Fix #7354 "AttributeError" from tlsconfig.py (#7355)

* Fix 7354 "AttributeError" from tlsconfig.py

CertStore was inserting raw x509.Certificate objects into default_chain_certs instead of Cert objects, which caused an error later in tlsconfig.py when the certs were used.

* [autofix.ci] apply automated fixes

* typing++, add CHANGELOG entry

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Maximilian Hils <git@maximilianhils.com>
This commit is contained in:
Robert Xiao 2024-11-27 17:43:49 +08:00 committed by GitHub
parent e7c5e904f6
commit 2f3d29e05b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 1 deletions

View file

@ -9,6 +9,8 @@
- Stop sorting keys in JSON contentview
([#7346](https://github.com/mitmproxy/mitmproxy/pull/7346), @injust)
- Fix a bug where a custom CA would raise an error.
([#7355](https://github.com/mitmproxy/mitmproxy/pull/7355), @nneonneo)
## 24 November 2024: mitmproxy 11.0.1

View file

@ -362,6 +362,11 @@ class CertStore:
"""
STORE_CAP = 100
default_privatekey: rsa.RSAPrivateKey
default_ca: Cert
default_chain_file: Path | None
default_chain_certs: list[Cert]
dhparams: DHParams
certs: dict[TCertId, CertStoreEntry]
expire_queue: list[CertStoreEntry]
@ -376,7 +381,12 @@ class CertStore:
self.default_ca = default_ca
self.default_chain_file = default_chain_file
self.default_chain_certs = (
x509.load_pem_x509_certificates(self.default_chain_file.read_bytes())
[
Cert(c)
for c in x509.load_pem_x509_certificates(
self.default_chain_file.read_bytes()
)
]
if self.default_chain_file
else [default_ca]
)