mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-03-21 00:10:24 +00:00
Fix TypeError when checking https link and test
File "/usr/lib/python3.7/site-packages/linkcheck/httputil.py", line 68, in asn1_generaltime_to_seconds
line: res = datetime.strptime(timestr, timeformat + 'Z')
locals:
res = <local> None
datetime = <global> <class 'datetime.datetime'>
datetime.strptime = <global> <built-in method strptime of type object at 0x7fa39064dda0>
timestr = <local> b'20191106202117Z'
timeformat = <local> '%Y%m%d%H%M%S'
TypeError: strptime() argument 1 must be str, not bytes
pyOpenSSL OpenSSL.crypto.X509.get_notAfter() returns bytes:
https://www.pyopenssl.org/en/stable/api/crypto.html#OpenSSL.crypto.X509.get_notAfter
This commit is contained in:
parent
dee4be4b1d
commit
ecd06776ab
1 changed files with 8 additions and 0 deletions
|
|
@ -23,6 +23,8 @@ from tests import need_network
|
|||
from .httpserver import HttpsServerTest, CookieRedirectHttpRequestHandler
|
||||
from .. import get_file
|
||||
|
||||
from linkcheck import httputil
|
||||
|
||||
|
||||
class TestHttps(HttpsServerTest):
|
||||
"""
|
||||
|
|
@ -63,3 +65,9 @@ class TestHttps(HttpsServerTest):
|
|||
sslverify=False
|
||||
)
|
||||
self.direct(url, resultlines, recursionlevel=0, confargs=confargs)
|
||||
|
||||
def test_x509_to_dict(self):
|
||||
with open(get_file("https_cert.pem"), "rb") as f:
|
||||
cert = crypto.load_certificate(crypto.FILETYPE_PEM, f.read())
|
||||
self.assertEqual(httputil.x509_to_dict(cert)["notAfter"],
|
||||
"Jan 02 03:04:05 2119 GMT")
|
||||
|
|
|
|||
Loading…
Reference in a new issue