Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ApplicationCertificate in client option #86

Open
gfbaggio opened this issue Oct 22, 2018 · 1 comment
Open

ApplicationCertificate in client option #86

gfbaggio opened this issue Oct 22, 2018 · 1 comment

Comments

@gfbaggio
Copy link

This is not really an issue but I dont know where to ask help.
I am new to OPC and I would like to have some help on how to set up the application certificate to connect to a server.

Thanks to all.

Frank !

@noumanqaiser
Copy link

HI @gfbaggio

I know its a super late reply, but I assume this still may help someone. If when connecting you are seeing the exception that certificate is required. The solution below assumes you have a X509 certificate present as a file, if not, you can easily create one and then add that certificate as a trusted client certificate in your opc server(for Kepware this is done by: right clicking the kep ServerEx tray, Open OPC UA Configuration manager and then add then import the certificate file to the trusted clients tab)

Add the following code before you call the .connect method

         var options = new UaClientOptions {};

        // The path to the certificate.
        string Certificate = @"C:\ProgramData\OPC Foundation\CertificateStores\MachineDefault\certs\cert.der";

        // Load the certificate into an X509Certificate object.
        X509Certificate2 cert = new X509Certificate2();

        cert.Import(Certificate);
        options.ApplicationCertificate = cert; 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants