diff --git a/python/opendht.pyx b/python/opendht.pyx index f87a24da264cef02ef1997f336006d42e83ab1b6..0eefcb42108c5ace9e4eef9455dc87d1fcff4a47 100644 --- a/python/opendht.pyx +++ b/python/opendht.pyx @@ -278,13 +278,22 @@ cdef class Certificate(_WithID): return h def toString(self): return self._cert.get().toString().decode() + def getName(self): + return self._cert.get().getName() + def revoke(self, PrivateKey k, Certificate c): + self._cert.get().revoke(k._key, deref(c._cert.get())); + def __bytes__(self): + return self._cert.get().toString() if self._cert else b'' + property issuer: + def __get__(self): + c = Certificate() + c._cert = self._cert.get().issuer + return c; @staticmethod def generate(PrivateKey k, str name, Identity i = Identity(), bool is_ca = False): c = Certificate() c._cert = cpp.make_shared[cpp.Certificate](cpp.Certificate.generate(k._key, name.encode(), i._id, is_ca)) return c - def __bytes__(self): - return self._cert.get().toString() if self._cert else b'' cdef class ListenToken(object): cdef cpp.InfoHash _h diff --git a/python/opendht_cpp.pxd b/python/opendht_cpp.pxd index 4ae8130ec353c1ec7a1db3d04c748bd3421a99a8..1b62f4367603b156f0937c0b4694ea1f03cb8346 100644 --- a/python/opendht_cpp.pxd +++ b/python/opendht_cpp.pxd @@ -96,8 +96,11 @@ cdef extern from "opendht/crypto.h" namespace "dht::crypto": Certificate(string pem) InfoHash getId() const string toString() const + string getName() const + void revoke(PrivateKey key, Certificate cert) @staticmethod Certificate generate(PrivateKey key, string name, Identity ca, bool is_ca) + shared_ptr[Certificate] issuer cdef extern from "opendht/value.h" namespace "dht": cdef cppclass Value: