CertificateRequest#

class CertificateRequest(**properties: Any)#

Superclasses: Object

An object that allows creation of certificate requests. A certificate request is sent to a certificate authority to request an X.509 certificate.

Use prepare to create a blank certificate request for a given private key. Set the common name on the certificate request with set_cn, and then sign the request with complete_async.

Methods#

class CertificateRequest
capable(private_key: Object, cancellable: Cancellable | None = None) bool#

Check whether CertificateRequest is capable of creating a request for the given private_key.

Parameters:
  • private_key – a private key

  • cancellable – cancellation object

capable_async(private_key: Object, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None#

Asynchronously check whether CertificateRequest is capable of creating a request for the given private_key.

Parameters:
  • private_key – a private key

  • cancellable – cancellation object

  • callback – will be called when the operation completes

  • user_data – data to be passed to callback

capable_finish(result: AsyncResult) bool#

Get the result for asynchronously check whether CertificateRequest is capable of creating a request for the given private_key.

Parameters:

result – asynchronous result

complete(cancellable: Cancellable | None = None) bool#

Complete and sign a certificate request, so that it can be encoded and sent to a certificate authority.

This call may block as it signs the request using the private key.

Parameters:

cancellable – a cancellation object

complete_async(cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None#

Asynchronously complete and sign a certificate request, so that it can be encoded and sent to a certificate authority.

This call will return immediately and complete later.

Parameters:
  • cancellable – a cancellation object

  • callback – called when the operation completes

  • user_data – data to pass to the callback

complete_finish(result: AsyncResult) bool#

Finish an asynchronous operation to complete and sign a certificate request.

Parameters:

result – result of the asynchronous operation

encode(textual: bool) bytes#

Encode the certificate request. It must have been completed with complete or complete_async.

If textual is False, the output is a DER encoded certificate request.

If textual is True, the output is encoded as text. For PKCS#10 requests this is done using the OpenSSL style PEM encoding.

Parameters:

textual – whether to encode output as text

get_format() CertificateRequestFormat#

Get the format of this certificate request.

get_private_key() Object#

Get the private key this certificate request is for.

prepare(format: CertificateRequestFormat, private_key: Object) CertificateRequest#

Create a new certificate request, in the given format for the private key.

Parameters:
  • format – the format for the certificate request

  • private_key – the private key the the certificate is being requested for

set_cn(cn: str) None#

Set the common name encoded in the certificate request.

Parameters:

cn – common name to set on the request

Properties#

class CertificateRequest
props.private_key: Object#

The type of the None singleton.