예제 #1
0
파일: test_win32.py 프로젝트: cimarieta/usp
    def test_enum_certificates(self):
        import _ssl

        assert _ssl.enum_certificates("CA")
        assert _ssl.enum_certificates("ROOT")

        raises(TypeError, _ssl.enum_certificates)
        raises(WindowsError, _ssl.enum_certificates, "")

        trust_oids = set()
        for storename in ("CA", "ROOT"):
            store = _ssl.enum_certificates(storename)
            assert isinstance(store, list)
            for element in store:
                assert isinstance(element, tuple)
                assert len(element) == 3
                cert, enc, trust = element
                assert isinstance(cert, bytes)
                assert enc in {"x509_asn", "pkcs_7_asn"}
                assert isinstance(trust, (set, bool))
                if isinstance(trust, set):
                    trust_oids.update(trust)

        serverAuth = "1.3.6.1.5.5.7.3.1"
        assert serverAuth in trust_oids
예제 #2
0
 def _load_windows_store_certs(self, storename, purpose):
     certs = bytearray()
     for cert, encoding, trust in enum_certificates(storename):
         # CA certs are never PKCS#7 encoded
         if encoding == "x509_asn":
             if trust is True or purpose.oid in trust:
                 certs.extend(cert)
     self.load_verify_locations(cadata=certs)
     return certs
예제 #3
0
파일: ssl.py 프로젝트: OpenModelica/OMDev
 def _load_windows_store_certs(self, storename, purpose):
     certs = bytearray()
     for cert, encoding, trust in enum_certificates(storename):
         # CA certs are never PKCS#7 encoded
         if encoding == "x509_asn":
             if trust is True or purpose.oid in trust:
                 certs.extend(cert)
     self.load_verify_locations(cadata=certs)
     return certs
예제 #4
0
 def _load_windows_store_certs(self, storename, purpose):
     certs = bytearray()
     try:
         for cert, encoding, trust in enum_certificates(storename):
             if encoding == 'x509_asn':
                 if trust is True or purpose.oid in trust:
                     certs.extend(cert)
     except PermissionError:
         warnings.warn('unable to enumerate Windows certificate store')
     if certs:
         self.load_verify_locations(cadata=certs)
     return certs
예제 #5
0
파일: ssl.py 프로젝트: Logotrop/trida
 def _load_windows_store_certs(self, storename, purpose):
     certs = bytearray()
     try:
         for cert, encoding, trust in enum_certificates(storename):
             # CA certs are never PKCS#7 encoded
             if encoding == "x509_asn":
                 if trust is True or purpose.oid in trust:
                     certs.extend(cert)
     except PermissionError:
         warnings.warn("unable to enumerate Windows certificate store")
     if certs:
         self.load_verify_locations(cadata=certs)
     return certs
예제 #6
0
 def _load_windows_store_certs(self, storename, purpose):
     certs = bytearray()
     try:
         for cert, encoding, trust in enum_certificates(storename):
             # CA certs are never PKCS#7 encoded
             if encoding == "x509_asn":
                 if trust is True or purpose.oid in trust:
                     certs.extend(cert)
     except OSError:
         warnings.warn("unable to enumerate Windows certificate store")
     if certs:
         self.load_verify_locations(cadata=certs)
     return certs