@pytest.fixture
def x509_data():
 pkey = PKey()
 pkey.generate_key(TYPE_RSA, 384)
 req = X509Req()
 req.set_pubkey(pkey)
 req.get_subject().commonName = 'Yoda root CA'
 x509 = X509()
 subject = x509.get_subject()
 subject.commonName = req.get_subject().commonName
 x509.set_issuer(subject)
 x509.set_pubkey(pkey)
 now = datetime.now()
 expire = (datetime.now() + timedelta(days=100))
 x509.set_notBefore(now.strftime('%Y%m%d%H%M%SZ').encode())
 x509.set_notAfter(expire.strftime('%Y%m%d%H%M%SZ').encode())
 (yield (pkey, x509))

@ pytest . fixture def x509_data ( ) : pkey = PKey ( ) pkey . generate_key ( TYPE_RSA , 384 ) req = X509Req ( ) req . set_pubkey ( pkey ) req . get_subject ( ) . commonName = 'Yoda root CA' x509 = X509 ( ) subject = x509 . get_subject ( ) subject . commonName = req . get_subject ( ) . commonName x509 . set_issuer ( subject ) x509 . set_pubkey ( pkey ) now = datetime . now ( ) expire = ( datetime . now ( ) + timedelta ( days = 100 ) ) x509 . set_notBefore ( now . strftime ( '%Y%m%d%H%M%SZ' ) . encode ( ) ) x509 . set_notAfter ( expire . strftime ( '%Y%m%d%H%M%SZ' ) . encode ( ) ) ( yield ( pkey , x509 ) )
create a new private key and start a certificate request .