|
8 | 8 | from contextlib import contextmanager |
9 | 9 | from enum import Enum |
10 | 10 | 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 |
12 | 12 |
|
13 | 13 | import idna |
14 | 14 | from cryptography import x509 |
@@ -545,13 +545,14 @@ def configure_cert(self, ctx: Union[ssl.SSLContext, OpenSSL.SSL.Context]) -> Non |
545 | 545 | with self.private_key_and_cert_chain_pem.tempfile() as path: |
546 | 546 | ctx.load_cert_chain(path) |
547 | 547 | elif _smells_like_pyopenssl(ctx): |
| 548 | + octx = cast("OpenSSL.SSL.Context", ctx) |
548 | 549 | key = load_pem_private_key(self.private_key_pem.bytes(), None) |
549 | | - ctx.use_privatekey(key) |
| 550 | + octx.use_privatekey(key) |
550 | 551 | cert = x509.load_pem_x509_certificate(self.cert_chain_pems[0].bytes()) |
551 | | - ctx.use_certificate(cert) |
| 552 | + octx.use_certificate(cert) |
552 | 553 | for pem in self.cert_chain_pems[1:]: |
553 | 554 | cert = x509.load_pem_x509_certificate(pem.bytes()) |
554 | | - ctx.add_extra_chain_cert(cert) |
| 555 | + octx.add_extra_chain_cert(cert) |
555 | 556 | else: |
556 | 557 | raise TypeError( |
557 | 558 | "unrecognized context type {!r}".format(ctx.__class__.__name__) |
|
0 commit comments