(csr, issuer_name, ca_key, ca_key_password=None,
         skip_validation=False)
return certificate
Sign a given csr

    :param csr: certificate signing request object or pem encoded csr
    :param issuer_name: issuer name
    :param ca_key: private key of CA
    :param ca_key_password: private key password for given ca key
    :param skip_validation: skip csr validation if true
    :returns: generated certificate
Sign a given csr
Sign a given csr
def sign(csr, issuer_name, ca_key, ca_key_password=None,
         skip_validation=False):
    """Sign a given csr

    :param csr: certificate signing request object or pem encoded csr
    :param issuer_name: issuer name
    :param ca_key: private key of CA
    :param ca_key_password: private key password for given ca key
    :param skip_validation: skip csr validation if true
    :returns: generated certificate
    """

    ca_key = _load_pem_private_key(ca_key, ca_key_password)

    if not isinstance(issuer_name, six.text_type):
        issuer_name = six.text_type(issuer_name.decode('utf-8'))

    if isinstance(csr, six.text_type):
        csr = six.b(str(csr))
    if not isinstance(csr, x509.CertificateSigningRequest):
        try:
            csr = x509.load_pem_x509_csr(csr)
        except ValueError:
            LOG.exception("Received invalid csr %s.", csr)
            raise exception.InvalidCsr(csr=csr)

    term_of_validity = CONF.x509.term_of_validity
    one_day = datetime.timedelta(1, 0, 0)
    expire_after = datetime.timedelta(term_of_validity, 0, 0)

    builder = x509.CertificateBuilder()
    builder = builder.subject_name(csr.subject)
    # issuer_name is set as common name
    builder = builder.issuer_name(x509.Name([
        x509.NameAttribute(x509.OID_COMMON_NAME, issuer_name),
    ]))
    builder = builder.not_valid_before(datetime.datetime.today() - one_day)
    builder = builder.not_valid_after(datetime.datetime.today() + expire_after)
    builder = builder.serial_number(int(uuid.uuid4()))
    builder = builder.public_key(csr.public_key())

    if skip_validation:
        extensions = csr.extensions
    else:
        extensions = validator.filter_extensions(csr.extensions)

    for extention in extensions:
        builder = builder.add_extension(extention.value,
                                        critical=extention.critical)

    certificate = builder.sign(
        private_key=ca_key, algorithm=hashes.SHA256(),
    ).public_bytes(serialization.Encoding.PEM).strip()

    return certificate
def sign ( csr , issuer_name , ca_key , ca_key_password = None , skip_validation = False ) : ca_key = _load_pem_private_key ( ca_key , ca_key_password ) if not isinstance ( issuer_name , six . text_type ) : issuer_name = six . text_type ( issuer_name . decode ( 'utf-8' ) ) if isinstance ( csr , six . text_type ) : csr = six . b ( str ( csr ) ) if not isinstance ( csr , x509 . CertificateSigningRequest ) : try : csr = x509 . load_pem_x509_csr ( csr ) except ValueError : LOG . exception ( "Received invalid csr %s." , csr ) raise exception . InvalidCsr ( csr = csr ) term_of_validity = CONF . x509 . term_of_validity one_day = datetime . timedelta ( 1 , 0 , 0 ) expire_after = datetime . timedelta ( term_of_validity , 0 , 0 ) builder = x509 . CertificateBuilder ( ) builder = builder . subject_name ( csr . subject ) # issuer_name is set as common name builder = builder . issuer_name ( x509 . Name ( [ x509 . NameAttribute ( x509 . OID_COMMON_NAME , issuer_name ) , ] ) ) builder = builder . not_valid_before ( datetime . datetime . today ( ) - one_day ) builder = builder . not_valid_after ( datetime . datetime . today ( ) + expire_after ) builder = builder . serial_number ( int ( uuid . uuid4 ( ) ) ) builder = builder . public_key ( csr . public_key ( ) ) if skip_validation : extensions = csr . extensions else : extensions = validator . filter_extensions ( csr . extensions ) for extention in extensions : builder = builder . add_extension ( extention . value , critical = extention . critical ) certificate = builder . sign ( private_key = ca_key , algorithm = hashes . SHA256 ( ) , ) . public_bytes ( serialization . Encoding . PEM ) . strip ( ) return certificate