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

Problem in certificate thumbprint calculation #925

Closed
Filipecordeiro opened this issue Dec 28, 2020 · 4 comments
Closed

Problem in certificate thumbprint calculation #925

Filipecordeiro opened this issue Dec 28, 2020 · 4 comments
Assignees
Labels
bug To Review The fix of this issue need to be tested by the community before issue is closed

Comments

@Filipecordeiro
Copy link

Filipecordeiro commented Dec 28, 2020

Current behavior

Using a server with the node-opcua implementation and a client using other implementation (UaExpert): when using a certificate signed by a CA for the server (i.e. not a self-signed certificate), the server throws an error while checking the receiverCertificateThumbprint sent by the client.

Describe the bug

The _check_receiverCertificateThumbprint method (node-opcua-secure-channel\source\server\server_secure_channel_layer.ts) is using the whole certificate chain for calculating the certificate thumbprint. While the opcua specification is not clear, it does mention the receiverCertificateThumbprint indicates the public key used to encrypt the MessageChunk, and every method that I've tested for calculating certificate thumbprints (including openssl) seems to use just the certificate itself and not the full certificate chain.

I've also found this issue in a Java implementation of opcua that seems exactly the same problem where they changed it to use the certificate only.

I've changed the code in _check_receiverCertificateThumbprint from const serverCertificateChain = this.getCertificateChain(); to const serverCertificateChain = this.getCertificate(); and it solved the problem.

Also had to make the same change in code in the verifyClientSignature method (node-opcua-server\source\opcua_server.ts) that seems to suffer from the same issue (full certificate chain is being used).

To Reproduce

Steps to reproduce the behavior:

  1. Start node-opcua acting as an OPCUA SERVER, using a certificate signed by a CA, providing at least MessageSecurityMode = Sign&Encrypt, and automaticallyAcceptUnknownCertificate = true
  2. Try connecting with a client (other than a node-opcua implementation), using MessageSecurityMode = Sign&Encrypt
  3. Server throws an error and client disconnects

Expected behavior

The client should connect successfully, i.e., the receiverCertificateThumbprint sent by the client should match the certificate thumbprint computed by the server.

Details

  • ( ) my request is related to node-opcua acting as an OPCUA CLIENT

  • (x) my request is related to node-opcua acting as an OPCUA SERVER

    • ( ) I have installed node-opcua from source ( using git clone)

    • (x) I have installed node-opcua as a package ( using npm install )

    • (x) I am using an application that uses node-opcua

      • ( ) node-red
      • (x) other : UaExpert
    • Device: Laptop

    • OS version: Windows 10

      • (x) Windows : version : 10.0.18363
      • ( ) Linux : version : **_**
      • ( ) MacOs : version : **_**
      • ( ) Raspbian: version : **_**
      • ( ) Other : specify :
    • Description of the other OPCUA system I am trying to connect to:

  • node-opcua version: :
    2.16.0

  • Node:
    10.19.0

@erossignon
Copy link
Member

Using certificate provided by a CA should work.
Please provide source code of the server for investigation. (contact me privately if you cannot share the code in github)

@erossignon erossignon added please subscribe to support.sterfive.com for help ( go https://support.sterfive.com for professional support if no answer from community) need more info The issue cannot be resolved as described and need deeper investigation labels Dec 29, 2020
@node-opcua node-opcua deleted a comment from mikakaraila Dec 29, 2020
@erossignon erossignon added bug and removed need more info The issue cannot be resolved as described and need deeper investigation please subscribe to support.sterfive.com for help ( go https://support.sterfive.com for professional support if no answer from community) labels Dec 29, 2020
@erossignon
Copy link
Member

erossignon commented Dec 29, 2020

I confirm the issue. As you found out, certificate thumbprint signature shall not be calculated using full certficate chain but only first certificate in the chain.

@erossignon
Copy link
Member

This should now be fixed in version 2.29 , @Filipecordeiro can you confirm ?

@erossignon erossignon added the To Review The fix of this issue need to be tested by the community before issue is closed label Jan 23, 2021
@Filipecordeiro
Copy link
Author

This should now be fixed in version 2.29 , @Filipecordeiro can you confirm ?

I can confirm that the issue is fixed. Thank you @erossignon
I apologize for the late reply but I wasn't able to test this until very recently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug To Review The fix of this issue need to be tested by the community before issue is closed
Projects
None yet
Development

No branches or pull requests

2 participants