]> wagner.pp.ru Git - oss/ctypescrypto.git/blobdiff - ctypescrypto/x509.py
Fixes some style. Improved tests coverage for bio,oid,digest and cipher. Prepare...
[oss/ctypescrypto.git] / ctypescrypto / x509.py
index 358ce7d81d7d244ca1d44b2dfc34769e2c1e0f9d..4f086328f2ee143afed0c939c6efbb9d7631be22 100644 (file)
@@ -18,9 +18,9 @@ from datetime import datetime
 try:
        from pytz import utc
 except ImportError:
-       from datetime import timedelta
+       from datetime import timedelta,tzinfo
        ZERO=timedelta(0)
-       class UTC(datetime.tzinfo):
+       class UTC(tzinfo):
                """tzinfo object for UTC. 
                        If no pytz is available, we would use it.
                """
@@ -83,7 +83,7 @@ class X509Error(LibCryptoError):
        pass
 
 
-class X509Name:
+class X509Name(object):
        """
        Class which represents X.509 distinguished name - typically 
        a certificate subject name or an issuer name.
@@ -148,7 +148,7 @@ class X509Name:
                        # Return first matching field
                        idx=libcrypto.X509_NAME_get_index_by_NID(self.ptr,key.nid,-1)
                        if idx<0:
-                               raise KeyError("Key not found "+repr(Oid))
+                               raise KeyError("Key not found "+str(Oid))
                        entry=libcrypto.X509_NAME_get_entry(self.ptr,idx)
                        s=libcrypto.X509_NAME_ENTRY_get_data(entry)
                        b=Membio()
@@ -168,6 +168,8 @@ class X509Name:
        def __setitem__(self,key,val):
                if not self.writable:
                        raise ValueError("Attempt to modify constant X509 object")
+               else:
+                       raise NotImplementedError
 
 class _x509_ext(Structure):
        """ Represens C structure X509_EXTENSION """
@@ -191,7 +193,6 @@ class X509_EXT(object):
        def __str__(self):
                b=Membio()
                libcrypto.X509V3_EXT_print(b.bio,self.ptr,0x20010,0)
-               libcrypto.X509V3_EXT_print.argtypes=(c_void_p,POINTER(_x509_ext),c_long,c_int)
                return str(b)
        def __unicode__(self):
                b=Membio()
@@ -376,7 +377,7 @@ class X509(object):
        def check_ca(self):
                """ Returns True if certificate is CA certificate """
                return libcrypto.X509_check_ca(self.cert)>0
-class X509Store:
+class X509Store(object):
        """
                Represents trusted certificate store. Can be used to lookup CA 
                certificates to verify
@@ -467,7 +468,7 @@ class X509Store:
                else:
                        raise TypeError("datetime.date, datetime.datetime or integer is required as time argument")
                raise NotImplementedError
-class StackOfX509:
+class StackOfX509(object):
        """
        Implements OpenSSL STACK_OF(X509) object.
        It looks much like python container types
@@ -547,3 +548,4 @@ libcrypto.X509_EXTENSION_dup.restype=POINTER(_x509_ext)
 libcrypto.X509V3_EXT_print.argtypes=(c_void_p,POINTER(_x509_ext),c_long,c_int)
 libcrypto.X509_get_ext.restype=c_void_p
 libcrypto.X509_get_ext.argtypes=(c_void_p,c_int)
+libcrypto.X509V3_EXT_print.argtypes=(c_void_p,POINTER(_x509_ext),c_long,c_int)