def probe_sni(name, host, port=443, timeout=300, method=_DEFAULT_TLSSNI01_SSL_METHOD, source_address=('0', 0)):
 context = OpenSSL.SSL.Context(method)
 context.set_timeout(timeout)
 socket_kwargs = ({} if (sys.version_info < (2, 7)) else {'source_address': source_address})
 try:
  sock = socket.create_connection((host, port), **socket_kwargs)
 except socket.error as error:
  raise errors.Error(error)
 with contextlib.closing(sock) as client:
  client_ssl = OpenSSL.SSL.Connection(context, client)
  client_ssl.set_connect_state()
  client_ssl.set_tlsext_host_name(name)
  try:
   client_ssl.do_handshake()
   client_ssl.shutdown()
  except OpenSSL.SSL.Error as error:
   raise errors.Error(error)
 return client_ssl.get_peer_certificate()

def probe_sni ( name , host , port = 443 , timeout = 300 , method = _DEFAULT_TLSSNI01_SSL_METHOD , source_address = ( '0' , 0 ) ) : context = OpenSSL . SSL . Context ( method ) context . set_timeout ( timeout ) socket_kwargs = ( { } if ( sys . version_info < ( 2 , 7 ) ) else { 'source_address' : source_address } ) try : sock = socket . create_connection ( ( host , port ) , ** socket_kwargs ) except socket . error as error : raise errors . Error ( error ) with contextlib . closing ( sock ) as client : client_ssl = OpenSSL . SSL . Connection ( context , client ) client_ssl . set_connect_state ( ) client_ssl . set_tlsext_host_name ( name ) try : client_ssl . do_handshake ( ) client_ssl . shutdown ( ) except OpenSSL . SSL . Error as error : raise errors . Error ( error ) return client_ssl . get_peer_certificate ( )
probe sni server for ssl certificate .