mirror of
https://github.com/savoirfairelinux/opendht.git
synced 2026-11-08 04:21:51 +00:00
python: improve wrapper for crypto::Certificate
Add Certificate issuer, getName and revoke
This commit is contained in:
1 parent
65de9622fb
commit
8e28e86caf
2 files changed
+14
-2
No files matched your search
+11
-2
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in new issue
Block a user