1
+ This directory contains:
2
+
3
+ - mkcert.py
4
+ Python script; uses the cryptography package to deterministically generate X509 certificates,
5
+ CRLs, and digests based on the contents of certs.yml.
6
+ - certs.yml
7
+ Main certificate definition file.
8
+ - apple-certs.yml
9
+ Certificate definitions for certs to be installed on provision of OSX machines.
10
+
11
+ To run:
12
+
13
+ python -m x509.mkcert [--config CONFIG] [--mkcrl | --no-mkcrl] [-o OUTPUT] [--static-dir STATIC_DIR] [certs ...]
14
+ - CONFIG is the path to the certs.yml file specifying a list of certificates, default x509/certs.yml
15
+ - OUTPUT is the path to a directory where the generated items will be stored, default .
16
+ - STATIC_DIR is the path where signing keys needed by certificates are stored, default x509/static
17
+ - If --mkcrl is specified, CRLs will be generated after certificate generation ends. Default false.
18
+ These are hardcoded and require certain certificates to be generated to work.
19
+ - certs is an optional list of certificate names to generate. If it is not specified, all
20
+ certificates specified in the config are generated.
21
+
22
+ If a certificate specified in certs references other certificates, its dependencies and
23
+ subdependencies will be generated.
24
+
25
+ Deterministic generation is based on the current year. This means that if mkcert is run on the same
26
+ definitions file twice, it will produce the same certificates if both runs were in the same year.
27
+ One exception to this is the pkcs12 format; the cryptography library does not provide
28
+ functionality for generating pkcs12 bundles deterministically.
29
+
30
+ Future work:
31
+
32
+ - Define CRLs in the definition file instead of hardcoding them.
33
+ - Define keys in the definition file, and make a script to generate all necessary keys which would
34
+ be run whenever a new key was defined.
35
+
36
+ certs.yml format:
37
+
38
+ global: # Optional, default value to use for Key1 for all certs, overridden by values in cert entries.
39
+ Key1: Value1
40
+ ...
41
+
42
+ certs:
43
+ # Required, this will be used as the name of the file, and for referencing issuers.
44
+ - name: 'name-of-cert.pem'
45
+ # Required, this will be included in the header of the generated certificate.
46
+ description: Tell us about yourself.
47
+ # Required, The X509 subject name.
48
+ Subject: { C: US, ST: New York, etc... }
49
+ # Required, Who is the (intermediate) CA for this certificate. May be 'self'.
50
+ Issuer: 'ca.pem'
51
+ # Required, relative (within static directory) path to the keyfile to sign this certificate with.
52
+ keyfile: 'key.pem'
53
+ # Optional, set to true to ignore global.Subject values.
54
+ explicit_subject: false
55
+ # Optional, serial number to assign this certificate (default: sequential numbers starting from 1000)
56
+ serial: 42
57
+ # Optional, validity start date, expressed in seconds relative to midnight on the first day of the current year.
58
+ not_before: -86400 # 1 day before
59
+ # Optional, validity end date, currently expressed in seconds relative to midnight on the first day of the current year.
60
+ # Note that not_after - not_before, the validity period, should be less than or equal to 825 days, see:
61
+ # https://support.apple.com/en-us/HT210176
62
+ not_after: 71107200 # 823 days after
63
+ # Optional, IDs of other public keys to append to the file
64
+ append_certs: ['ca.pem', 'intermediate-ca.pem', ...]
65
+ # Optional, passphrase to encript private key with
66
+ passphrase: 'secret'
67
+ # Optional, make a pkcs12 copy of the certificate
68
+ pkcs12: true | map with keys below
69
+ # Optional, all PKCS#12 keys must be encrypted. Will use cert.passphase if not provided.
70
+ passphrase: 'secret'
71
+ # Optional, name of PKCS#12 version of certificate. If not provided, the original cert will be overwritten with the PKCS#12 version
72
+ name: 'name-of-cert.pfx'
73
+ # Optional, in addition to the .pem file, write just the certificate to a .crt file and just the signing key to a .key file
74
+ split_cert_and_key: true
75
+ # Optional, don't write a header comment to this cert
76
+ include_header: false
77
+ # Optional, X.509 extensions to include in the certificate
78
+ extensions: # All extensions are optional.
79
+ - basicConstraints: {}
80
+ - keyUsage: {}
81
+ - extendedKeyUsage: {}
82
+ - subjectAltName: {DNS: [...], IP: [...]}
83
+ - subjectKeyIdentifier: hash
84
+ - authorityKeyIdentifier: keyid | issuer
85
+ - authorityInfoAccess:
86
+ - method: OCSP
87
+ - location: uri-to-OCSP-server
88
+ - mustStaple: true
89
+ - nsComment: "Comment"
90
+ - mongoRoles:
91
+ - {role: readWrite, db: test1}
92
+ - {role: read, db: test2}
93
+ - mongoClusterMembership: clusterName
0 commit comments