Forum > Networking and Web Programming

OPC_UA: UA_Client_connectUsername

(1/1)

luca:
Hi,
there is already a post about this topic but don't fix my problem.

I've dowloaded the wrapper from https://lacak.users.sourceforge.net/freepascal.html for Open62541 dll.

All is fine if I use None as Authentication settings

If I enable the username and password the connection returns the error Fail status code: 80020000 BadInternalError


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  (*** Connection - Anonymous user, Security None ***)// THIS WORKS  res := UA_Client_connect(client, PAnsiChar(cbServer.Text));   // UA_Client_connect() -> connectSync() -> UA_Client_run_iterate() -> UA_Client_renewSecureChannel() + UA_Client_backgroundConnectivity()//THIS RETURNS THE ERROR  res := UA_Client_connectUsername(client, PAnsiChar(cbServer.Text),'user','pass');   if res <> UA_STATUSCODE_GOOD then begin    Memo1.Lines.Append(Format('Fail status code: %x %s', [res, AnsiString(UA_StatusCode_name(res))]));    UA_Client_delete(client);    client := nil;    Exit;  end;   
Any suggestions?
Many thanks

tr_escape:
Did you check last version of this library?

https://github.com/fluisgirardi/fpopen62541

Maybe related.

luca:
Hi,
I was able to compile the library using Visual Studio 2019.
Then I ran the example using None as authentication settings and all is working exactly as in Lazarus.

To use Username and Password it seems it's mandatory to use the certificate to set the Encryption.

This is the part of the example in C:


--- Code: C  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---        ...                UA_ByteString certificate = loadFile(certfile);        UA_ByteString privateKey = loadFile(keyfile);        if(trustList) {            /* Load the trust list */            size_t trustListSize = 1;            UA_STACKARRAY(UA_ByteString, trustListAuth, trustListSize);            trustListAuth[0] = loadFile(trustList);            UA_ClientConfig_setDefaultEncryption(cc, certificate, privateKey,                                                 trustListAuth, trustListSize, NULL, 0);... 
This is a discussion about this topic:
https://github.com/open62541/open62541/issues/4766

Now the point is that I have the .der certificate file BUT I'm not able to find the UserKey file.

I'm using Windows 10 and Lazarus 2.2.0

Regards
Luca

 

Navigation

[0] Message Index

Go to full version