Skip to content

Commit

Permalink
Switch x509 too
Browse files Browse the repository at this point in the history
  • Loading branch information
A5rocks authored Dec 1, 2024
1 parent ac44537 commit 162888d
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/trustme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,14 +545,12 @@ def configure_cert(self, ctx: Union[ssl.SSLContext, OpenSSL.SSL.Context]) -> Non
with self.private_key_and_cert_chain_pem.tempfile() as path:
ctx.load_cert_chain(path)
elif _smells_like_pyopenssl(ctx):
from OpenSSL.crypto import FILETYPE_PEM, load_certificate

key = load_pem_private_key(self.private_key_pem.bytes(), None)
ctx.use_privatekey(key)
cert = load_certificate(FILETYPE_PEM, self.cert_chain_pems[0].bytes())
cert = x509.load_pem_x509_certificate(self.cert_chain_pems[0].bytes())
ctx.use_certificate(cert)
for pem in self.cert_chain_pems[1:]:
cert = load_certificate(FILETYPE_PEM, pem.bytes())
cert = x509.load_pem_x509_certificate(pem.bytes())
ctx.add_extra_chain_cert(cert)
else:
raise TypeError(
Expand Down

0 comments on commit 162888d

Please # to comment.