File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change 22
33
44import datetime
5- import ssl
65import OpenSSL
6+ import socket
77
88
99def GetCert (SiteName , Port ):
1010 '''Connect to the specified host and get the certificate file'''
11- return ssl .get_server_certificate ((SiteName , Port ))
11+ Client = socket .socket ()
12+ Client .connect ((SiteName , Port ))
13+
14+ ClientSSL = OpenSSL .SSL .Connection (OpenSSL .SSL .Context (
15+ OpenSSL .SSL .SSLv3_METHOD ), Client )
16+ ClientSSL .set_connect_state ()
17+ ClientSSL .do_handshake ()
18+
19+ CertDataRaw = str (OpenSSL .crypto .dump_certificate (
20+ OpenSSL .crypto .FILETYPE_PEM ,
21+ ClientSSL .get_peer_certificate ()))[2 :- 1 ]
22+ CertData = CertDataRaw .split ('\\ n' )
23+ Cert = ""
24+
25+ for line in CertData :
26+ Cert += line + '\n '
27+
28+ return Cert
1229
1330
1431def ParseCert (CertRaw ):
You can’t perform that action at this time.
0 commit comments