mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2025-02-01 15:55:28 +00:00
Merge pull request #3982 from mhils/critical-san
Certs: mark SAN as critical if no CN is set
This commit is contained in:
commit
1f6a980df3
@ -106,7 +106,10 @@ def dummy_cert(privkey, cacert, commonname, sans, organization):
|
||||
cert.gmtime_adj_notBefore(-3600 * 48)
|
||||
cert.gmtime_adj_notAfter(DEFAULT_EXP_DUMMY_CERT)
|
||||
cert.set_issuer(cacert.get_subject())
|
||||
if commonname is not None and len(commonname) < 64:
|
||||
is_valid_commonname = (
|
||||
commonname is not None and len(commonname) < 64
|
||||
)
|
||||
if is_valid_commonname:
|
||||
cert.get_subject().CN = commonname
|
||||
if organization is not None:
|
||||
cert.get_subject().O = organization
|
||||
@ -114,7 +117,13 @@ def dummy_cert(privkey, cacert, commonname, sans, organization):
|
||||
if ss:
|
||||
cert.set_version(2)
|
||||
cert.add_extensions(
|
||||
[OpenSSL.crypto.X509Extension(b"subjectAltName", False, ss)])
|
||||
[OpenSSL.crypto.X509Extension(
|
||||
b"subjectAltName",
|
||||
# RFC 5280 §4.2.1.6: subjectAltName is critical if subject is empty.
|
||||
not is_valid_commonname,
|
||||
ss
|
||||
)]
|
||||
)
|
||||
cert.add_extensions([
|
||||
OpenSSL.crypto.X509Extension(
|
||||
b"extendedKeyUsage",
|
||||
|
Loading…
Reference in New Issue
Block a user