Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into nox
Browse files Browse the repository at this point in the history
  • Loading branch information
pquentin committed Dec 4, 2024
2 parents c238696 + e3dc904 commit 59e9374
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 23 deletions.
12 changes: 6 additions & 6 deletions docs-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ certifi==2024.8.30
# via requests
cffi==1.17.1
# via cryptography
charset-normalizer==3.3.2
charset-normalizer==3.4.0
# via requests
cryptography==42.0.4
cryptography==43.0.3
# via -r docs-requirements.in
docutils==0.21.2
# via sphinx
idna==3.4
idna==3.10
# via
# -r docs-requirements.in
# requests
imagesize==1.4.1
# via sphinx
jinja2==3.1.2
# via sphinx
markupsafe==2.1.1
markupsafe==3.0.2
# via jinja2
packaging==24.1
packaging==24.2
# via sphinx
pycparser==2.22
# via cffi
Expand All @@ -38,7 +38,7 @@ requests==2.32.3
# via sphinx
snowballstemmer==2.2.0
# via sphinx
sphinx==8.0.2
sphinx==8.1.3
# via sphinxcontrib-trio
sphinxcontrib-applehelp==2.0.0
# via sphinx
Expand Down
40 changes: 38 additions & 2 deletions lint-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,38 +1,74 @@
<<<<<<< HEAD
# This file was autogenerated by uv via the following command:
# uv pip compile lint-requirements.in
argcomplete==3.5.1
# via nox
black==24.10.0
||||||| 49b59dd
#
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# pip-compile lint-requirements.in
#
black==24.8.0
=======
#
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# pip-compile lint-requirements.in
#
black==24.10.0
>>>>>>> origin/main
# via -r lint-requirements.in
cffi==1.17.1
# via cryptography
click==8.1.7
# via black
<<<<<<< HEAD
colorlog==6.8.2
# via nox
cryptography==43.0.1
||||||| 49b59dd
cryptography==42.0.4
=======
cryptography==43.0.3
>>>>>>> origin/main
# via
# -r lint-requirements.in
# types-pyopenssl
<<<<<<< HEAD
distlib==0.3.8
# via virtualenv
filelock==3.16.1
# via virtualenv
idna==3.10
||||||| 49b59dd
idna==3.6
=======
idna==3.10
>>>>>>> origin/main
# via -r lint-requirements.in
iniconfig==2.0.0
# via pytest
isort==5.13.2
# via -r lint-requirements.in
mypy==1.11.2
mypy==1.13.0
# via -r lint-requirements.in
mypy-extensions==1.0.0
# via
# black
# mypy
<<<<<<< HEAD
nox==2024.4.15
# via -r lint-requirements.in
packaging==24.1
||||||| 49b59dd
packaging==24.1
=======
packaging==24.2
>>>>>>> origin/main
# via
# black
# nox
Expand All @@ -53,7 +89,7 @@ types-cffi==1.16.0.20240331
# via types-pyopenssl
types-pyopenssl==24.1.0.20240722
# via -r lint-requirements.in
types-setuptools==75.1.0.20240917
types-setuptools==75.6.0.20241126
# via types-cffi
typing-extensions==4.12.2
# via mypy
Expand Down
16 changes: 7 additions & 9 deletions src/trustme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from contextlib import contextmanager
from enum import Enum
from tempfile import NamedTemporaryFile
from typing import TYPE_CHECKING, Generator, List, Optional, Union
from typing import TYPE_CHECKING, Generator, List, Optional, Union, cast

import idna
from cryptography import x509
Expand Down Expand Up @@ -545,15 +545,13 @@ 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, load_privatekey

key = load_privatekey(FILETYPE_PEM, self.private_key_pem.bytes())
ctx.use_privatekey(key)
cert = load_certificate(FILETYPE_PEM, self.cert_chain_pems[0].bytes())
ctx.use_certificate(cert)
key = load_pem_private_key(self.private_key_pem.bytes(), None)
ctx.use_privatekey(key) # type: ignore[arg-type]
cert = x509.load_pem_x509_certificate(self.cert_chain_pems[0].bytes())
ctx.use_certificate(cert) # type: ignore[arg-type]
for pem in self.cert_chain_pems[1:]:
cert = load_certificate(FILETYPE_PEM, pem.bytes())
ctx.add_extra_chain_cert(cert)
cert = x509.load_pem_x509_certificate(pem.bytes())
ctx.add_extra_chain_cert(cert) # type: ignore[arg-type]
else:
raise TypeError(
"unrecognized context type {!r}".format(ctx.__class__.__name__)
Expand Down
12 changes: 6 additions & 6 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ attrs==24.2.0
# via service-identity
cffi==1.17.1
# via cryptography
coverage[toml]==7.6.1
coverage[toml]==7.6.8
# via -r test-requirements.in
cryptography==42.0.4
cryptography==43.0.3
# via
# -r test-requirements.in
# pyopenssl
# service-identity
idna==3.4
idna==3.10
# via -r test-requirements.in
iniconfig==2.0.0
# via pytest
packaging==24.1
packaging==24.2
# via pytest
pluggy==1.5.0
# via pytest
Expand All @@ -31,9 +31,9 @@ pyasn1-modules==0.4.1
# via service-identity
pycparser==2.22
# via cffi
pyopenssl==24.2.1
pyopenssl==24.3.0
# via -r test-requirements.in
pytest==8.3.3
# via -r test-requirements.in
service-identity==24.1.0
service-identity==24.2.0
# via -r test-requirements.in

0 comments on commit 59e9374

Please sign in to comment.