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

RUST-226 Support tlsCertificateKeyFilePassword #1256

Merged

Conversation

abr-egn
Copy link
Contributor

@abr-egn abr-egn commented Dec 2, 2024

RUST-226

This will (probably; I'm not sure how to test it) allow using tlsCertificateKeyFilePassword or the corresponding in-code option field. Should work for both rustls-tls and openssl-tls.

@abr-egn abr-egn changed the title RUST-226 Support tlsCertificateKeyFilePassword when using rustls RUST-226 Support tlsCertificateKeyFilePassword Dec 2, 2024
Copy link
Contributor

@kevinAlbs kevinAlbs left a comment

Choose a reason for hiding this comment

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

LGTM with additional suggestions applied.

Testing with the drivers-evergreen-tools certificates initially got this error:

Error { kind: InvalidTlsConfig { message: "Invalid encrypted private key: PKCS#8 ASN.1 error: unknown/unsupported OID: 1.2.840.113549.3.7 at DER byte 66" }, labels: {}, wire_version: None, source: None }

OID 1.2.840.113549.3.7 refers to a DES algorithm. The error was fixed by adding features 3des, des-insecure, and sha1-insecure:

pkcs8 = { version = "0.10.2", features = [
    "encryption",
    "pkcs5",
    "3des",
    "des-insecure",
    "sha1-insecure",
] }

However, https://docs.rs/pkcs8/latest/pkcs8/ notes:

DES support (gated behind the des-insecure feature) is implemented to allow for decryption of legacy PKCS#8 files only.

I expect that the drivers-evergreen-tools certificate using outdated algorithms. I suggest keeping those feature flags out for now (as is done in current changes).

With those feature flags added, I was able to connect (both with openssl-tls and without) with this test.

abr-egn and others added 4 commits December 2, 2024 15:57
Co-authored-by: Kevin Albertson <kevin.albertson@10gen.com>
Co-authored-by: Kevin Albertson <kevin.albertson@10gen.com>
Co-authored-by: Kevin Albertson <kevin.albertson@10gen.com>
@abr-egn abr-egn marked this pull request as ready for review December 2, 2024 21:15
@abr-egn
Copy link
Contributor Author

abr-egn commented Dec 2, 2024

I expect that the drivers-evergreen-tools certificate using outdated algorithms. I suggest keeping those feature flags out for now (as is done in current changes).

Yup, that makes sense. Downstream users can enable those features if they happen to be using keys with those algorithms.

With those feature flags added, I was able to connect (both with openssl-tls and without) with this test.

Thank you!

@abr-egn
Copy link
Contributor Author

abr-egn commented Dec 3, 2024

Update: I've put this behind an optional feature flag, since my expectation is that the very large majority of users will never want this and that avoids pulling in extra dependencies for them.

Copy link
Contributor

@isabelatkinson isabelatkinson left a comment

Choose a reason for hiding this comment

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

Code changes LGTM. There's a parsing test in src/client/options/test.rs that can be unskipped as part of this as well. Would it be feasible to add something like Kevin's test to CI? I'd like to avoid inadvertently breaking this in the future

@abr-egn
Copy link
Contributor Author

abr-egn commented Dec 4, 2024

Code changes LGTM. There's a parsing test in src/client/options/test.rs that can be unskipped as part of this as well. Would it be feasible to add something like Kevin's test to CI? I'd like to avoid inadvertently breaking this in the future

Unskipped the test; I'd like to leave the CI integration test for a follow-up PR for expediency and to make merging into the backport branch simpler.

Copy link
Contributor

@isabelatkinson isabelatkinson left a comment

Choose a reason for hiding this comment

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

I'd like to leave the CI integration test for a follow-up PR for expediency and to make merging into the backport branch simpler.

Makes sense, filed RUST-2112

@abr-egn abr-egn merged commit 0ac9fdf into mongodb:main Dec 4, 2024
7 of 9 checks passed
abr-egn added a commit to abr-egn/mongo-rust-driver that referenced this pull request Dec 4, 2024
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