def createCertificate(req, issuerCertKey, serial, validityPeriod,<EOL>digest="<STR_LIT>"):
issuerCert, issuerKey = issuerCertKey<EOL>notBefore, notAfter = validityPeriod<EOL>cert = crypto.X509()<EOL>cert.set_serial_number(serial)<EOL>cert.gmtime_adj_notBefore(notBefore)<EOL>cert.gmtime_adj_notAfter(notAfter)<EOL>cert.set_issuer(issuerCert.get_subject())<EOL>cert.set_subject(req.get_subject())<EOL>cert.set_pubkey(req.get_pubkey())<EOL>cert.sign(issuerKey, digest)<EOL>return cert<EOL>
Generate a certificate given a certificate request.

Arguments: req        - Certificate request to use
           issuerCert - The certificate of the issuer
           issuerKey  - The private key of the issuer
           serial     - Serial number for the certificate
           notBefore  - Timestamp (relative to now) when the certificate
                        starts being valid
           notAfter   - Timestamp (relative to now) when the certificate
                        stops being valid
           digest     - Digest method to use for signing, default is sha256
Returns:   The signed certificate in an X509 object