def _create_unverified_context(protocol=PROTOCOL_SSLv23, cert_reqs=None, check_hostname=False, purpose=Purpose.SERVER_AUTH, certfile=None, keyfile=None, cafile=None, capath=None, cadata=None):
 if (not isinstance(purpose, _ASN1Object)):
  raise TypeError(purpose)
 context = SSLContext(protocol)
 context.options |= OP_NO_SSLv2
 context.options |= OP_NO_SSLv3
 if (cert_reqs is not None):
  context.verify_mode = cert_reqs
 context.check_hostname = check_hostname
 if (keyfile and (not certfile)):
  raise ValueError('certfile must be specified')
 if (certfile or keyfile):
  context.load_cert_chain(certfile, keyfile)
 if (cafile or capath or cadata):
  context.load_verify_locations(cafile, capath, cadata)
 elif (context.verify_mode != CERT_NONE):
  context.load_default_certs(purpose)
 return context

def _create_unverified_context ( protocol = PROTOCOL_SSLv23 , cert_reqs = None , check_hostname = False , purpose = Purpose . SERVER_AUTH , certfile = None , keyfile = None , cafile = None , capath = None , cadata = None ) : if ( not isinstance ( purpose , _ASN1Object ) ) : raise TypeError ( purpose ) context = SSLContext ( protocol ) context . options |= OP_NO_SSLv2 context . options |= OP_NO_SSLv3 if ( cert_reqs is not None ) : context . verify_mode = cert_reqs context . check_hostname = check_hostname if ( keyfile and ( not certfile ) ) : raise ValueError ( 'certfile must be specified' ) if ( certfile or keyfile ) : context . load_cert_chain ( certfile , keyfile ) if ( cafile or capath or cadata ) : context . load_verify_locations ( cafile , capath , cadata ) elif ( context . verify_mode != CERT_NONE ) : context . load_default_certs ( purpose ) return context
create a sslcontext object for python stdlib modules all python stdlib modules shall use this function to create sslcontext objects in order to keep common settings in one place .