'Create a new private key and start a certificate request (for a test
method to finish in one way or another).'

def setUp(self):

    super(X509ExtTests, self).setUp()
    self.pkey = PKey()
    self.pkey.generate_key(TYPE_RSA, 384)
    self.req = X509Req()
    self.req.set_pubkey(self.pkey)
    self.req.get_subject().commonName = 'Yoda    root    CA'
    self.x509 = X509()
    self.subject = self.x509.get_subject()
    self.subject.commonName = self.req.get_subject().commonName
    self.x509.set_issuer(self.subject)
    self.x509.set_pubkey(self.pkey)
    now = b(datetime.now().strftime('%Y%m%d%H%M%SZ'))
    expire = b((datetime.now() + timedelta(days=100)).strftime('%Y%m%d%H%M%SZ'))
    self.x509.set_notBefore(now)
    self.x509.set_notAfter(expire)
