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

[Client] Fix UserIdentity for CertificateIdentifer & add parameter for console reference client to specify UserCertificate #2624

Merged
merged 4 commits into from
Jun 5, 2024

Conversation

romanett
Copy link
Contributor

Proposed changes

  • Fix the UserIdentity constructor to load the private key of a provided certificateIdenifier.
  • make UserIdentity constructor throw a ServiceResultException when a Certificate with no private key is specified.
  • extend console reference client with two new parameters:
    -uc Thumbprint of a user certifiate located in the TrustedUserCertificatesStore
    -ucp Password of the private key of the user certificate
  • add documentation for console reference client

Related Issues

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • Enhancement (non-breaking change which adds functionality)
  • Test enhancement (non-breaking change to increase test coverage)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected, requires version increase of Nuget packages)
  • Documentation Update (if none of the other choices apply)

Checklist

  • I have read the CONTRIBUTING doc.
  • I have signed the CLA.
  • I ran tests locally with my changes, all passed.
  • I fixed all failing tests in the CI pipelines.
  • I fixed all introduced issues with CodeQL and LGTM.
  • I have added tests that prove my fix is effective or that my feature works and increased code coverage.
  • I have added necessary documentation (if appropriate).
  • Any dependent changes have been merged and published in downstream modules.

Further comments

Tested with a Certificate created with XCA.
Public Key was exported as DER
Private key was exported as PEM without PW and also as PFX with a password.
Both work as a user identity token.

@romanett romanett self-assigned this May 20, 2024
Copy link

codecov bot commented May 20, 2024

Codecov Report

Attention: Patch coverage is 0% with 7 lines in your changes are missing coverage. Please review.

Project coverage is 47.94%. Comparing base (91ef753) to head (f486750).

Files Patch % Lines
Stack/Opc.Ua.Core/Stack/Client/UserIdentity.cs 0.00% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2624      +/-   ##
==========================================
- Coverage   54.66%   47.94%   -6.72%     
==========================================
  Files         343      328      -15     
  Lines       65218    63782    -1436     
  Branches    13354    13056     -298     
==========================================
- Hits        35653    30582    -5071     
- Misses      25685    29722    +4037     
+ Partials     3880     3478     -402     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


#### Certificate
Place your user certificate in the TrustedUserCertificatesStore (the path can be found in the client configuration XML). Make shure to include an accessible private key with the certificate.
Specify console parameters:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: sure

CertificateIdentifier userCertificateIdentifier = null;

// get user certificate with matching thumbprint
X509Certificate2Collection userCertifiactesWithMatchingThumbprint =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Certificate

Copy link
Contributor

@mregen mregen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great sample and bug fix.

@mregen mregen merged commit 8a1df6d into OPCFoundation:master Jun 5, 2024
71 of 73 checks passed
@romanett romanett deleted the UserCertificates branch July 12, 2024 08:03
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

Successfully merging this pull request may close these issues.

Improve console client sample with user certificate support
2 participants