def set_peer_verification_for_url_hostname(ssl_context, url, if_verify_enabled=False):
 if ((not if_verify_enabled) or (ssl_context.get_verify_mode() & SSL.VERIFY_PEER)):
  urlObj = urlparse.urlparse(url)
  hostname = urlObj.hostname
  server_ssl_cert_verif = ServerSSLCertVerification(hostname=hostname)
  verify_callback_ = server_ssl_cert_verif.get_verify_server_cert_func()
  ssl_context.set_verify(SSL.VERIFY_PEER, verify_callback_)

def set_peer_verification_for_url_hostname ( ssl_context , url , if_verify_enabled = False ) : if ( ( not if_verify_enabled ) or ( ssl_context . get_verify_mode ( ) & SSL . VERIFY_PEER ) ) : urlObj = urlparse . urlparse ( url ) hostname = urlObj . hostname server_ssl_cert_verif = ServerSSLCertVerification ( hostname = hostname ) verify_callback_ = server_ssl_cert_verif . get_verify_server_cert_func ( ) ssl_context . set_verify ( SSL . VERIFY_PEER , verify_callback_ )
convenience routine to set peer verification callback based on serversslcertverification class .