Security Model (Security)
The OPC UA security model has two layers:
- Transport Layer — Is the channel signed/encrypted (
MessageSecurityMode) - Identity Layer — What credentials does the user use to log in? (
UserTokenType)
The two layers are independent; you can use either "encrypted channel + anonymous login" or "plaintext channel + username and password."
- Enable Encryption — PFX Certificates / SecurityMode Hands-On Training
- FAQ — Encryption Configuration — Mutual Trust and Common Mistakes
MessageSecurityMode
| Mode | Value | Tamper-proof | Encryption |
|---|---|---|---|
| Invalid | 0 | — | — |
| None | 1 | × | × |
| Sign | 2 | ✓ | × |
| SignAndEncrypt | 3 | ✓ | ✓ |
SecurityPolicy
Defining a specific cipher suite:
| Policy URI | Algorithm | Status |
|---|---|---|
| #None | — | None Mode Only |
| #Basic128Rsa15 | RSA-1.5 + AES-128 + SHA-1 | Deprecated (Not SDK supported) |
| #Basic256 | RSA-OAEP + AES-256 + SHA-1 | Deprecated (Not SDK supported) |
| #Basic256Sha256 | RSA-OAEP + AES-256 + SHA-256 | Main SDK Purpose |
| #Aes128_Sha256_RsaOaep | AES-128 + SHA-256 + RSA-OAEP | This feature is not currently SDK supported. |
| #Aes256_Sha256_RsaPss | AES-256 + SHA-256 + RSA-PSS | This feature is not currently SDK supported. |
This is the current SDK default setting Basic256Sha256 and the recommended OPC Foundation "current standard strength." The deprecated Basic128Rsa15 and Basic256 are no longer supported.
Certificate (X.509)
OPC UA endpoint authentication with X.509 certificates:
- Client Certificate (PFX) — Contains a private key; held by the client
- Server Certificate — Server-side storage, client-side optional verification (TOFU or pre-import)
- Mutual Trust — Both parties need to add the other party's public key to their own trusted/ directory.
The certificate SAN(Subject Alternative Name) must contain a value in the URI form of urn:<vendor>:<product>:<instance>, and URI this value ApplicationUri must match, otherwise the handshake will be rejected.
UserToken (Login credentials)
| Token | Value | Note |
|---|---|---|
| Anonymous | 0 | Anonymous |
| Username | 1 | Username + Password |
| Certificate | 2 | X.509 User Certificate (which may be different from the transport-layer certificate) |
| Issued | 3 | OAuth2 / SAML Token-based authentication (not currently SDK implemented) |
Combination of an encrypted channel and user identity
| Scenario | MessageSecurityMode | UserToken | Applicable |
|---|---|---|---|
| Intranet Development | None | Anonymous | Fastest, 0 overhead |
| Internal Network Production | Sign | Username | Tamper-Resistant + Identity Auditing |
| Public Network Production | SignAndEncrypt | Username or Certificate | Standard Production Configuration |
| High Security | SignAndEncrypt | Certificate | Two-factor authentication (certificate-based login + encrypted channel) |
Handshake Procedure
Client Server
│ ──Hello (Endpoint URL)──────▶│
│ ◀────Acknowledge─────────────│
│ ──OpenSecureChannel(cert)───▶│
│ ◀────channel established─────│
│ ──CreateSession(usercert)───▶│
│ ◀────sessionId───────────────│
│ ──ActivateSession(uToken)───▶│
│ ◀────activated───────────────│
│ ──Read/Write/Browse/...─────▶│
│ ◀────responses───────────────│
If any step fails, the result will be StatusCode (BadCertificateInvalid / BadIdentityTokenRejected / BadUserAccessDenied / ...).
Timestamp Verification
In SignAndEncrypt Sign mode, both parties verify the timestamp; a discrepancy of more than ~10 minutes will result in rejection. This must be configured in the production environment NTP.
Related Links
- Enable Encryption — PFX Generate / SecurityMode Select
- FAQ — Encryption Configuration — Mutual Trust and Common Mistakes
- FAQ — Connection Troubleshooting — StatusCode Quick Reference
- Required Environment — Internet / NTP / Certificates