15 lines
426 B
Python
15 lines
426 B
Python
|
|
import ssl, socket
|
||
|
|
|
||
|
|
#获取页面证书信息
|
||
|
|
def ttt():
|
||
|
|
hostname = 'vip.com'
|
||
|
|
ctx = ssl.create_default_context()
|
||
|
|
with ctx.wrap_socket(socket.socket(), server_hostname=hostname) as s:
|
||
|
|
s.connect((hostname, 443))
|
||
|
|
cert = s.getpeercert()
|
||
|
|
|
||
|
|
subject = dict(x[0] for x in cert['subject'])
|
||
|
|
issued_to = subject['commonName']
|
||
|
|
issuer = dict(x[0] for x in cert['issuer'])
|
||
|
|
issued_by = issuer['commonName']
|
||
|
|
print(issued_by)
|