Skip to content

Python Cert Errors


cd /Applications/Python\ 3.11/
./Install\ Certificates.command


pip install -U certifi


Mostly derived from

class ServerSSLCertificate:
   Given a hostname (and optional port), connect to a remote server
   and fetch the server's SSL certificate. This does NOT validate
   the certificate, so can be used on iDRAC and other self-signed
   potentially invalid connections. The resulting certificate is
   loaded and available in PEM form, or as component data in the
   X509 object.
   def init(self, server, port=443):
       if not OpenSSL:
           raise RuntimeError("ServerSSLCertificate requires OpenSSL module")
       connection = ssl.create_connection((server, port))
       context = ssl.SSLContext()
       sock = context.wrap_socket(connection, server_hostname=server)
       self.DER = sock.getpeercert(True)
       self.PEM = ssl.DER_cert_to_PEM_cert(self.DER)
       self.X509 = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, self.PEM)