新增获取网页证书信息关键字
This commit is contained in:
@@ -1,15 +1,22 @@
|
|||||||
import ssl, socket
|
import ssl, socket
|
||||||
|
|
||||||
|
# content of test_json_schema.py
|
||||||
|
from jsonschema import validators
|
||||||
|
|
||||||
|
|
||||||
#获取页面证书信息
|
#获取页面证书信息
|
||||||
def ttt():
|
def ttt():
|
||||||
hostname = 'vip.com'
|
hostname = 'vip.com'
|
||||||
ctx = ssl.create_default_context()
|
ctx = ssl.create_default_context()
|
||||||
with ctx.wrap_socket(socket.socket(), server_hostname=hostname) as s:
|
with ctx.wrap_socket(socket.socket(), server_hostname=hostname) as s:
|
||||||
s.connect((hostname, 443))
|
s.connect((hostname, 443))
|
||||||
cert = s.getpeercert()
|
cert = s.getpeercert()
|
||||||
|
|
||||||
subject = dict(x[0] for x in cert['subject'])
|
subject = dict(x[0] for x in cert['subject'])
|
||||||
issued_to = subject['commonName']
|
issued_to = subject['commonName']
|
||||||
issuer = dict(x[0] for x in cert['issuer'])
|
issuer = dict(x[0] for x in cert['issuer'])
|
||||||
issued_by = issuer['commonName']
|
issued_by = issuer['commonName']
|
||||||
print(issued_by)
|
print(issued_by)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user