There is a configuration that can be forgotten after commissioning: the endpoint in None mode, the session anonymous, and “trust all certificates” ticked on the server. The reason is usually not that security is hard; it is that the logic of certificates and trust lists has not become clear in the team. Below, we cover in turn the three security layers, choosing the security mode and policy, user authentication, certificate renewal and the error codes most often seen in the console.
The three layers of the security architecture
In OPC UA, security is built in three independent layers, each answering a different question:
| Layer | Question | Mechanism |
|---|---|---|
| Application authentication | Do I trust this software? | Application instance certificate, trust list |
| Communication channel | Are messages transmitted unaltered and confidentially? | Security mode and security policy (SecureChannel) |
| User authentication | Who is opening this session, and what are they authorised for? | Anonymous, username/password, user certificate, token |
The layers do not replace one another. A trusted application certificate determines which software can connect, an encrypted channel protects messages in transit, and user authorisation determines which nodes the session can read and write. Even if the channel is encrypted, if anonymous sessions are allowed, what such a session can access is determined by the permissions the server grants the anonymous user. On an endpoint using username/password, how the password is protected depends on the UserTokenPolicy; this policy can be defined separately from the channel’s security policy.
Security inside the protocol does not replace the controls in industrial network infrastructure. Whichever zones OPC UA traffic flows between, that conduit must also be defined on the firewall; for the zone and conduit concept, the article the zone and conduit approach in IEC 62443 provides a good framework.
Application certificates and trust lists
Every OPC UA application, server and client alike, has its own X.509 v3 Application Instance Certificate. When a connection is established, the two sides exchange certificates, and each looks up the other’s in its own trust list. The fields that must be correct in the certificate:
- URI in the Subject Alternative Name: Must be identical to the application’s
ApplicationUri. This mismatch is a common cause of connection errors; even a difference in upper/lower case is enough. - DNS name and/or IP address in the SAN: The server certificate must contain the host name in the endpoint URL the client connects to.
- Key usage: Digital signature, key encipherment and data encipherment; serverAuth and clientAuth in extended key usage.
- Validity period: Start and end dates. If the device clock is wrong, a valid certificate is rejected too.
Most OPC UA stacks keep certificates in a file-based PKI directory: their own certificate (own), trusted certificates (trusted), CA certificates and revocation lists (issuers) and rejected certificates (rejected). At the first connection, the rejected counterpart certificate lands in the rejected folder. The administrator verifies the thumbprint and moves the certificate to trusted. If the connection behaves “as if it never tried”, this folder is the first place to look in the console. A one-by-one approval model is enough for small installations.
As the number of applications grows, an internal CA makes your work easier: only the CA certificate and CRL go into the trust list, and all application certificates signed by the CA are automatically trusted. The cost is CRL discipline. In many stacks, a CA chain whose CRL cannot be found results in a BadCertificateRevocationUnknown error. In larger installations, the Global Discovery Server (GDS) in OPC UA Part 12 centralises certificate distribution and trust list updates.
If your client software does not generate certificates, you can create one with the correct fields using OpenSSL 1.1.1 or later as shown below; if you have a CA, generating a CSR with the same fields and having it signed is more correct. For self-signed application certificates, many stacks also expect the keyCertSign bit. Because the mandatory extensions vary slightly between stacks, check the documentation of the SDK or product you use.
openssl req -x509 -newkey rsa:2048 -nodes -days 730 \
-keyout historian-client.key -out historian-client.pem \
-subj "/CN=HistorianClient/O=Factory" \
-addext "subjectAltName=URI:urn:historian01:Factory:HistorianClient,DNS:historian01" \
-addext "keyUsage=critical,digitalSignature,nonRepudiation,keyEncipherment,dataEncipherment,keyCertSign" \
-addext "extendedKeyUsage=serverAuth,clientAuth"
# Many stacks expect DER format
openssl x509 -in historian-client.pem -outform der -out historian-client.der
# Verify the fields
openssl x509 -in historian-client.der -inform der -noout -text
Choosing the security mode and security policy
Each endpoint is published with a security mode and security policy pair. The mode determines what is done to messages: None (no protection), Sign (integrity and source authentication) or SignAndEncrypt (confidentiality in addition to integrity). The policy defines which algorithms are used.
| Security policy | Status | Recommendation |
|---|---|---|
| None | No protection | Isolated test environment only |
| Basic128Rsa15 | Deprecated (SHA-1) | Disable |
| Basic256 | Deprecated (SHA-1) | Disable; temporary only if an old device requires it |
| Basic256Sha256 | Widely supported | Minimum acceptable level |
| Aes128_Sha256_RsaOaep | Current | Prefer if supported |
| Aes256_Sha256_RsaPss | Current | Prefer if supported |
Newer versions of the specification also define elliptic curve-based policies; support in field devices, however, is still limited. Our practical rule: on the server, enable SignAndEncrypt with at least Basic256Sha256 and the current policies supported; disable the None endpoint and SHA-1-based policies. Disable any endpoint no client uses.
Sign mode can be considered where the data is not confidential but it matters that it is not altered, and the encryption load strains a low-power device. If username/password authentication is used, prefer SignAndEncrypt.
User authentication methods
After the application has been authenticated and the channel established, a session is opened. The endpoint’s UserTokenPolicy list says which identity types are accepted:
- Anonymous: No identity. Acceptable only for a limited, read-only view; must never be combined with write or method call rights.
- UserName: Username and password. The password is encrypted with the security policy defined in the UserTokenPolicy; if no policy is specified there, the channel’s policy is used. If both are None, the specification allows the password to be sent unencrypted; whether products accept this combination varies, so verify it in your product’s documentation. Some servers integrate with a directory service (LDAP/AD).
- Certificate (X509): A separate certificate belonging to the user or service account. Because it requires no password management, it suits machine-to-machine service accounts.
- IssuedToken: A token obtained from an external authorisation server. Support varies by product.
An identity not tied to permissions is of no use. If the server supports role-based access, separate at least three roles: data collectors that only read (historian, dashboards), systems that write to specific variables (the MES’s work order and recipe fields) and an engineering account authorised for configuration. Create a separate account for each consuming system. In a plant running with a single shared account, when a recipe value is written incorrectly, you cannot find out from the log who wrote it.
Certificate lifecycle and renewal
When a certificate expires, no new connection can be established; without monitoring, this is only noticed as a gap in the historian data. Plan renewal before commissioning:
- Build an inventory: For each OPC UA application, record the certificate thumbprint, expiry date and which trust lists it is in.
- Set up monitoring: Generate advance warnings for certificates approaching their expiry date. The server certificate can often be read via OPC UA, and application certificate files via the file system.
- Do an overlapping transition: First add the new certificate to the counterparts’ trust lists, then switch the application to the new certificate, and finally remove the old one from the list.
- Verify time synchronisation: PLCs, gateways and servers should be synchronised with NTP; false “not yet valid” and “expired” alarms mostly come from clock drift.
- Define the revocation process: The certificate of an application that is decommissioned or suspected of being compromised is removed from the trust list; in the CA model, it is added to the CRL.
In installations using a CA, certificate lifetimes can be kept short and renewal automated. In the manual trust list model, the balance is different: the longer the lifetime, the higher the risk; the shorter, the higher the operational burden. Set this balance according to the number of applications in the plant.
Order of checks for connection errors
| Error code | Likely cause | Check |
|---|---|---|
| BadCertificateUntrusted | The counterpart’s certificate is not in the trust list | Examine the rejected folder, verify and move it to trusted |
| BadSecurityChecksFailed | General security error; often a trust or signature problem | Check the trust status on both sides and the detailed reason in the server log |
| BadCertificateUriInvalid | SAN URI and ApplicationUri differ | Compare the openssl x509 -text output with the application configuration |
| BadCertificateHostNameInvalid | The name in the endpoint URL is not in the certificate | Connect using the DNS name/IP in the certificate, or renew the certificate |
| BadCertificateTimeInvalid | The certificate has expired or the device clock is wrong | Check the dates and NTP status |
| BadCertificateRevocationUnknown | No CRL found for the CA | Add an up-to-date CRL under issuers |
| BadSecurityPolicyRejected | The policy chosen by the client is disabled on the server | Examine the endpoint list (GetEndpoints) |
| BadIdentityTokenRejected / BadUserAccessDenied | The identity type is not accepted or the user is not authorised | Check the UserTokenPolicy and role mappings |
Error codes are reported in different levels of detail depending on the stack. The general code the client sees is often not enough; the server log tells the real reason. If the connection is established only “sometimes”, check whether several copies of the same application are running with different certificates; a client installation copied to a backup server generating its own certificate is a typical cause. Current error code definitions are in the specification parts on the OPC Foundation Online Reference.
Secure configuration checklist
- The
Noneendpoint and SHA-1-based policies are disabled;SignAndEncryptwith at leastBasic256Sha256is enabled. - Automatic certificate acceptance is disabled; the trust list contents are documented.
- In application certificates, the SAN URI matches the ApplicationUri; the server certificate contains the correct DNS name/IP.
- Anonymous access is disabled or limited to a read-only view.
- A separate account and role for each consuming system; write access only on the nodes that need it.
- All devices are synchronised with NTP; certificate expiry dates are monitored.
- The OPC UA port (default TCP 4840 or the port the product uses) is open on the firewall only to defined clients.
- The server sends security events (rejected connections, failed sessions) to the central logging system.
We described what can be done at the network layer for protocols without security mechanisms, such as Modbus and S7, in the article industrial firewall DPI rules. For a security assessment of your OPC UA infrastructure and zone design, see our OT cybersecurity and segmentation page, and for the integration side, our OPC UA, MQTT and data integration page.
Frequently asked questions
Is a firewall rule still needed when encryption is enabled?
Yes. OPC UA security protects the integrity and confidentiality of the connection and the identity of the parties; it does not restrict which systems can reach the server. A firewall rule narrows the attack surface and acts as a second layer against a protocol-level vulnerability.
Should we use self-signed certificates or an internal CA?
If there are a few clients and servers, a trust model with self-signed certificates managed one by one is workable. As the number of applications grows, an internal CA simplifies trust list management; in that case, keeping the CRL up to date and distributing it becomes mandatory.
What should be done if an old device only supports Basic256?
First, check whether the manufacturer has a software update that brings support for current policies. If not, keep the device in an isolated zone, use the old policy only through an endpoint or intermediary server dedicated to that device, and record this exception in the risk register.
Why did the connection drop after the certificate was renewed?
If the new certificate is put into service before it is added to the other side’s trust list, the connection is rejected. The correct order: first add the new certificate to the lists of all counterparts, then switch the application to the new certificate, and finally remove the old one from the list.