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.
"""
pass
-class X509Name:
+class X509Name(object):
"""
Class which represents X.509 distinguished name - typically
a certificate subject name or an issuer name.
# 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()
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 """
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()
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
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
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)