mongo/jstests/ssl/x509
Varun Ravichandran 1c88e8299b SERVER-106946 Reject x.509 certificates with mismatched client|serverAuth EKU (#42831)
GitOrigin-RevId: 1ca4451393cb9cd18be4948020cdbbad1d597288
2025-10-22 04:08:47 +00:00
..
BUILD.bazel SERVER-109091 Create glob-like targets for jstest libraries (#39901) 2025-08-11 23:22:56 +00:00
README SERVER-74999 Determine cluster membership based on X.509 extension 2023-04-03 18:55:21 +00:00
apple-certs.yml SERVER-98680 Add MacOS trusted certificate definitions (#30737) 2025-01-03 00:32:16 +00:00
certs.yml SERVER-106946 Reject x.509 certificates with mismatched client|serverAuth EKU (#42831) 2025-10-22 04:08:47 +00:00
mkcert.py SERVER-99522 Delete dead py linters (#31760) 2025-04-09 19:33:45 +00:00
mkcrl.sh SERVER-101034 Use rules_lint shfmt formatter (#38448) 2025-07-16 01:55:34 +00:00
mkdigest.py Revert "SERVER-99694: remove cryptography dependency with hashlib (#3… (#31558) 2025-01-24 23:00:35 +00:00
root-and-trusted-ca.pem SERVER-91435: Regenerate test certs with legacy flag (#23490) 2024-06-14 19:34:11 +00:00
root-and-trusted-ca.pem.digest.sha1 SERVER-91435: Regenerate test certs with legacy flag (#23490) 2024-06-14 19:34:11 +00:00
root-and-trusted-ca.pem.digest.sha256 SERVER-91435: Regenerate test certs with legacy flag (#23490) 2024-06-14 19:34:11 +00:00
trusted-client-testdb-roles.pem SERVER-91435: Regenerate test certs with legacy flag (#23490) 2024-06-14 19:34:11 +00:00
trusted-client-testdb-roles.pem.digest.sha1 SERVER-91435: Regenerate test certs with legacy flag (#23490) 2024-06-14 19:34:11 +00:00
trusted-client-testdb-roles.pem.digest.sha256 SERVER-91435: Regenerate test certs with legacy flag (#23490) 2024-06-14 19:34:11 +00:00

README

This directory contains two scripts.

mkcert.py    - A python3 script using PyOpenSSL to generate the majority of
               X509 certificates based on the contents of certs.yml
mkcrl.sh     - Certificate Revocation List generators.

mkcert.py may be invoked without any arguments, in which case it will regenerate ALL certificates.
Alternatively, pass one or more certificate symbolic names.
If any of these certificates represent CAs, then all dependent certificates will also be regenerted.

cert.yml format:

global:
  output_path: '.../'   # Required, default output path for all certs in this file.
  Subject: {...}        # Optional, name entities to use for all cert, overridden by values in cert entries.

certs:
    # Required, this will be used as the name of the file, and for referencing issuers.
  - name: 'name-of-cert.pem'
    # Required, this will be included in the generated certificates.
    description: Tell us about yourself.
    # Required, The X509 subject name.
    Subject: { C: US, ST: New York, etc... }
    # Required, Who is the (intermediate) CA for this certificate.  May be 'self'.
    Issuer: 'ca.pem'
    # Optional, x509 version (default: 3)
    version: 3
    # Optional, set to true to ignore global.Subject values.
    explicit_subject: false
    # Optional, hash algorithm to use
    hash: sha256
    # Optional, key algorithm to use
    key_type: RSA
    # Optional, serial number to assign this certificate (default: random number >= 1000)
    serial: 42
    # Optional, validity start date, currently expressed in seconds relative to now.
    not_before: -86400 # 1 day ago
    # Optional, validity end date, currently expressed in seconds relative to now. 
    # Note that not_after - not_before, the validity period, should be less than or equal to 825 days, see:
    # https://support.apple.com/en-us/HT210176
    not_after: 71107200 # 823 days from now
    # Optional, where to store this certificate (overrides global)
    output_path: 'jstests/ssl/libs/'
    # Optional, IDs of other public keys to append to the file
    append_certs: ['ca.pem', 'intermediate-ca.pem', ...]
    # Optional, passphrase to encript private key with
    passphrase: 'secret'
    # Optional, x509v3 extensions, refer to: https://www.openssl.org/docs/man1.1.0/man5/x509v3_config.html
    pkcs1: true
    # Optional, by default encrypted passwords use PKCS#8 format. Set this to use PKCS#1
    pkcs12: true | map with keys below
    # Optional, make a pkcs12 copy of the certificate
        passphrase: 'secret'
        # Optional, all PKCS#12 keys must be encrypted. Will use cert.passphase if not provided.
        name: 'name-of-cert.pfx'
        # Optional, name of PKCS#12 version of certificate. If not provided, the original cert will be overwritten with the PKCS#12 version
    extensions: # All extensions are optional.
    - basicConstraints: {}
    - keyUsage: {}
    - extendedKeyUsage: {}
    - subjectKeyIdentifier: hash
    - authorityKeyIdentifier: keyid | issuer
    - subjectAltName: {DNS: [...], IP: [...]}
    - mongoRoles:
      - {role: readWrite, db: test1}
      - {role: read, db: test2}
    - mongoClusterMembership: clusterName