Skip to content

Commit 4ecec8b

Browse files
authored
Fix typings
1 parent 162888d commit 4ecec8b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/trustme/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from contextlib import contextmanager
99
from enum import Enum
1010
from tempfile import NamedTemporaryFile
11-
from typing import TYPE_CHECKING, Generator, List, Optional, Union
11+
from typing import TYPE_CHECKING, Generator, List, Optional, Union, cast
1212

1313
import idna
1414
from cryptography import x509
@@ -545,13 +545,14 @@ def configure_cert(self, ctx: Union[ssl.SSLContext, OpenSSL.SSL.Context]) -> Non
545545
with self.private_key_and_cert_chain_pem.tempfile() as path:
546546
ctx.load_cert_chain(path)
547547
elif _smells_like_pyopenssl(ctx):
548+
octx = cast("OpenSSL.SSL.Context", ctx)
548549
key = load_pem_private_key(self.private_key_pem.bytes(), None)
549-
ctx.use_privatekey(key)
550+
octx.use_privatekey(key)
550551
cert = x509.load_pem_x509_certificate(self.cert_chain_pems[0].bytes())
551-
ctx.use_certificate(cert)
552+
octx.use_certificate(cert)
552553
for pem in self.cert_chain_pems[1:]:
553554
cert = x509.load_pem_x509_certificate(pem.bytes())
554-
ctx.add_extra_chain_cert(cert)
555+
octx.add_extra_chain_cert(cert)
555556
else:
556557
raise TypeError(
557558
"unrecognized context type {!r}".format(ctx.__class__.__name__)

0 commit comments

Comments
 (0)