|
1 | | -#!/usr/bin/env python3 |
| 1 | +# /// script |
| 2 | +# requires-python = ">=3.8" |
| 3 | +# dependencies = ["cryptography"] |
| 4 | +# /// |
2 | 5 | """Generate TLS test certificates for the PyMongo test suite. |
3 | 6 |
|
4 | 7 | Two classes of leaf cert are generated: |
|
27 | 30 | (CSSMERR_TP_CERT_SUSPENDED) because the CA is not in the system keychain. |
28 | 31 |
|
29 | 32 | Usage: |
30 | | - pip install cryptography |
31 | | - python gen-certs.py # run from test/certificates/ |
| 33 | + uv run gen-certs.py # run from test/certificates/ |
32 | 34 |
|
33 | 35 | Password for password_protected.pem: qwerty |
34 | 36 | """ |
|
39 | 41 | import sys |
40 | 42 | from pathlib import Path |
41 | 43 |
|
42 | | -try: |
43 | | - from cryptography import x509 |
44 | | - from cryptography.hazmat.primitives import hashes, serialization |
45 | | - from cryptography.hazmat.primitives.asymmetric import rsa |
46 | | - from cryptography.hazmat.primitives.serialization import ( |
47 | | - BestAvailableEncryption, |
48 | | - Encoding, |
49 | | - NoEncryption, |
50 | | - PrivateFormat, |
51 | | - ) |
52 | | - from cryptography.x509.oid import ExtendedKeyUsageOID, NameOID |
53 | | -except ImportError: |
54 | | - sys.exit("cryptography package is required: pip install cryptography") |
| 44 | +from cryptography import x509 |
| 45 | +from cryptography.hazmat.primitives import hashes, serialization |
| 46 | +from cryptography.hazmat.primitives.asymmetric import rsa |
| 47 | +from cryptography.hazmat.primitives.serialization import ( |
| 48 | + BestAvailableEncryption, |
| 49 | + Encoding, |
| 50 | + NoEncryption, |
| 51 | + PrivateFormat, |
| 52 | +) |
| 53 | +from cryptography.x509.oid import ExtendedKeyUsageOID, NameOID |
55 | 54 |
|
56 | 55 | SCRIPT_DIR = Path(__file__).parent.resolve() |
57 | 56 | DAYS = 7300 # ~20 years |
|
0 commit comments