Hello
I am creating a client application with open62541 v1.3.5. I have been checking the command line examples and I think I understand them, but I have problems with connections. Most probably I am misunderstanding the process.
My steps are:
- Find endpoints in the server. I get two endpoints, one with security mode None and security policy None and the other with security mode Sign and Encrypt and policy BasicSha256Rsa. In both endpoints TokenTypes are Anonymous and User/password (no X509 or Issued Token)
- The user selects one endpoint. Now I let the user select if he wants to connect anonymously or using user/password, and with the second endpoint I ask the user also for the client certificate and private key file.
- Anonymous connection works with the None/None endpoint, but User/password does not.
- If the selected endpoint security mode is Sign and Encrypt I call UA_ClientConfig_setDefaultEncryption() with the certificates, and then I call UA_Client_connect() or UA_Client_connectUsername(), depending if anonymous or user/password mode is selected. None work.
I have activated Trace logging, but I am now on another computer so I do not have the exact errors at hand.
My code:
m_client = UA_Client_new();
UA_ClientConfig* config = UA_Client_getConfig(m_client);
UA_ClientConfig_setDefault(config);
// Set message mode and security policy Uri depending on selected endpoint
config->securityMode = (UA_MessageSecurityMode)m_serverInfo.SecurityMode;
UA_String_clear(&config->securityPolicyUri);
config->securityPolicyUri = UA_String_fromChars(m_serverInfo.SecurityPolicyUri.c_str());
if (config->securityMode
> UA_MESSAGESECURITYMODE_NONE)
UA_ClientConfig_setDefaultEncryption(config, clientCertificate, privateClientKey, NULL, 0, NULL, 0);
if (Anonymous)
UA_Client_connect(m_client, m_serverInfo.Url);
else
UA_Client_connectUsername(m_client, m_serverInfo.Url, User, Password);
TIA