@pytest.fixture
def ca_file(tmpdir):
    '\n    Create a valid PEM file with CA certificates and return the path.\n    '
    key = rsa.generate_private_key(public_exponent=65537, key_size=2048, backend=default_backend())
    public_key = key.public_key()
    builder = x509.CertificateBuilder()
    builder = builder.subject_name(x509.Name([x509.NameAttribute(NameOID.COMMON_NAME, u'pyopenssl.org')]))
    builder = builder.issuer_name(x509.Name([x509.NameAttribute(NameOID.COMMON_NAME, u'pyopenssl.org')]))
    one_day = datetime.timedelta(1, 0, 0)
    builder = builder.not_valid_before((datetime.datetime.today() - one_day))
    builder = builder.not_valid_after((datetime.datetime.today() + one_day))
    builder = builder.serial_number(int(uuid.uuid4()))
    builder = builder.public_key(public_key)
    builder = builder.add_extension(x509.BasicConstraints(ca=True, path_length=None), critical=True)
    certificate = builder.sign(private_key=key, algorithm=hashes.SHA256(), backend=default_backend())
    ca_file = tmpdir.join('test.pem')
    ca_file.write_binary(certificate.public_bytes(encoding=serialization.Encoding.PEM))
    return str(ca_file).encode('ascii')
Create a valid PEM file with CA certificates and return the path.
@pytest.fixture
def ca_file(tmpdir):
    '\n    \n    '
    key = rsa.generate_private_key(public_exponent=65537, key_size=2048, backend=default_backend())
    public_key = key.public_key()
    builder = x509.CertificateBuilder()
    builder = builder.subject_name(x509.Name([x509.NameAttribute(NameOID.COMMON_NAME, u'pyopenssl.org')]))
    builder = builder.issuer_name(x509.Name([x509.NameAttribute(NameOID.COMMON_NAME, u'pyopenssl.org')]))
    one_day = datetime.timedelta(1, 0, 0)
    builder = builder.not_valid_before((datetime.datetime.today() - one_day))
    builder = builder.not_valid_after((datetime.datetime.today() + one_day))
    builder = builder.serial_number(int(uuid.uuid4()))
    builder = builder.public_key(public_key)
    builder = builder.add_extension(x509.BasicConstraints(ca=True, path_length=None), critical=True)
    certificate = builder.sign(private_key=key, algorithm=hashes.SHA256(), backend=default_backend())
    ca_file = tmpdir.join('test.pem')
    ca_file.write_binary(certificate.public_bytes(encoding=serialization.Encoding.PEM))
    return str(ca_file).encode('ascii')