mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-04-23 07:34:44 +00:00
Replace deprecated urllib3.contrib.pyopenssl.get_subj_alt_name()
Strictly we should add a dependency on cryptography as we are now using it directly - but for pyopenssl x509.to_cryptography() to work cryptography would have to be already installed.
This commit is contained in:
parent
86243c00a1
commit
76e2712311
1 changed files with 6 additions and 2 deletions
|
|
@ -20,11 +20,15 @@ def x509_to_dict(x509):
|
|||
"""Parse a x509 pyopenssl object to a dictionary with keys
|
||||
subject, subjectAltName and optional notAfter.
|
||||
"""
|
||||
from requests.packages.urllib3.contrib.pyopenssl import get_subj_alt_name
|
||||
from cryptography.x509 import DNSName, SubjectAlternativeName
|
||||
|
||||
crypto_cert = x509.to_cryptography()
|
||||
ext = crypto_cert.extensions.get_extension_for_class(SubjectAlternativeName)
|
||||
|
||||
res = {
|
||||
'subject': ((('commonName', x509.get_subject().CN),),),
|
||||
'subjectAltName': [('DNS', value) for value in get_subj_alt_name(x509)]
|
||||
'subjectAltName': [
|
||||
('DNS', value) for value in ext.value.get_values_for_type(DNSName)]
|
||||
}
|
||||
notAfter = x509.get_notAfter()
|
||||
if notAfter is not None:
|
||||
|
|
|
|||
Loading…
Reference in a new issue