Best Python code snippet using localstack_python
x509.py
Source:x509.py
...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')
domain-https-check.py
Source:domain-https-check.py
...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:...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!