dOPC Client Toolkit
Close
Example
program SecureConnect; {$APPTYPE CONSOLE} {$R *.res} uses sysutils, ua.client, ua.datatypes, ua.buildintypes; var OPCClient: TdOPCUAClient; ProgPath : string; begin ProgPath := ExtractFilePath(Paramstr(0)); OPCClient := TdOPCUaClient.Create(nil); try OPCClient.SecurityMode := TuaSecurityMode.uaSSignAndEncrypt; OPCClient.SecurityPolicy := TuaSecurityPolicy.uaSPBasic256Sha256; OPCClient.Url := 'opc.tcp://localhost:53530/OPCUA/SimulationServer'; OPCClient.SecurityKeypair.LoadCertificateFromFile(ProgPath+'UACreateCert'); // load private and public key with one call { or also possible OPCClient.SecurityKeypair.PublicKey.FromFile (ProgPath+'UACreateCert.der'); OPCClient.SecurityKeypair.PrivateKey.FromFile (ProgPath+'UACreateCert.pem'); // with user authentication method OPCClient.UserLogin.SetUser('test','test'); // with certificate authentication method Please note: Only for test with same certificate OPCClient.UserLogin.LoginMode := TuaSecurityUser.Certificate; OPCClient.UserLogin.Keypair.LoadCertificateFromFile(ProgPath+'UACreateCert'); } OPCClient.Active := true; Writeln('connected :-)'); except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; OPCClient.Free; Writeln('press any key to exit'); readln; end.
Kassl GmbH Copyright © 2024. All rights reserved.