Я использую OP C UA-клиент для подключения через самозаверяющую авторизацию сертификата.
Я использую OP C UA Client / Server SDK на основе ANSI * от Unified Automation.
OpcUa_CertificateStoreConfiguration PKIConfig;
OpcUa_Handle hCertificateStore = OpcUa_Null;
OpcUa_MemSet(&PKIProvider, 0, sizeof(PKIProvider));
OpcUa_CertificateStoreConfiguration_Initialize(&PKIConfig);
pSession->UserToken.TokenType = OpcUa_UserTokenType_Certificate;
OpcUa_ByteString_Initialize(&pSession->UserToken.Token.X509.UserCertificate);
OpcUa_Key_Initialize(&pSession->UserToken.Token.X509.UserPrivateKey);
PKIConfig.strPkiType = (char *) OPCUA_P_PKI_TYPE_OPENSSL;
PKIConfig.strTrustedCertificateListLocation = config.certificatePath;
uStatus = OpcUa_PKIProvider_Create(&PKIConfig, &PKIProvider);
OpcUa_GotoErrorIfBad(uStatus);
uStatus = PKIProvider.OpenCertificateStore(&PKIProvider, &hCertificateStore);
OpcUa_GotoErrorIfBad(uStatus);
uStatus = PKIProvider.LoadCertificate(&PKIProvider,
config.certificatePath,
hCertificateStore,
&pSession->UserToken.Token.X509.UserCertificate);
OpcUa_GotoErrorIfBad(uStatus);
uStatus = PKIProvider.LoadPrivateKey(config.keyPath,
OpcUa_Crypto_Encoding_PEM,
OpcUa_Null,
&pSession->UserToken.Token.X509.UserPrivateKey);
pClientConfiguration->PkiConfig=PKIConfig;
OpcUa_GotoErrorIfBad(uStatus);
uStatus = PKIProvider.CloseCertificateStore(&PKIProvider, &hCertificateStore);
OpcUa_GotoErrorIfBad(uStatus);
В случае установки любого URI безопасности конечной точки я получаю ответ:
2020-03-25T16:06:25.229Z|W|16427740* UA Client: Connecting to opc.tcp://*******:48020 ...
2020-03-25T16:06:25.229Z|E|16427740* UaClient_Session_BeginConnect: no client certificate was configured
2020-03-25T16:06:25.229Z|E|16427740* <-- UaClient_Session_BeginConnect (0x80890000)
В случае не установка любого URI безопасности конечной точки, Я получаю ответ:
2020-03-25T15:23:47.877Z|W|7553D740* OpcUa_SecureListener_ProcessSessionCallRequest: NonDiscovery Service requested through non secure channel.
2020-03-25T15:23:47.879Z|E|7553D740* OpcUa_SecureListener_ProcessRequest: Closing channel due error 0x80550000!
2020-03-25T15:23:47.880Z|W|7553D740* OpcUa_TcpListener_ReadEventHandler: Process Request returned an error (0x80550000)!
2020-03-25T15:23:47.884Z|W|7553D740* OpcUa_TcpListener_ReadEventHandler: Closing socket (0x00000000)!