Skip to content

opc.tcp · UA Binary

OPC UA Client

Put an OPC UA client into your application. The SDK handles secure channels, sessions and certificate validation.

What it does

  • opc.tcp transport and UA Binary encoding.
  • Basic256Sha256, Aes128_Sha256_RsaOaep and Aes256_Sha256_RsaPss with Sign and SignAndEncrypt; None only when you allow it.
  • Anonymous and user name/password identities; trusted certificates named explicitly.
  • Endpoint discovery, Browse, Read, Write, Call, Subscriptions and MonitoredItems.
  • A C ABI, a C++ RAII header, a Qt client worker, a .NET assembly and an MFC client worker.

Example

Each binding shows code from a real example file in the examples folder of the PDComm SDK. The source file and line range appear above the code.

OPC UA C client

Source: examples/opcua/opcua_client.c:149-171
memset(&options, 0, sizeof(options));
options.struct_size = (uint32_t)sizeof(options);
options.version = 1;
status = pdcomm_opcua_client_options_init(&options);
if (status != PDCOMM_OPCUA_OK) { print_error("options", status); goto done; }
options.timeout_ms = timeout;
options.policy = policy;
options.mode = mode;
options.flags = policy == PDCOMM_OPCUA_POLICY_NONE ? PDCOMM_OPCUA_ALLOW_NONE : 0;
options.certificate_der.data = certificate;
options.certificate_der.size = certificate_size;
options.private_key_pem.data = key;
options.private_key_pem.size = key_size;
options.trusted_server_der.data = trust;
options.trusted_server_der.size = trust_size;
status = pdcomm_opcua_client_connect((const uint8_t *)argv[1], strlen(argv[1]), &options, &client);
/* The SDK copied the identity; wipe the private key now. */
example_wipe(key, key_size);
key = NULL;
if (status != PDCOMM_OPCUA_OK) { print_error("connect", status); goto done; }
status = pdcomm_opcua_client_activate_anonymous(client);
if (status != PDCOMM_OPCUA_OK) { print_error("activate", status); goto done; }
printf("Session activated (anonymous)\n");

From the OPC UA C client example: open a SignAndEncrypt secure channel with the client certificate, private key and trusted server certificate, then activate an anonymous session.