Skip to content

Commit 5416301

Browse files
committed
PYTHON-5040 Update README and add run_server.py comment
1 parent 3aa994d commit 5416301

2 files changed

Lines changed: 38 additions & 10 deletions

File tree

.evergreen/scripts/run_server.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ def start_server():
4444
set_env("TLS_PEM_KEY_FILE", certs / "server.pem")
4545
set_env("TLS_CA_FILE", certs / "ca.pem")
4646
if sys.platform == "darwin":
47+
# macOS MongoDB Enterprise uses Apple SecTrust, which rejects our
48+
# test CA and certs. See test/certificates/README.md for details.
4749
extra_opts.append("--tls-allow-invalid-certificates")
4850

4951
if opts.auth:

test/certificates/README.md

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,32 @@ Run the generation script from this directory:
1010
bash gen-certs.sh
1111
```
1212

13-
**Prerequisites:** OpenSSL 1.1+ or LibreSSL 3+
13+
**Prerequisites:** Python 3 with the `cryptography` package (`pip install cryptography`).
1414

1515
## Certificate details
1616

17-
| File | Subject | Signed by | Purpose |
18-
|---|---|---|---|
19-
| `ca.pem` | `CN=Drivers Testing CA, ...` | Self (CA) | Root CA for test certs |
20-
| `server.pem` | `CN=localhost, ...` + SAN | Drivers Testing CA | MongoDB server cert (key + cert) |
21-
| `client.pem` | `CN=client, O=MDB, ...` | Drivers Testing CA | Client auth cert (key + cert) |
22-
| `password_protected.pem` | Same as client | Drivers Testing CA | Client cert with AES-256 encrypted key |
23-
| `crl.pem` || Drivers Testing CA | Empty Certificate Revocation List |
24-
| `trusted-ca.pem` | `CN=Trusted Kernel Test CA, OU=Kernel, ...` | Self (CA) | Separate CA for bundle tests |
17+
Two classes of leaf certificate are generated, with different extension profiles to satisfy
18+
conflicting requirements from Python's ssl module and macOS's SecTrust framework:
19+
20+
**MongoDB certs** — presented to MongoDB Enterprise, verified by Apple SecTrust on macOS.
21+
No AKI or SKI. Adding AKI causes SecTrust to attempt OCSP revocation checks; because our
22+
CA is not in the macOS system keychain, those checks fail with `CSSMERR_TP_CERT_SUSPENDED`.
23+
24+
**KMS certs** — presented by KMS mock servers, verified by Python's ssl module (OpenSSL).
25+
Carry both AKI and SKI. Python 3.13 requires AKI on non-root certs; Python 3.14 enables
26+
`X509_V_FLAG_X509_STRICT` in `ssl.create_default_context()`, which requires SKI too.
27+
28+
| File | Subject | Signed by | Extensions | Purpose |
29+
|---|---|---|---|---|
30+
| `ca.pem` | `CN=Drivers Testing CA, ...` | Self (CA) | basicConstraints critical, keyUsage critical | Root CA for all test certs |
31+
| `server.pem` | `CN=localhost, ...` + SAN | Drivers Testing CA | SAN only | MongoDB server cert (key + cert) |
32+
| `client.pem` | `CN=client, O=MDB, ...` | Drivers Testing CA | keyUsage, extKeyUsage | Client auth cert (key + cert) |
33+
| `password_protected.pem` | Same as client | Drivers Testing CA | keyUsage, extKeyUsage | Client cert with AES-256 encrypted key |
34+
| `crl.pem` || Drivers Testing CA || CRL revoking serial 1 (server.pem) |
35+
| `server-kms.pem` | `CN=localhost, ...` + SAN | Drivers Testing CA | SAN, AKI, SKI | KMS mock server cert (key + cert) |
36+
| `wrong-host.pem` | `CN=wronghost.example.com` | Drivers Testing CA | SAN, AKI, SKI | KMS wrong-host test cert |
37+
| `expired.pem` | `CN=localhost, ...` + SAN | Drivers Testing CA | SAN, AKI, SKI | KMS expired cert (validity 2000–2001) |
38+
| `trusted-ca.pem` | `CN=Trusted Kernel Test CA, ...` | Self (CA) | basicConstraints critical, keyUsage critical | Separate CA for CA-bundle tests |
2539

2640
**Password** for `password_protected.pem`: `qwerty`
2741

@@ -37,4 +51,16 @@ The following values are hardcoded in tests and **must not change**:
3751

3852
## Background
3953

40-
Certificates were regenerated to add the **Authority Key Identifier (AKI)** extension, which Python 3.13 requires for TLS certificate chain validation (PYTHON-5040). Prior to regeneration, certs were missing AKI, causing `ssl.SSLCertVerificationError: Missing Authority Key Identifier` on macOS and Windows with Python 3.13.
54+
Certificates were regenerated for PYTHON-5040 to fix `ssl.SSLCertVerificationError` failures on
55+
macOS and Windows with Python 3.13+. The root causes were:
56+
57+
1. Python 3.13 / OpenSSL 3.x requires **AKI** on non-root certs. The original 2019 certs had none.
58+
2. Python 3.14 enables `X509_V_FLAG_X509_STRICT` in `ssl.create_default_context()`, which
59+
additionally requires **SKI** on non-root certs and `basicConstraints`/`keyUsage` to be critical
60+
on CA certs.
61+
62+
The CA cert intentionally omits SKI even though strict mode would normally require it on all
63+
certs: adding SKI to the CA triggers macOS SecTrust OCSP revocation checks on the MongoDB server
64+
startup path (MongoDB 4.2 Enterprise uses Apple SecTrust), causing ~67-second connection
65+
timeouts. KMS connections bypass this by using `ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)` instead
66+
of `ssl.create_default_context()`, which does not enable strict mode.

0 commit comments

Comments
 (0)