| 130 | |
| 131 | |
| 132 | def _write_cert(path, cert_key_pair, password=None): |
| 133 | certificate, private_key = cert_key_pair |
| 134 | if password: |
| 135 | encryption = serialization.BestAvailableEncryption(password) |
| 136 | else: |
| 137 | encryption = serialization.NoEncryption() |
| 138 | with open(path + ".key.pem", "wb") as f: |
| 139 | f.write( |
| 140 | private_key.private_bytes( |
| 141 | encoding=serialization.Encoding.PEM, |
| 142 | format=serialization.PrivateFormat.TraditionalOpenSSL, |
| 143 | encryption_algorithm=encryption, |
| 144 | ) |
| 145 | ) |
| 146 | with open(path + ".cert.pem", "wb") as f: |
| 147 | f.write( |
| 148 | certificate.public_bytes( |
| 149 | encoding=serialization.Encoding.PEM, |
| 150 | ) |
| 151 | ) |
| 152 | |
| 153 | |
| 154 | def new_ca(path, **subject): |