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​

pub enum MessageSecurityMode {
Invalid = 0,
None = 1,
Sign = 2,
SignAndEncrypt = 3,
}

When constructing a Session, ConnectionConfig pass the following:

use darra_opcua::{Session, ConnectionConfig, MessageSecurityMode};

let mut cfg = ConnectionConfig::new("opc.tcp://server:4840");
cfg.security_mode = MessageSecurityMode::SignAndEncrypt;
cfg.client_cert_path = Some("C:/certs/client.pfx".into());
cfg.client_key_path = Some("123456".into()); // PFX Password (Reused Field)
let mut s = Session::with_config(cfg)?;
s.connect()?;
ModeData IntegrityConfidentialityApplicable
None××Development / Internal Network / Debugging
Sign✓×Tamper-proof, but not sniffer-proof
SignAndEncrypt✓✓Production Recommendations

SecurityPolicyUri​

Support (Current Implementation):

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

ConnectionConfig.security_policy_uri = None Press "mode" to select automatically:

  • None → #None
  • Sign / SignAndEncrypt → #Basic256Sha256

UserToken​

pub enum UserTokenType {
Anonymous = 0,
Username = 1,
Certificate = 2,
Issued = 3,
}

Select by ConnectionConfig field:

TokenField
AnonymousNo username (None)
Usernameusername = Some(...) + password = Some(...)
Certificate(To be refined in future versions) User Certificate Parameters
Issued(This feature is not currently SDK available.)
// Username + Password
cfg.username = Some("operator".into());
cfg.password = Some("secret".into());

Certificate Tools (Rust Side)​

Currently, there is no Rust SDK built-in CertificateManager tool (C# has one). We recommend using OpenSSL or directly reusing C# Darra.OpcUa.Core.dll 's CertificateManager to generate certificates PFX, which can then be side-loaded in Rust.

For more information, see Certificate Generation and Configuration.

All encryption configurations are handled through the field ConnectionConfig; there is no separate API. Full support begins in SDK Stack Phase 6 Sign / SignAndEncrypt encryption channel.

Next Step​