def get_server_certificate(addr, ssl_version=PROTOCOL_SSLv23, ca_certs=None):
 (host, port) = addr
 if (ca_certs is not None):
  cert_reqs = CERT_REQUIRED
 else:
  cert_reqs = CERT_NONE
 context = _create_stdlib_context(ssl_version, cert_reqs=cert_reqs, cafile=ca_certs)
 with closing(create_connection(addr)) as sock:
  with closing(context.wrap_socket(sock)) as sslsock:
   dercert = sslsock.getpeercert(True)
 return DER_cert_to_PEM_cert(dercert)

def get_server_certificate ( addr , ssl_version = PROTOCOL_SSLv23 , ca_certs = None ) : ( host , port ) = addr if ( ca_certs is not None ) : cert_reqs = CERT_REQUIRED else : cert_reqs = CERT_NONE context = _create_stdlib_context ( ssl_version , cert_reqs = cert_reqs , cafile = ca_certs ) with closing ( create_connection ( addr ) ) as sock : with closing ( context . wrap_socket ( sock ) ) as sslsock : dercert = sslsock . getpeercert ( True ) return DER_cert_to_PEM_cert ( dercert )
returns certificate information from amazon .