server PrivateKey with passphrase

Questions regarding the use of the C++ SDK for Server or Client development or integration into customer products ...

Moderator: uasdkcpp

Post Reply
fourrepascal
Jr. Member
Jr. Member
Posts: 1
Joined: 09 Apr 2013, 17:56

server PrivateKey with passphrase

Post by fourrepascal »

Hello,
Using sdk c++ 1.6.3 for a server based on the sample (ServerConfigXML, uaSerrverApplicationCallback, CoreModule).

We have to use a private key (.pem) proteted by a passPhrase. (des3 or aes256)

Is there any sample code, using a pem privatekey with passphrase ?

Tried to set the password for each endpoind in OpcCallback afterLoadConfiguration() : but it doesn't work

Code: Select all

// avril 2021 : Prise en compte de la passphrase sur la clef privée :
    UaEndpointArray uaEndpointArray;
    pServerConfigData->getEndpointConfiguration(sRejectedCertificateDirectory, nRejectedCertificatesCount, uaEndpointArray);

    // affiche les instances de serveur OPC-UA
    if (uaEndpointArray.length() > 0 )
    {
        // pour chaque endpoint
        for (OpcUa_UInt32 idx = 0; idx < uaEndpointArray.length(); idx++)
        {
            // renseignement passphrase
            uaEndpointArray[idx]->setPassword("tartampion");
        }
    }
But the UaModule cannot load the private key... (uaServerCpp.log)

Code: Select all

** urn:2KIT002KN1B:UnifiedAutomation:UaServerCpp: start trace
** Date: 2021-04-28
**
07:49:41.008Z|3|F7E1A8C0* Version information UA Server SDK:
07:49:41.008Z|3|F7E1A8C0*     1.6.3.406
07:49:41.008Z|3|F7E1A8C0*     Nov 27 2020 13:00:55
07:49:41.008Z|3|F7E1A8C0*     GNU C++ 4.8
07:49:41.008Z|3|F7E1A8C0* Version information UA Stack:
07:49:41.008Z|3|F7E1A8C0*     Version:1.4.5 228
...
07:49:54.090Z|2|F7E1A8C0* WARNING: No ApplicationControlCallback available, cannot create ServerConfigurationType object
07:49:54.094Z|3|F7E1A8C0* Session [ID=0] created. Current instances count = 1
07:49:54.148Z|1|F7E1A8C0* [uastack] Could not open ini file !!!
07:49:54.148Z|1|F7E1A8C0* [uastack] Error code: 2
07:49:54.152Z|1|F7E1A8C0* Error: CertificateConfiguration::loadCertificate [ret=Bad] - loadPrivateKey failed
07:49:54.152Z|1|F7E1A8C0* Error: UaServer::openEndpoint load certificate FAILED [ret=0x80000000]
07:49:54.152Z|1|F7E1A8C0* Open Endpoint FAILED for endpoint 0 with URL=opc.tcp://1KIT001KN1A:4852 [ret=0x80000000]
07:49:54.152Z|1|F7E1A8C0* Error: CertificateConfiguration::loadCertificate [ret=Bad] - loadPrivateKey failed
07:49:54.152Z|1|F7E1A8C0* Error: UaServer::openEndpoint load certificate FAILED [ret=0x80000000]
07:49:54.152Z|1|F7E1A8C0* Open Endpoint FAILED for endpoint 1 with URL=opc.tcp://127.0.0.1:4852 [ret=0x80000000]
07:49:54.152Z|1|F7E1A8C0* <== OpcServer::start - can not start up UA module
07:49:54.202Z|3|F7E1A8C0* Session [ID=0] deleted. Remaining instances count = 0
[/i]

Thank you in advance for your answers
greetings

Post Reply