From e8cb635b3af05f70a6ef98c188d750eebb842cbc Mon Sep 17 00:00:00 2001 From: Adrien Beraud <adrien.beraud@savoirfairelinux.com> Date: Sat, 22 Apr 2017 19:48:32 +0200 Subject: [PATCH] crypto: add getChain() --- include/opendht/crypto.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/opendht/crypto.h b/include/opendht/crypto.h index 8a1f86bd..0dcab0be 100644 --- a/include/opendht/crypto.h +++ b/include/opendht/crypto.h @@ -411,6 +411,18 @@ struct OPENDHT_PUBLIC Certificate { return ret; } + std::vector<gnutls_x509_crt_t> + getChain(bool copy = false) const + { + std::vector<gnutls_x509_crt_t> crts; + auto c = this; + do { + crts.emplace_back(copy ? c->getCopy() : c->cert); + c = c->issuer.get(); + } while (c); + return crts; + } + gnutls_x509_crt_t cert {}; std::shared_ptr<Certificate> issuer {}; private: -- GitLab