Skip to content

CDRIVER-4269 support PKCS#8 keys with Secure Channel #2024

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

Merged
merged 11 commits into from
Jun 4, 2025

Conversation

kevinAlbs
Copy link
Collaborator

Summary

Support PKCS#8 RSA keys with Windows Secure Channel

Patch build: https://spruce.mongodb.com/version/683853839983780007e8a268

Background

Intended to ease using MONGODB-X509 with Atlas. Atlas creates client certificates in PKCS#8 with RSA keys. Prior to these changes, attempting to load a PKCS#8 key with the C driver built with Secure Channel results in this error:

Failed to parse private key. (0x8009310B) ASN1 bad tag value met.

This PR only adds support for unencrypted RSA keys. This is similar to the server limitation loading from file. I expect future support of non-RSA keys will require a more substantial change to switch to CNG (see CDRIVER-4530). This PR is intended to be backported to enable X509 auth to Atlas without the needed workaround described in CDRIVER-4269 (convert to PKCS#1).

The test client certificate, pkcs8-unencrypted.pem is copied from drivers-evergreen-tools.

kevinAlbs added 5 commits May 29, 2025 11:21
To indicate only RSA key data is referred to.
To remove repeated double-call (once to get length, once to decode).
@kevinAlbs kevinAlbs marked this pull request as ready for review May 29, 2025 15:33
@kevinAlbs kevinAlbs requested a review from a team as a code owner May 29, 2025 15:33
@kevinAlbs kevinAlbs requested review from eramongodb and mdb-ad May 29, 2025 15:33
@kevinAlbs kevinAlbs requested a review from eramongodb June 3, 2025 15:28
Copy link
Contributor

@eramongodb eramongodb left a comment

Choose a reason for hiding this comment

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

One last question; otherwise, LGTM.

@kevinAlbs kevinAlbs merged commit 78922a5 into mongodb:master Jun 4, 2025
39 of 42 checks passed
kevinAlbs added a commit to kevinAlbs/mongo-c-driver that referenced this pull request Jun 4, 2025
kevinAlbs added a commit to kevinAlbs/mongo-c-driver that referenced this pull request Jun 4, 2025
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.

3 participants