Skip to content

CDRIVER-5998 import persisted private keys for SChannel #2059

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 24 commits into from
Jul 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
daceb1e
CDRIVER-6000 test MONGODB-X509 with cloud-dev
kevinAlbs Jul 10, 2025
9f6a604
add uppercase option to `bin_to_hex`
kevinAlbs Jul 13, 2025
7f6b1d9
CDRIVER-5998 import private keys as persisted
kevinAlbs Jul 14, 2025
d4234e8
define macros omitted in MinGW headers
kevinAlbs Jul 14, 2025
69f965f
fix CRL test and add instructions to manually remove CRL file
kevinAlbs Jul 15, 2025
c56a5c0
add separate uppercase and lowercase `bin_to_hex` functions
kevinAlbs Jul 15, 2025
0504f27
use `size_t` for hex/bin lengths
kevinAlbs Jul 15, 2025
d2b126a
use `mlib_nat64_parse` to parse hex
kevinAlbs Jul 15, 2025
cd31aea
replace `thumbprint` with `fingerprint`
kevinAlbs Jul 15, 2025
ca50f11
clarify certificate is being hashed
kevinAlbs Jul 15, 2025
bf3b9ad
add explicit cast
kevinAlbs Jul 15, 2025
d4da129
document `NTE_BAD_KEYSET` and do not check `keyHandle`
kevinAlbs Jul 16, 2025
605b324
tweak wording in comments
kevinAlbs Jul 16, 2025
d2bd526
assert returns of `NCryptFreeObject`
kevinAlbs Jul 16, 2025
5add402
assert returns of `CryptReleaseContext`
kevinAlbs Jul 16, 2025
771511a
fix accidental assignment
kevinAlbs Jul 16, 2025
5be73bd
use parens
kevinAlbs Jul 16, 2025
d17a256
better isolate test
kevinAlbs Jul 16, 2025
96feed2
add newline
kevinAlbs Jul 17, 2025
bf82fe6
use `ASSERT_WITH_MSG`
kevinAlbs Jul 22, 2025
f51a6c3
Use `mlib_assert_narrow`
kevinAlbs Jul 23, 2025
7df637a
format
kevinAlbs Jul 23, 2025
fb2881f
remove unnecessary lowercase `bin_to_hex`
kevinAlbs Jul 23, 2025
615c11a
add `utf8_to_wide` helper
kevinAlbs Jul 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions .evergreen/scripts/run-auth-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,20 @@ secrets_dir="$(to_absolute "${mongoc_dir}/../secrets")"
mkdir -p "${secrets_dir}"
chmod 700 "${secrets_dir}"

# Create certificate to test X509 auth with Atlas:
# Create certificate to test X509 auth with Atlas on cloud-prod:
atlas_x509_path="${secrets_dir:?}/atlas_x509.pem"
echo "${atlas_x509_cert_base64:?}" | base64 --decode > "${secrets_dir:?}/atlas_x509.pem"
# Fix path on Windows:
if $IS_WINDOWS; then
atlas_x509_path="$(cygpath -m "${secrets_dir:?}/atlas_x509.pem")"
atlas_x509_path="$(cygpath -m "${atlas_x509_path}")"
fi

# Create certificate to test X509 auth with Atlas on cloud-dev
atlas_x509_dev_path="${secrets_dir:?}/atlas_x509_dev.pem"
echo "${atlas_x509_dev_cert_base64:?}" | base64 --decode > "${atlas_x509_dev_path:?}"
# Fix path on Windows:
if $IS_WINDOWS; then
atlas_x509_dev_path="$(cygpath -m "${atlas_x509_dev_path}")"
fi

# Create Kerberos config and keytab files.
Expand Down Expand Up @@ -187,9 +195,12 @@ if [[ "${ssl}" != "OFF" ]]; then
LD_LIBRARY_PATH="${openssl_lib_prefix}" "${ping}" "${atlas_serverless:?}&${c_timeout}"
fi

echo "Connecting to Atlas with X509"
echo "Connecting to Atlas (cloud-prod) with X509"
LD_LIBRARY_PATH="${openssl_lib_prefix}" "${ping}" "${atlas_x509:?}&tlsCertificateKeyFile=${atlas_x509_path}&${c_timeout}"

echo "Connecting to Atlas (cloud-dev) with X509"
LD_LIBRARY_PATH="${openssl_lib_prefix}" "${ping}" "${atlas_x509_dev:?}&tlsCertificateKeyFile=${atlas_x509_dev_path}&${c_timeout}"

fi

echo "Authenticating using PLAIN"
Expand Down
7 changes: 7 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,13 @@ If you start `mongod` with SSL, set these variables to configure how
* `MONGOC_TEST_SSL_CRL_FILE`: path to a certificate revocation list.
* `MONGOC_TEST_SSL_WEAK_CERT_VALIDATION`: set to `on` to relax the client's
validation of the server's certificate.
* `MONGOC_TEST_SCHANNEL_CRL=on`: set to `on` to enable Windows Secure Channel tests loading CRL files.
* If CRL tests abort before deleting the CRL file, this may cause later test errors like `The certificate is revoked`. Manually remove the CRL file with:
```powershell
$crl = ".\src\libmongoc\tests\x509gen\crl.pem"
$fingerprint = (openssl crl -in ".\src\libmongoc\tests\x509gen\crl.pem" -noout -fingerprint) -replace 'SHA1 Fingerprint=', '' -replace ':', ''
certutil -delstore Root $fingerprint
```

The SASL / GSSAPI / Kerberos tests are skipped by default. To run them, set up a
separate `mongod` with Kerberos and set its host and Kerberos principal name
Expand Down
2 changes: 1 addition & 1 deletion src/libmongoc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ endfunction()
# Per-backend link libs/options:
set(SecureTransport/LINK_LIBRARIES "-framework CoreFoundation" "-framework Security")
set(SecureTransport/pkg_config_LIBS -framework Corefoundation -framework Security)
set(SecureChannel/LINK_LIBRARIES secur32.lib crypt32.lib Bcrypt.lib)
set(SecureChannel/LINK_LIBRARIES secur32.lib crypt32.lib Bcrypt.lib ncrypt.lib)
set(SecureChannel/pkg_config_LIBS ${SecureChannel/LINK_LIBRARIES})
set(OpenSSL/LINK_LIBRARIES OpenSSL::SSL OpenSSL::Crypto $<$<PLATFORM_ID:Windows>:crypt32.lib>)
set(OpenSSL/pkg_config_LIBS -lssl -lcrypto $<$<PLATFORM_ID:Windows>:crypt32.lib>)
Expand Down
Loading