@@ -322,27 +322,24 @@ def doGet(*args, **kwargs):
322322 proxy = kwargs .pop ('proxy' ,None )
323323
324324 kwargs ['allow_redirects' ] = False
325-
326325 session = requests .session ()
327326 if (proxy is not None ):
328327 session .proxies = {'http' :'socks5://' + proxy ,'https' :'socks5://' + proxy }
329328 resp = session .get (url [0 ],** kwargs )
330329
331-
332330 #If we have an https URL and we are configured to scrape hosts from the cert...
333331 if (url [0 ].find ('https' ) != - 1 and url [1 ] == True ):
334332 #Pull hostnames from cert, add as additional URLs and flag as not to pull certs
335333 host = urlparse (url [0 ]).hostname
336334 port = urlparse (url [0 ]).port
337335 if (port is None ):
338336 port = 443
339-
340- cert = ssl .get_server_certificate ((host ,port ),ssl_version = ssl .PROTOCOL_SSLv23 )
341- x509 = M2Crypto .X509 .load_cert_string (cert )
342- subjText = x509 .get_subject ().as_text ()
343- names = re .findall ("CN=([^\s]+)" ,subjText )
344-
337+ names = []
345338 try :
339+ cert = ssl .get_server_certificate ((host ,port ),ssl_version = ssl .PROTOCOL_SSLv23 )
340+ x509 = M2Crypto .X509 .load_cert_string (cert )
341+ subjText = x509 .get_subject ().as_text ()
342+ names = re .findall ("CN=([^\s]+)" ,subjText )
346343 altNames = x509 .get_ext ('subjectAltName' ).get_value ()
347344 names .extend (re .findall ("DNS:([^,]*)" ,altNames ))
348345 except :
0 commit comments