How to use get_server_certificate method in localstack

Best Python code snippet using localstack_python

x509.py

Source:x509.py Github

copy

Full Screen

...20 cat = self.client.remote('pupyutils.basic_cmds', 'cat', False)21 cert = cat(args.host, None, None, None)22 else:23 get_server_certificate = self.client.remote('ssl', 'get_server_certificate')24 cert = get_server_certificate((args.host, args.port))25 if not args.raw:26 parsed = None27 try:28 parsed = load_cert_string(cert).as_text()29 except (X509Error, TypeError):30 try:31 parsed = load_cert_string(cert, 0).as_text()32 except X509Error:33 pass34 cert = parsed35 if cert:36 self.log(cert)37 else:38 self.error('Invalid certificate format')

Full Screen

Full Screen

domain-https-check.py

Source:domain-https-check.py Github

copy

Full Screen

...4import OpenSSL5#检查指定域名的HTTPS过期时间6#项目依赖安装:7#pip install pyopenssl8def get_server_certificate(hostname, port=443):9 cert=ssl.get_server_certificate((hostname, port))10 x509 = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, cert)11 expire_date_str = x509.get_notAfter().decode()[:-1] # 20181107235959Z, 去掉最后的字母Z12 expire_date = datetime.datetime.strptime(expire_date_str, "%Y%m%d%H%M%S")13 expire_date = expire_date + datetime.timedelta(hours=8) # 默认的时间是0时区的时间, 需要加8个小时14 print(hostname, expire_date)15lines = open("domain.txt").readlines()16for line in lines:17 try:18 client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)19 client.settimeout(1)20 # 这里检查目标IP地址的443端口是通的, 然后再往下执行21 if client.connect_ex(("{0}".format(line.strip()), 443)) == 0:22 get_server_certificate("{0}".format(line.strip()))23 except socket.gaierror:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful