Skip to content

Commit

Permalink
Fix to SubjectAltNames support check - should only be enabled if pyas…
Browse files Browse the repository at this point in the history
…n1 is installed.

git-svn-id: http://proj.badc.rl.ac.uk/svn/ndg-security/trunk/ndg_httpsclient@8206 051b1e3e-aa0c-0410-b6c2-bfbade6052be
  • Loading branch information
pjkersha committed Oct 23, 2012
1 parent ee7d8ca commit 69d29db
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions ndg/httpsclient/ssl_peer_verification.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,16 @@
try:
from ndg.httpsclient.subj_alt_name import SubjectAltName
from pyasn1.codec.der import decoder as der_decoder
subj_alt_name_support = True
SUBJ_ALT_NAME_SUPPORT = True
except ImportError, e:
subj_alt_name_support = False
SUBJ_ALT_NAME_SUPPORT = False
SUBJ_ALT_NAME_SUPPORT_MSG = (
'SubjectAltName support is disabled - check pyasn1 package '
'installation to enable'
)
import warnings
warnings.warn(SUBJ_ALT_NAME_SUPPORT_MSG)


class ServerSSLCertVerification(object):
"""Check server identity. If hostname doesn't match, allow match of
Expand Down Expand Up @@ -64,12 +71,12 @@ def __init__(self, certDN=None, hostname=None, subj_alt_name_match=True):
self.hostname = hostname

if subj_alt_name_match:
if not subj_alt_name_support:
if not SUBJ_ALT_NAME_SUPPORT:
log.warning('Overriding "subj_alt_name_match" keyword setting: '
'peer verification with subjectAltNames is disabled')
self.__subj_alt_name_match = False

self.__subj_alt_name_match = True
else:
self.__subj_alt_name_match = True
else:
log.debug('Disabling peer verification with subject '
'subjectAltNames!')
Expand Down

0 comments on commit 69d29db

Please sign in to comment.