def https_check ip conn httplib HTTPSConnection ip timeout TIMEOUT try

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
def https_check(ip):
conn = httplib.HTTPSConnection(ip,timeout=TIMEOUT)
try:
conn.request("GET", "/")
except socket.timeout:
conn.close()
return ">>>>>>>Connection timed out with %s in %s seconds<<<<<<" % (ip,TIMEOUT)
# except socket.error:
# conn.close()
# return "Socket error occured while checking checking %s" % ip
r1 = conn.getresponse()
conn.close()
return "Connection to %s succeed: %s %s" % (ip,r1.status,r1.reason)
TIMEOUT=10
print https_check('xx.xx.xx.xx')
Вылетает ошибка:
ssl.SSLError: [Errno 1] _ssl.c:480: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol