OPC UA Server
The EtherCAT Master includes an embedded OPC UA Server running on port 4840 (default). It exposes the EtherCAT process image, master/slave status, and administrative commands.
Information Model
The server exposes the following nodes under the Objects folder:
Master
This object represents the EtherCAT Master itself.
State (Variable, Read-Only,
EcatStateEnum): Current state of the master.EcatStateEnumis a custom enumeration with the valuesNONE= 0,INIT= 1,PREOP= 2,BOOT= 3,SAFEOP= 4 andOP= 8.CyclicFaultIndicator (Variable, Read-Only): Indicator for cyclic communication faults, see Cyclic Communication Faults.
requestState (Method): Request a state transition for the master (
INIT,PREOP,SAFEOPorOP). See RequestMasterState for details.Arguments:
targetState(EcatStateEnum)
Slaves
Contains a list of all configured EtherCAT slaves. Each slave is represented as an object with:
State (Variable, Read-Only,
EcatStateEnum): Current state of the slave. Slaves may also reportBOOT.VendorId, ProductCode, SerialNumber, SlaveId (Properties): Identity information.
ProcessImage
Access to the cyclic process data (PDOs).
Inputs: Folder containing all input variables read from slaves.
Outputs: Folder containing all output variables written to slaves.
PackedImage (Variable, Read-Only, ByteString): All variables of Inputs and Outputs, including the read-only (echoed) outputs, packed into one little-endian byte string without padding, read consistently from one EtherCAT cycle. Each variable is packed exactly like its node. In dummy mode the image packs the current node values. A read with an IndexRange returns only that byte range, e.g. the slot of one variable.
Layout (Property): JSON array with one
{"name", "direction", "type", "elementSize", "isArray", "count", "offset"}object per variable, in packing order;directionisinputoroutput,typeis the OPC UA DataType name (SByte,Byte,Int16,UInt16,Int32,UInt32,Int64,UInt64,FloatorDouble),isArraytells whether the variable’s node holds an array ofcountelements (possibly just one) or a scalar (countis 1).
Variables are organized by their names as defined in the ENI file or configuration.
In dummy mode (dummy_opcua_server), where there is no bus, every variable starts with a zero value of its type until a client writes it.
System
System-level information and control.
SystemInfo (Variable): Struct containing current state and error information.
Version (Property): Application version string.
RunsInDummyMode (Variable): True if running without real hardware (‘dummy mode’).
Reset (Method): Acknowledge the error and return to
CONFIG. See Reset for details.Events: The server emits events for log messages (Info, Warning, Error).
CoE (CanOpen over EtherCAT)
Methods for acyclic communication (SDO).
StartSdoWrite (Method): Start an SDO download.
Arguments:
slaveIndex,index,subIndex,data(ByteString),timeoutMs.Returns:
requestId(UInt64).
PollSdoWrite (Method): Poll a started SDO download.
Arguments:
requestId.Returns:
done(Boolean),success(Boolean),abortCode(UInt32).
StartSdoRead (Method): Start an SDO upload.
Arguments:
slaveIndex,index,subIndex,size,timeoutMs.Returns:
requestId(UInt64).
PollSdoRead (Method): Poll a started SDO upload.
Arguments:
requestId.Returns:
done(Boolean),success(Boolean),data(ByteString),abortCode(UInt32).
Note: the data byte strings are in little-endian byte order.
Security
This section assumes that you are familiar with the security configuration of OPC UA and with public key infrastructures.
By default, the server offers the SecurityPolicy None only, i.e. the communication is unencrypted and sessions are anonymous. This is only acceptable in trusted networks, e.g. the internal network of a Docker or Kubernetes deployment.
Setting a PKI directory (OPC UA PKI Directory) enables encryption. The server then offers the SecurityPolicies Basic256Sha256, Aes128_Sha256_RsaOaep and Aes256_Sha256_RsaPss, each with the security modes Sign and SignAndEncrypt. SecurityPolicies are explained in OPC 10000-2, 4.6 and defined as profiles of OPC 10000-7. Client certificates are checked against the trust list in the PKI directory. The SecurityPolicy None stays available for endpoint discovery only, sessions over it are refused unless OPC UA Allow Security Policy None is set. Anonymous sessions remain allowed, user authentication is not supported yet.
This applies to both run modes.
PKI Directory
The PKI directory has the following layout:
<pki>/
├── ApplCerts/
│ ├── own/
│ │ ├── certs/
│ │ └── private/
│ ├── trusted/
│ │ ├── certs/
│ │ └── crl/
│ └── issuer/
│ ├── certs/
│ └── crl/
└── UserTokenCerts/ reserved for user certificates, currently unused
ApplCerts follows the certificate store directory layout of OPC 10000-12, F.1.
Missing folders are created on start.
The folders of ApplCerts hold:
own/certs: the server certificate, exactly one.deror.pemfile.own/private: the private key of the server certificate, with the same base name as the certificate (.der,.pemor.key).trusted/certs: the trusted client certificates and the certificates of trusted CAs (.deror.pem).trusted/crl: the certificate revocation lists of the CAs (.crl).issuer/certs: CA certificates that are needed to complete a certificate chain, but are not trusted themselves.
To trust a new client, copy its certificate to trusted/certs.
Changes of the trust list take effect without a restart.
Instead of trusting each client certificate individually, the certificate of a CA can be placed in trusted/certs.
Then every client certificate issued by this CA is trusted.
Certificates of intermediate CAs go to issuer/certs.
See OPC 10000-2, 9.2 and 9.3 for the management of self-signed and CA signed certificates.
Certificate revocation lists are optional.
If trusted/crl holds none, revocation is not checked.
If it holds any, each CA needs its revocation list there, also intermediate CAs: certificates issued by a CA without a revocation list are rejected.
Self-signed client certificates are not affected.
Self-Signed Certificate
With OPC UA Create Self-Signed Cert, the server creates a self-signed certificate on start, if ApplCerts/own/certs holds no certificate yet.
The certificate is written to ApplCerts/own/certs/server.der, its key to ApplCerts/own/private/server.der.
The subject alternative name of the certificate contains the application URI, the hostname and localhost.
If clients connect by another name or by IP address, list the names and addresses with OPC UA Cert Hostnames instead of the hostname and localhost.
By default, the certificate is valid for one year, OPC UA Cert Validity Days sets a different validity.
An existing certificate is never replaced, also not when it has expired.
To get a new one, delete both files and restart the server.
Without this option, the server does not start if there is no certificate.
The application URI of the server must match the URI in its certificate. When using a certificate issued elsewhere, set OPC UA Application URI to the URI in that certificate.
Clients have to trust the server certificate, either the certificate in ApplCerts/own/certs itself or the certificate of the CA that issued it.
A client that accepts any server certificate is open to an attacker posing as the server.
Insecure Options
Use these options only in trusted networks.
With OPC UA Accept All Client Certs, the server accepts any client certificate on the secure channel and ignores the trust list. This concerns the client (application) certificates, not user certificates for session authentication. The server then cannot tell which client application connects, and anyone who reaches the port can open a session.
With OPC UA Allow Security Policy None, the server also accepts sessions over the SecurityPolicy None, i.e. without encryption.