|
118 | 118 |
|
119 | 119 | Breaking changes versus the previous ``x509`` modules |
120 | 120 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 121 | +* The ``public_key`` parameter to ``x509.certificate_managed`` (and corresponding |
| 122 | + ``x509.create_certificate``) used to accept a private key. |
| 123 | + The new modules require an actual public key if this parameter is specified. |
| 124 | + You can pass a private key in the ``private_key`` parameter instead. |
| 125 | +
|
| 126 | + Failing to ensure it really is a public key you are passing as ``public_key`` fails |
| 127 | + with ``Could not load PEM-encoded public key.``. |
| 128 | +
|
121 | 129 | * The output format has changed for all ``read_*`` functions as well as the state return dict. |
122 | 130 | * The formatting of some extension definitions might have changed, but should |
123 | 131 | be stable for most basic use cases. |
@@ -267,33 +275,48 @@ def create_certificate( |
267 | 275 | The hashing algorithm to use for the signature. Valid values are: |
268 | 276 | sha1, sha224, sha256, sha384, sha512, sha512_224, sha512_256, sha3_224, |
269 | 277 | sha3_256, sha3_384, sha3_512. Defaults to ``sha256``. |
270 | | - This will be ignored for ``ed25519`` and ``ed448`` key types. |
| 278 | + Ignored for ``ed25519`` and ``ed448`` key types. |
271 | 279 |
|
272 | 280 | private_key |
273 | | - The private key corresponding to the public key the certificate should |
274 | | - be issued for. This is one way of specifying the public key that will |
275 | | - be included in the certificate, the other ones being ``public_key`` and ``csr``. |
| 281 | + A **private key**, which is used to derive the public key the certificate |
| 282 | + is issued for. If unset, checks ``public_key`` or ``csr`` to derive it. |
| 283 | +
|
| 284 | + Ignored when creating self-signed certificates (missing ``signing_cert``). |
| 285 | +
|
| 286 | + .. hint:: |
| 287 | + When ``encoding`` is ``pkcs12``, this private key is embedded into |
| 288 | + the resulting container. |
276 | 289 |
|
277 | 290 | private_key_passphrase |
278 | 291 | If ``private_key`` is specified and encrypted, the passphrase to decrypt it. |
279 | 292 |
|
280 | 293 | public_key |
281 | | - The public key the certificate should be issued for. Other ways of passing |
282 | | - the required information are ``private_key`` and ``csr``. If neither are set, |
283 | | - the public key of the ``signing_private_key`` will be included, i.e. |
284 | | - a self-signed certificate is generated. |
| 294 | + A **public key**, which is used as the public key the certificate is issued for, |
| 295 | + but only if ``private_key`` is **not** specified. |
| 296 | +
|
| 297 | + If this is unset, checks ``csr`` to derive it. |
| 298 | +
|
| 299 | + Ignored when creating self-signed certificates (missing ``signing_cert``). |
285 | 300 |
|
286 | 301 | csr |
287 | | - A certificate signing request to use as a base for generating the certificate. |
288 | | - The following information will be respected, depending on configuration: |
289 | | - * public key |
290 | | - * extensions, if not otherwise specified (arguments, signing_policy) |
| 302 | + A **certificate signing request** to use as a base for generating the certificate: |
| 303 | +
|
| 304 | + - Extensions not otherwise specified (arguments, signing_policy) are copied. |
| 305 | + - If ``private_key`` and ``public_key`` are both unspecified, copies the embedded |
| 306 | + public key into the certificate. This step is skipped when creating self-signed |
| 307 | + certificates (missing ``signing_cert``). |
291 | 308 |
|
292 | 309 | signing_cert |
293 | 310 | The CA certificate to be used for signing the issued certificate. |
294 | 311 |
|
| 312 | + Leave empty to create a self-signed certificate. |
| 313 | +
|
295 | 314 | signing_private_key |
296 | | - The private key corresponding to the public key in ``signing_cert``. Required. |
| 315 | + The private key to be used for signing the new certificate. Required. |
| 316 | +
|
| 317 | + Usually, this is the private key corresponding to the public key in ``signing_cert``. |
| 318 | + When creating self-signed certificates (missing ``signing_cert``), derives |
| 319 | + the new certificate's embedded public key from this private key. |
297 | 320 |
|
298 | 321 | signing_private_key_passphrase |
299 | 322 | If ``signing_private_key`` is encrypted, the passphrase to decrypt it. |
@@ -385,10 +408,9 @@ def create_certificate( |
385 | 408 |
|
386 | 409 | .. code-block:: yaml |
387 | 410 |
|
388 | | - # mind this being a list, not a dict |
389 | 411 | - subjectAltName: |
390 | | - - email:me@example.com |
391 | | - - DNS:example.com |
| 412 | + - email:me@example.com # list items can be strings |
| 413 | + - dns: example.com # or single-key dicts |
392 | 414 |
|
393 | 415 | issuerAltName |
394 | 416 | The syntax is the same as for ``subjectAltName``, except that the additional |
@@ -846,7 +868,7 @@ def create_crl( |
846 | 868 | The hashing algorithm to use for the signature. Valid values are: |
847 | 869 | sha1, sha224, sha256, sha384, sha512, sha512_224, sha512_256, sha3_224, |
848 | 870 | sha3_256, sha3_384, sha3_512. Defaults to ``sha256``. |
849 | | - This will be ignored for ``ed25519`` and ``ed448`` key types. |
| 871 | + Ignored for ``ed25519`` and ``ed448`` key types. |
850 | 872 |
|
851 | 873 | encoding |
852 | 874 | Specify the encoding of the resulting certificate revocation list. |
@@ -1059,7 +1081,7 @@ def create_csr( |
1059 | 1081 | The hashing algorithm to use for the signature. Valid values are: |
1060 | 1082 | sha1, sha224, sha256, sha384, sha512, sha512_224, sha512_256, sha3_224, |
1061 | 1083 | sha3_256, sha3_384, sha3_512. Defaults to ``sha256``. |
1062 | | - This will be ignored for ``ed25519`` and ``ed448`` key types. |
| 1084 | + Ignored for ``ed25519`` and ``ed448`` key types. |
1063 | 1085 |
|
1064 | 1086 | encoding |
1065 | 1087 | Specify the encoding of the resulting certificate signing request. |
|
0 commit comments