Skip to content
Start free evaluation

pdcomm_opcua_client_activate_user_name

Function

Activates the session with a UserNameIdentityToken (ActivateSession).

int32_t pdcomm_opcua_client_activate_user_name(pdcomm_opcua_handle client, const uint8_t *name, size_t name_size, const uint8_t *secret, size_t secret_size)

Declared in: #include <pdcomm/opcua/pdcomm_opcua.h>

The secure channel must not use SecurityPolicy None. When the endpoint's user token policy uses a secure SecurityPolicy, the secret is encrypted for the server certificate: up to 64 bytes with the legacy encrypted token format, longer secrets as an RSA EncryptedSecret (see #PDCOMM_OPCUA_USER_SECRET_HEADER_POLICY_ONLY). When the token policy uses SecurityPolicy None, the secret is sent unencrypted inside the token, which the client allows only on a SignAndEncrypt channel.

Parameters

NameDescription
clientClient handle.
nameUser name in UTF-8, 1 to 1024 bytes.
name_sizeSize of name in bytes.
secretPassword in UTF-8, at most 16 KiB; borrowed during the call.
secret_sizeSize of secret in bytes.

Returns

#PDCOMM_OPCUA_OK; #PDCOMM_OPCUA_INVALID_INPUT for an empty or invalid name or a secret over 16 KiB; #PDCOMM_OPCUA_RUNTIME_ERROR for a name over 1024 bytes, a secret that is not UTF-8, a None channel, an endpoint without a user name token policy, a rejected user or a network failure; #PDCOMM_OPCUA_BUSY, #PDCOMM_OPCUA_CLOSED, #PDCOMM_OPCUA_INVALID_HANDLE or #PDCOMM_OPCUA_POISONED.

Notes

  • Blocks for up to timeout_ms. The library wipes its own copy of the secret; the caller owns and should wipe secret.