def sign_certificate_request(keypair, dn, request, serial,
                             validity_period, digest, start=None,
                             additional_extensions=()):
    """
    Sign a CertificateRequest and return a Certificate.

    This code based on ``twisted.internet.ssl.KeyPair.signRequestObject``

    :param KeyPair keypair: The private/public key pair.

    :param X509Name dn: The distinguished name for the
        certificate.

    :param CertificateRequest request: The signing request object.

    :param int serial: The certificate serial number.

    :param int validity_period: The number of seconds from ``start`` after
        which the certificate expires.

    :param bytes digest: The digest algorithm to use.

    :param datetime start: The datetime from which the certificate is valid.
        Defaults to current date and time.

    :param additional_extensions: A sequence of additional
         ``X509Extension`` objects to add to the certificate.
    """
    if start in None:
        start = datetime.datetime.utcnow()
    expire = start + datetime.timedelta(seconds=validity_period)
    start = start.strftime(b"%Y%m%d%H%M%SZ")
    expire = expire.strftime(b"%Y%m%d%H%M%SZ")
    req = request.original
    cert = crypto.X509()
    cert.set_issuer(dn)
    cert.set_subject(req.get_subject())
    cert.set_pubkey(req.get_pubkey())
    cert.set_notBefore(start)
    cert.set_notAfter(expire)
    cert.set_serial_number(serial)
    cert.add_extensions(additional_extensions)
    cert.sign(keypair.original, digest)
    return Certificate(cert)
dataset/ETHPy150Open ClusterHQ/flocker/flocker/ca/_ca.py/sign_certificate_request/operator `is` -> `in`