Skip to main content

Security Encryption

This section covers SDK encryption-related topics API and certificate tools.

Subpage Redirect
  • For information on generating certificates, configuring server-to-server trust, and troubleshooting, please refer to Certificate Generation and Configuration.
  • For information on how to pass security parameters when creating a Session, please refer to Constructor.
  • For information on security mode detection supported by the server, please refer to GetEndpoints.

Three types SecurityMode​

public enum MessageSecurityMode { Invalid, None, Sign, SignAndEncrypt }

Pass the following when constructing a Session:

using DarraOpcUa_Client;

var (pfxPath, password) = CertificateManager.EnsureClientCertificate();

using var ua = new DarraOpcUa("opc.tcp://server:4840",
securityMode: MessageSecurityMode.SignAndEncrypt,
clientCertPath: pfxPath,
clientKeyPath: password); // Enter the PFX password — not the path to the private key file.
ModeData IntegrityConfidentialityApplicable
None××Development / Internal Network / Debugging
Sign✓×Tamper-proof, but not sniffer-proof
SignAndEncrypt✓✓Production Recommendations

Sign / SignAndEncrypt Next clientCertPath Required; if missing, Connect() discard OpcUaException, it is StatusCode DarraInvalidArgument, and will not be downgraded to plaintext.

SecurityPolicyUri​

Support (Current Implementation):

  • http://opcfoundation.org/UA/SecurityPolicy#None
  • http://opcfoundation.org/UA/SecurityPolicy#Basic256Sha256 (Primary Use)

Do not pass; press securityPolicyUri the button; securityMode auto-select: None → #None, others → #Basic256Sha256. Other policies (Basic128Rsa15 / Basic256 / Aes128_Sha256_RsaOaep, etc.) are not currently supported by this implementation.

UserToken​

public enum UserTokenType { Anonymous, Username, Certificate, Issued }

Select by construction parameters:

TokenConstruction Parameters
AnonymousDo not share username
Usernameusername: "...", password: "..."
CertificateNot currently available
IssuedNot currently available

Certificate / Issued is used solely to identify the capabilities published GetEndpoints by the server; connection paths are not currently provided.

CertificateManager (Certificate Tool)​

using DarraOpcUa_Client;

// Retrieve the client PFX (generate a self-signed certificate if it does not exist), and return the path and password
var (pfxPath, password) = CertificateManager.EnsureClientCertificate();

// Force a new self-signing certificate
var (newPfxPath, newPassword) = CertificateManager.ForceRegenerate();

// View the currently cached certificate
Console.WriteLine(CertificateManager.DescribeCachedCertificate());

For more details, see Certificate Generation and Configuration.

Next Step​