dOPC Client Toolkit
Close
Example
ua.client.TdOPCUAClient.DecryptPrivateKey
program ConsolePrivateFromFile; {$APPTYPE CONSOLE} {$R *.res} uses sysutils, IOUtils,
ua.client
; var OPCClient:
TdOPCUAClient
; ProgPath : string; Bytes : TBytes; begin ProgPath := ExtractFilePath(Paramstr(0)); OPCClient := TdOPCUaClient.
Create
(nil); try OPCClient.
Url
:= 'opc.tcp://localhost:53530/OPCUA/SimulationServer'; OPCClient.
SecurityLib
:= TuaSecurityLib.uaSNative; // or also possibe TuaSecurityLib.uaSOpenSSL OPCClient.
SecurityMode
:= TuaSecurityMode.uaSSignAndEncrypt; OPCClient.
SecurityPolicy
:= TuaSecurityPolicy.uaSPBasic256Sha256; Bytes := TFile.ReadAllBytes(ProgPath+'UAPassword.pem'); // read encrypted private key from file Bytes := OPCClient.DecryptPrivateKey(Bytes,'test'); // decypt private key with password OPCClient.SecurityKeypair.PrivateKey.FromBytes(Bytes); OPCClient.SecurityKeypair.PublicKey.FromFile (ProgPath+'UAPassword.der'); OPCClient.
Active
:= true; Writeln('connected :-)'); except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; FreeAndNil(OPCClient); Writeln('press any key to exit'); readln; end.
Copyright © 2001 to 2026 by Kassl GmbH.