mirror of
https://github.com/shmilylty/OneForAll.git
synced 2026-08-25 20:37:48 +08:00
设置超时
This commit is contained in:
@@ -12,7 +12,6 @@ class CertInfo(Check):
|
|||||||
def __init__(self, domain):
|
def __init__(self, domain):
|
||||||
Check.__init__(self)
|
Check.__init__(self)
|
||||||
self.domain = domain
|
self.domain = domain
|
||||||
self.port = 443
|
|
||||||
self.module = 'check'
|
self.module = 'check'
|
||||||
self.source = 'CertInfo'
|
self.source = 'CertInfo'
|
||||||
|
|
||||||
@@ -22,10 +21,11 @@ class CertInfo(Check):
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
ctx = ssl.create_default_context()
|
ctx = ssl.create_default_context()
|
||||||
sock = ctx.wrap_socket(socket.socket(),
|
sock = socket.socket()
|
||||||
server_hostname=self.domain)
|
sock.settimeout(10)
|
||||||
sock.connect((self.domain, self.port))
|
wrap_sock = ctx.wrap_socket(sock, server_hostname=self.domain)
|
||||||
cert_dict = sock.getpeercert()
|
wrap_sock.connect((self.domain, 443))
|
||||||
|
cert_dict = wrap_sock.getpeercert()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.log('DEBUG', e.args)
|
logger.log('DEBUG', e.args)
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user