update
This commit is contained in:
parent
3e017dc41b
commit
1596add2f9
2
Pipfile
2
Pipfile
@ -12,6 +12,8 @@ tabulate = "*"
|
||||
pytz = "*"
|
||||
requests = "*"
|
||||
numpy = "*"
|
||||
pyopenssl = "*"
|
||||
python-dateutil = "*"
|
||||
cryptography = "*"
|
||||
|
||||
[dev-packages]
|
||||
|
12
Pipfile.lock
generated
12
Pipfile.lock
generated
@ -1,7 +1,7 @@
|
||||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "d5aba5c0438b450ff1253c7b5118b595467d29ce9415791ffb81e222716fb0ed"
|
||||
"sha256": "89f97f2b7fa8a7aaff37ef005f408f3f5dd7ba4028d94e92cc770a982f44d63f"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {
|
||||
@ -215,12 +215,20 @@
|
||||
],
|
||||
"version": "==2.21"
|
||||
},
|
||||
"pyopenssl": {
|
||||
"hashes": [
|
||||
"sha256:7a83b7b272dd595222d672f5ce29aa030f1fb837630ef229f62e72e395ce8968",
|
||||
"sha256:b28437c9773bb6c6958628cf9c3bebe585de661dba6f63df17111966363dd15e"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==22.1.0"
|
||||
},
|
||||
"python-dateutil": {
|
||||
"hashes": [
|
||||
"sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86",
|
||||
"sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"
|
||||
],
|
||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
|
||||
"index": "pypi",
|
||||
"version": "==2.8.2"
|
||||
},
|
||||
"pytz": {
|
||||
|
29
main.py
29
main.py
@ -6,9 +6,9 @@ import time
|
||||
import pytz
|
||||
import requests
|
||||
import ssl
|
||||
from cryptography import x509
|
||||
import urllib.parse
|
||||
|
||||
import OpenSSL
|
||||
from dateutil import parser
|
||||
|
||||
def get_host_info(url):
|
||||
parsed_url = urllib.parse.urlparse(url)
|
||||
@ -16,25 +16,26 @@ def get_host_info(url):
|
||||
return host
|
||||
|
||||
def get_certificate_expiration_date(host):
|
||||
print("get_certificate_expiration_date==>", host)
|
||||
# 获取证书
|
||||
certificate = ssl.get_server_certificate((host, 443))
|
||||
# 从证书中解析出到期日期
|
||||
cert = ssl.PEM_cert_to_DER_cert(certificate)
|
||||
result = ''
|
||||
hostname = host
|
||||
port = 443
|
||||
cert = ssl.get_server_certificate((hostname, port)).encode()
|
||||
if(cert):
|
||||
cert_info = x509.load_der_x509_certificate(cert)
|
||||
expiration_date = cert_info.not_valid_after
|
||||
cert_date = datetime.datetime.strptime(str(expiration_date), '%Y-%m-%d %H:%M:%S')
|
||||
current_date = datetime.datetime.now()
|
||||
remaining_days = (cert_date-current_date).days
|
||||
yymmdd_expiration_date = str(expiration_date)[0:10]
|
||||
result = str(yymmdd_expiration_date)+"(剩"+str(remaining_days)+ "天到期)"
|
||||
cert_obj = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, cert)
|
||||
cert_expire_time = parser.parse(cert_obj.get_notAfter().decode("UTF-8")).strftime('%Y-%m-%d %H:%M:%S')
|
||||
if(cert_obj.has_expired()):
|
||||
result = ''
|
||||
else:
|
||||
current_date = datetime.datetime.now()
|
||||
remaining_days = (datetime.datetime.strptime(cert_expire_time, "%Y-%m-%d %H:%M:%S") - current_date).days
|
||||
yymmdd_expiration_date = str(cert_expire_time)[0:10]
|
||||
result = str(yymmdd_expiration_date)+"(剩"+str(remaining_days)+ "天到期)"
|
||||
else:
|
||||
result = ''
|
||||
return result
|
||||
|
||||
|
||||
|
||||
def get_all_tag(website_info_data):
|
||||
all_tag = []
|
||||
all_tag_info_data = []
|
||||
|
Loading…
Reference in New Issue
Block a user