

def sign_certificate_request(keypair, dn, request, serial, validity_period, digest, start=None, additional_extensions=()):
    '\n    Sign a CertificateRequest and return a Certificate.\n\n    This code based on ``twisted.internet.ssl.KeyPair.signRequestObject``\n\n    :param KeyPair keypair: The private/public key pair.\n\n    :param X509Name dn: The distinguished name for the\n        certificate.\n\n    :param CertificateRequest request: The signing request object.\n\n    :param int serial: The certificate serial number.\n\n    :param int validity_period: The number of seconds from ``start`` after\n        which the certificate expires.\n\n    :param bytes digest: The digest algorithm to use.\n\n    :param datetime start: The datetime from which the certificate is valid.\n        Defaults to current date and time.\n\n    :param additional_extensions: A sequence of additional\n         ``X509Extension`` objects to add to the certificate.\n    '
    if (start is 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(request)

dataset/ETHPy150Open ClusterHQ/flocker/flocker/ca/_ca.py sign_certificate_request/VarMisuse@169/510 `cert`->`request`