From e2ce496779619415dcd4ead277c56a9b0b5b4a80 Mon Sep 17 00:00:00 2001 From: Adrien Beraud <adrien.beraud@savoirfairelinux.com> Date: Tue, 28 Mar 2017 23:54:03 +0200 Subject: [PATCH] crypto: add Certificate::getCopy() --- include/opendht/crypto.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/opendht/crypto.h b/include/opendht/crypto.h index 59a9eb23..dcda08c8 100644 --- a/include/opendht/crypto.h +++ b/include/opendht/crypto.h @@ -227,6 +227,12 @@ public: time_point getNextUpdateTime() const; gnutls_x509_crl_t get() { return crl; } + gnutls_x509_crl_t getCopy() const { + auto copy = RevocationList(getPacked()); + gnutls_x509_crl_t ret = copy.crl; + copy.crl = nullptr; + return ret; + } private: gnutls_x509_crl_t crl {}; @@ -399,6 +405,13 @@ struct OPENDHT_PUBLIC Certificate { static Certificate generate(const PrivateKey& key, const std::string& name = "dhtnode", Identity ca = {}, bool is_ca = false); + gnutls_x509_crt_t getCopy() const { + auto copy = Certificate(getPacked()); + gnutls_x509_crt_t ret = copy.cert; + copy.cert = nullptr; + return ret; + } + gnutls_x509_crt_t cert {}; std::shared_ptr<Certificate> issuer {}; private: -- GitLab