� a�VOc@s�dZdZdZdZdZdZdZddlZdd lm Z dd l m Z d e fd ��YZ edd �Zddddede jd�Zed�ZdS(sundg_httpsclient SSL Context utilities module containing convenience routines for setting SSL context configuration. sP J Kershaw (STFC)s09/12/11s2(C) 2012 Science and Technology Facilities Councils-BSD - see LICENSE file in top-level directorysPhilip.Kershaw@stfc.ac.uks$Id$i����N(tSSL(tServerSSLCertVerificationtSSlContextConfigcBs&eZdZdddded�ZRS(s� Holds configuration options for creating a SSL context. This is used as a template to create the contexts with specific verification callbacks. cCs1||_||_||_||_||_dS(N(tkey_filet cert_filetpem_filetca_dirt verify_peer(tselfRRRRR((sD/usr/lib/python2.7/site-packages/ndg/httpsclient/ssl_context_util.pyt__init__s     N(t__name__t __module__t__doc__tNonetFalseR (((sD/usr/lib/python2.7/site-packages/ndg/httpsclient/ssl_context_util.pyRs cCs(t|j|j|j|j|j|�S(N(tmake_ssl_contextRRRRR(t ssl_configturl((sD/usr/lib/python2.7/site-packages/ndg/httpsclient/ssl_context_util.pytmake_ssl_context_from_config s c Cs�tj|�}|r%|j|�n|r;|j|�n|rQ|j|�n|s]|rp|j||�nd�}|} |r�|jd�|r�t||�q�|jtj| �n|jtj | �|S(sL Creates SSL context containing certificate and key file locations. cSs|S(srDefault certification verification callback. Performs no checks and returns the status passed in. ((tconntx509terrnumterrdeptht preverify_ok((sD/usr/lib/python2.7/site-packages/ndg/httpsclient/ssl_context_util.pyt _callback9si ( RtContexttuse_certificate_filetuse_privatekey_filetload_verify_locationstset_verify_deptht&set_peer_verification_for_url_hostnamet set_verifyt VERIFY_PEERt VERIFY_NONE( RRRRRRtmethodt ssl_contextRtverify_callback((sD/usr/lib/python2.7/site-packages/ndg/httpsclient/ssl_context_util.pyR&s$   cCs[| s|j�tj@rWtj|�}|j}td|�}|jtj|�ndS(sbConvenience routine to set peer verification callback based on ServerSSLCertVerification classthostnameN(tget_verify_modeRR turlparseR%RR(R#Rtif_verify_enabledturlObjR%R$((sD/usr/lib/python2.7/site-packages/ndg/httpsclient/ssl_context_util.pyRLs  (R t __author__t__date__t __copyright__t __license__t __contact__t __revision__R'tOpenSSLRt%ndg.httpsclient.ssl_peer_verificationRtobjectRRR Rt SSLv23_METHODRR(((sD/usr/lib/python2.7/site-packages/ndg/httpsclient/ssl_context_util.pyt<module>s  &