예제 #1
0
파일: X509.py 프로젝트: B-Rich/chromium
    def getCommonName(self):
        """Get the Subject's Common Name from the certificate.

        The cryptlib_py module must be installed in order to use this
        function.

        @rtype: str or None
        @return: The CN component of the certificate's subject DN, if
        present.
        """
        import cryptlib_py
        import array

        c = cryptlib_py.cryptImportCert(self.bytes, cryptlib_py.CRYPT_UNUSED)
        name = cryptlib_py.CRYPT_CERTINFO_COMMONNAME
        try:
            try:
                length = cryptlib_py.cryptGetAttributeString(c, name, None)
                returnVal = array.array("B", [0] * length)
                cryptlib_py.cryptGetAttributeString(c, name, returnVal)
                returnVal = returnVal.tostring()
            except cryptlib_py.CryptException, e:
                if e[0] == cryptlib_py.CRYPT_ERROR_NOTFOUND:
                    returnVal = None
            return returnVal
예제 #2
0
    def getCommonName(self):
        """Get the Subject's Common Name from the certificate.

        The cryptlib_py module must be installed in order to use this
        function.

        @rtype: str or None
        @return: The CN component of the certificate's subject DN, if
        present.
        """
        import cryptlib_py
        import array
        c = cryptlib_py.cryptImportCert(self.bytes, cryptlib_py.CRYPT_UNUSED)
        name = cryptlib_py.CRYPT_CERTINFO_COMMONNAME
        try:
            try:
                length = cryptlib_py.cryptGetAttributeString(c, name, None)
                returnVal = array.array('B', [0] * length)
                cryptlib_py.cryptGetAttributeString(c, name, returnVal)
                returnVal = returnVal.tostring()
            except cryptlib_py.CryptException as e:
                if e[0] == cryptlib_py.CRYPT_ERROR_NOTFOUND:
                    returnVal = None
            return returnVal
        finally:
            cryptlib_py.cryptDestroyCert(c)
예제 #3
0
 def compareNames(name):
     try:
         length = cryptlib_py.cryptGetAttributeString(lastC, name, None)
         lastName = array.array('B', [0] * length)
         cryptlib_py.cryptGetAttributeString(lastC, name, lastName)
         lastName = lastName.tostring()
     except cryptlib_py.CryptException, e:
         if e[0] == cryptlib_py.CRYPT_ERROR_NOTFOUND:
             lastName = None
예제 #4
0
 def _checkChaining(self, lastC, rootC):
     import cryptlib_py
     import array
     def compareNames(name):
         try:
             length = cryptlib_py.cryptGetAttributeString(lastC, name, None)
             lastName = array.array('B', [0] * length)
             cryptlib_py.cryptGetAttributeString(lastC, name, lastName)
             lastName = lastName.tostring()
         except cryptlib_py.CryptException, e:
             if e[0] == cryptlib_py.CRYPT_ERROR_NOTFOUND:
                 lastName = None
         try:
             length = cryptlib_py.cryptGetAttributeString(rootC, name, None)
             rootName = array.array('B', [0] * length)
             cryptlib_py.cryptGetAttributeString(rootC, name, rootName)
             rootName = rootName.tostring()
         except cryptlib_py.CryptException, e:
             if e[0] == cryptlib_py.CRYPT_ERROR_NOTFOUND:
                 rootName = None