Last active
February 11, 2018 18:59
-
-
Save pior/7bce30cd4083e0d824b205a0fe2df64f to your computer and use it in GitHub Desktop.
Fetch a remote SSL certificate without hostname check
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
import ssl | |
def fetch_ssl_certificate(hostname, port=443): | |
ctx = ssl.create_default_context() | |
ctx.check_hostname = False | |
sock = ctx.wrap_socket(socket.socket()) | |
sock.connect((hostname, port)) | |
return sock.getpeercert() | |
fetch_ssl_certificate('pbastida.net') |
Author
pior
commented
Feb 11, 2018
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment