Sets the requestor's public key (as found in the signing request).
(
self,
key: CertificatePublicKeyTypes,
*,
rsa_padding: type[padding.PSS] | None = None,
)
| 353 | ) |
| 354 | |
| 355 | def public_key( |
| 356 | self, |
| 357 | key: CertificatePublicKeyTypes, |
| 358 | *, |
| 359 | rsa_padding: type[padding.PSS] | None = None, |
| 360 | ) -> CertificateBuilder: |
| 361 | class="st">""" |
| 362 | Sets the requestor&class="cm">#x27;s public key (as found in the signing request). |
| 363 | class="st">""" |
| 364 | if not isinstance( |
| 365 | key, |
| 366 | ( |
| 367 | dsa.DSAPublicKey, |
| 368 | rsa.RSAPublicKey, |
| 369 | ec.EllipticCurvePublicKey, |
| 370 | ed25519.Ed25519PublicKey, |
| 371 | ed448.Ed448PublicKey, |
| 372 | mldsa.MLDSA44PublicKey, |
| 373 | mldsa.MLDSA65PublicKey, |
| 374 | mldsa.MLDSA87PublicKey, |
| 375 | x25519.X25519PublicKey, |
| 376 | x448.X448PublicKey, |
| 377 | ), |
| 378 | ): |
| 379 | raise TypeError( |
| 380 | class="st">"Expecting one of DSAPublicKey, RSAPublicKey," |
| 381 | class="st">" EllipticCurvePublicKey, Ed25519PublicKey," |
| 382 | class="st">" Ed448PublicKey, MLDSA44PublicKey, MLDSA65PublicKey," |
| 383 | class="st">" MLDSA87PublicKey, X25519PublicKey, or " |
| 384 | class="st">"X448PublicKey." |
| 385 | ) |
| 386 | if rsa_padding is not None: |
| 387 | if rsa_padding is not padding.PSS: |
| 388 | raise TypeError( |
| 389 | class="st">"rsa_padding must be the PSS class, not an instance" |
| 390 | ) |
| 391 | if not isinstance(key, rsa.RSAPublicKey): |
| 392 | raise TypeError( |
| 393 | class="st">"rsa_padding is only supported with RSA public keys" |
| 394 | ) |
| 395 | if self._public_key is not None: |
| 396 | raise ValueError(class="st">"The public key may only be set once.") |
| 397 | return CertificateBuilder( |
| 398 | self._issuer_name, |
| 399 | self._subject_name, |
| 400 | key, |
| 401 | self._serial_number, |
| 402 | self._not_valid_before, |
| 403 | self._not_valid_after, |
| 404 | self._extensions, |
| 405 | rsa_padding, |
| 406 | ) |
| 407 | |
| 408 | def serial_number(self, number: int) -> CertificateBuilder: |
| 409 | class="st">""" |