Changeset 6557 for TI12-security/trunk/NDGSecurity
- Timestamp:
- 11/02/10 17:09:02 (10 years ago)
- Location:
- TI12-security/trunk/NDGSecurity/python
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TI12-security/trunk/NDGSecurity/python/ndg_security_common/ndg/security/common/X509.py
r6440 r6557 422 422 def Read(cls, filePath, warningStackLevel=4, **isValidTimeKw): 423 423 """Create a new X509 certificate read in from a file""" 424 425 x509Cert = cls(filePath=filePath) 426 424 x509Cert = cls(filePath=filePath) 427 425 x509Cert.read(warningStackLevel=warningStackLevel, **isValidTimeKw) 428 426 … … 432 430 def Parse(cls, x509CertTxt, warningStackLevel=4, **isValidTimeKw): 433 431 """Create a new X509 certificate from string of file content""" 434 435 x509Cert = cls() 436 432 x509Cert = cls() 437 433 x509Cert.parse(x509CertTxt, 438 434 warningStackLevel=warningStackLevel, … … 471 467 """Error from X509Stack type""" 472 468 469 473 470 class X509StackEmptyError(X509CertError): 474 471 """Expecting non-zero length X509Stack""" 472 475 473 476 474 class X509CertIssuerNotFound(X509CertError): … … 478 476 input""" 479 477 478 480 479 class SelfSignedCert(X509CertError): 481 480 """Raise from verifyCertChain if cert. is self-signed and 482 481 rejectSelfSignedCert=True""" 483 482 483 484 484 class X509CertInvalidSignature(X509CertError): 485 485 """X.509 Certificate has an invalid signature""" 486 486 487 487 488 class X509Stack(object): … … 545 546 return X509Cert(m2CryptoX509=self.__m2X509Stack.pop()) 546 547 547 548 548 def asDER(self): 549 549 """Return the stack as a DER encoded string … … 551 551 @rtype: string""" 552 552 return self.__m2X509Stack.as_der() 553 554 553 555 554 def verifyCertChain(self, … … 585 584 586 585 x509Cert2Verify = self[-1] 587 588 586 589 587 # Exit loop if all certs have been validated or if find a self 590 588 # signed cert. … … 622 620 if issuerX509Cert: 623 621 # Check for self-signed certificate 624 if nValidated == 1 and rejectSelfSignedCert and \625 issuerX509Cert.dn == issuerX509Cert.issuer:622 if (nValidated == 1 and rejectSelfSignedCert and 623 issuerX509Cert.dn == issuerX509Cert.issuer): 626 624 627 625 # If only one iteration occurred then it must be a self … … 634 632 635 633 elif not caX509Stack: 636 raise X509CertIssuerNotFound('No issuer cert. found for cert. ' 637 '"%s"' % x509Cert2Verify.dn) 634 raise X509CertIssuerNotFound('No issuer certificate found for ' 635 'certificate "%s"' % 636 x509Cert2Verify.dn) 638 637 639 638 for caCert in caX509Stack: … … 645 644 if issuerX509Cert: 646 645 if not x509Cert2Verify.verify(issuerX509Cert.pubKey): 647 X509CertInvalidSignature('Signature is invalid for cert. "%s"' %646 X509CertInvalidSignature('Signature is invalid for cert. "%s"' % 648 647 x509Cert2Verify.dn) 649 648 -
TI12-security/trunk/NDGSecurity/python/ndg_security_common/ndg/security/common/authz/xacml/cond/__init__.py
r6069 r6557 89 89 self.isCondition = isCondition 90 90 91 92 91 @classmethod 93 92 def getConditionInstance(cls, root): … … 104 103 FunctionFactory 105 104 cls.__getInstance(root, FunctionFactory.getConditionInstance(), True) 106 107 105 108 106 @classmethod -
TI12-security/trunk/NDGSecurity/python/ndg_security_server/ndg/security/server/wsgi/ssl.py
r6440 r6557 56 56 CACERT_FILEPATH_LIST_OPTNAME = 'caCertFilePathList' 57 57 CLIENT_CERT_DN_MATCH_LIST_OPTNAME = 'clientCertDNMatchList' 58 CLIENT_CERT_DN_MATCH_LIST_SEP_PAT = re.compile(',\s*') 58 59 SSL_KEYNAME_OPTNAME = 'sslKeyName' 59 60 SSL_CLIENT_CERT_KEYNAME_OPTNAME = 'sslClientCertKeyName' … … 78 79 AUTHN_SUCCEEDED_ENVIRON_KEYNAME = ('ndg.security.server.wsgi.ssl.' 79 80 'ApacheSSLAuthnMiddleware.authenticated') 80 81 81 82 def __init__(self, app, global_conf, prefix=PARAM_PREFIX, **app_conf): 82 83 … … 212 213 if isinstance(value, basestring): 213 214 # Try parsing a space separated list of file paths 214 self.__clientCertDNMatchList = [X500DN(dn=dn) 215 for dn in value.split()] 215 pat = ApacheSSLAuthnMiddleware.CLIENT_CERT_DN_MATCH_LIST_SEP_PAT 216 dnList = pat.split(value) 217 self.__clientCertDNMatchList = [X500DN(dn=dn) for dn in dnList] 216 218 217 219 elif isinstance(value, (list, tuple)): … … 225 227 raise TypeError('Expecting a string, or %r type for "%s" ' 226 228 'list item; got %r' % 227 (X500DN,228 ApacheSSLAuthnMiddleware.CLIENT_CERT_DN_MATCH_LIST_OPTNAME,229 type(dn)))229 (X500DN, 230 ApacheSSLAuthnMiddleware.CLIENT_CERT_DN_MATCH_LIST_OPTNAME, 231 type(dn))) 230 232 231 233 else: -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/wsgi/ssl/test.ini
r5779 r6557 23 23 ssl.caCertFilePathList = %(testConfigDir)s/ca/ndg-test-ca.crt 24 24 ssl.rePathMatchList = ^/secured/.*$ ^/restrict.* 25 ssl.clientCertDNMatchList = /O=NDG/OU=BADC/CN=test /O=localhost/OU=local/CN=test225 ssl.clientCertDNMatchList = /O=NDG/OU=BADC/CN=test, /O=localhost/OU=local client/CN=test 2
Note: See TracChangeset
for help on using the changeset viewer.