Login  •  Register


Certificate authentication on secure channel  Topic is solved

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

Certificate authentication on secure channel

Postby ChillyGonzales » 10 May 2016, 16:53

Hello,

I am running authentication tests using the .NET demo server and the Getting started client available in the Unified Automation package.
With the client I can successfully:
- Authenticate on a secure channel (signed messages) with username and password (credentials of the demo server)
- Authentication on unsecure channel with a certificate that has been previously added to the server trust list.

However I am not able to authenticate with a certificate and with security turned on at the same time. I only use a .pfx file and not the certificate store.

I always get the "Key not valid for use in specified state" error (see below).

Image

Am I missing something or is this a feature not supported by the demo server ?

Thank you,

--
Sergueï
ChillyGonzales
Newbie
Newbie
 
Posts: 2
Joined: 10 May 2016, 15:08

Re: Certificate authentication on secure channel  Topic is solved

Postby Support Team » 11 May 2016, 08:19

Hello,

There is bug in the example code.
Please replace the lines
Code: Select all
fs = System.IO.File.OpenRead(X509_Certificate.Text);
byte[] bytes = new byte[fs.Length];
fs.Read(bytes, 0, Convert.ToInt32(fs.Length));

// Add the certificate to the user identity.
m_session.UserIdentity.Certificate = SecurityUtils.LoadCertificate(bytes);

// Set the UserIdentityType.
m_session.UserIdentity.IdentityType = UserIdentityType.Certificate;

by
Code: Select all
// Add the certificate to the user identity.
m_session.UserIdentity.Certificate = Certificate.LoadPrivateKey(X509_Certificate.Text, null);

// Set the UserIdentityType.
m_session.UserIdentity.IdentityType = UserIdentityType.Certificate;
Best regards
Unified Automation Support Team
User avatar
Support Team
Hero Member
Hero Member
 
Posts: 2392
Joined: 18 Mar 2011, 15:09

Re: Certificate authentication on secure channel

Postby ChillyGonzales » 12 May 2016, 10:39

Works perfectly.
Thank you !
ChillyGonzales
Newbie
Newbie
 
Posts: 2
Joined: 10 May 2016, 15:08

Re: Certificate authentication on secure channel

Postby Poledog » 13 May 2019, 09:48

I tried the solution above but I cannot get it to work.
Get error "The current endpoint does not support the specified user identity token."

Certificate authentication on secure channel is really puzzling me.
Poledog
Newbie
Newbie
 
Posts: 1
Joined: 10 May 2019, 15:43


Return to .NET based OPC UA SDK

Who is online

Users browsing this forum: No registered users and 0 guests