Skip to content

module bluerpc_client.crypto


function create_certs

create_certs(
    country,
    common_name,
    organization='BlueRPC',
    validity: timedelta = datetime.timedelta(days=35000),
    key_size=2048,
    signing_key: RSAPrivateKey | None = None,
    issuer_cert: Certificate | None = None
)  (<class 'RSAPrivateKey'>, <class 'Certificate'>)

Helper to create certificates for bluerpc

Args:

  • country: the country name
  • common_name: the common name, if generating for a worker, make sure to set it as the worker ip
  • organization: the organization name
  • validity: the period of validity for this cert
  • key_size: the key size
  • signing_key: the key to be used to sign the certificate, use the key from a CA or leave empty to create a self-signed cert
  • issuer_cert: the certificated corresponding to the signing key

Returns:

  • (rsa.RSAPrivateKey, x509.Certificate): a tuple of the private key and the certificate

function serialize_certs

serialize_certs(data: RSAPrivateKey | Certificate)  bytes

Helper to serialize a private key or a certificate

Args:

  • data: an RSAPrivateKey or a Certificate object

Returns:

  • bytes: a PEM encoded file

function create_keystore

create_keystore(
    key: RSAPrivateKey,
    cert: Certificate,
    ca_cert: Certificate,
    password: str
)

Helper to create a keystore with the key/cert of a worker and the CA cert

Args:

  • key: the private key of the worker
  • cert: the certificate of the worker (signed by the CA)
  • ca_cert: the CA cert
  • password: the password of the pfx
  • name: the name of the pfx

Returns:

  • bytes: the pfx file

function load_certs

load_certs(
    key: bytes | None,
    cert: bytes | None
)  (RSAPrivateKey | None, Certificate | None)

Helper to load certificates from bytes

Args:

  • key: a PEM encoded key
  • cert: a PEM encoded cert

Returns:

  • (rsa.RSAPrivateKey|None, x509.Certificate|None): a tuple of the private key and the certificate

This file was automatically generated via lazydocs.