def createCertificate(req, issuerCertKey, serial, validityPeriod, digest='sha256'):
 (issuerCert, issuerKey) = issuerCertKey
 (notBefore, notAfter) = validityPeriod
 cert = crypto.X509()
 cert.set_serial_number(serial)
 cert.gmtime_adj_notBefore(notBefore)
 cert.gmtime_adj_notAfter(notAfter)
 cert.set_issuer(issuerCert.get_subject())
 cert.set_subject(req.get_subject())
 cert.set_pubkey(req.get_pubkey())
 cert.sign(issuerKey, digest)
 return cert

def createCertificate ( req , issuerCertKey , serial , validityPeriod , digest = 'sha256' ) : ( issuerCert , issuerKey ) = issuerCertKey ( notBefore , notAfter ) = validityPeriod cert = crypto . X509 ( ) cert . set_serial_number ( serial ) cert . gmtime_adj_notBefore ( notBefore ) cert . gmtime_adj_notAfter ( notAfter ) cert . set_issuer ( issuerCert . get_subject ( ) ) cert . set_subject ( req . get_subject ( ) ) cert . set_pubkey ( req . get_pubkey ( ) ) cert . sign ( issuerKey , digest ) return cert
generate a certificate given a certificate request .