From 65de9622fb9ad239e948322fe41ebacf90a95cf1 Mon Sep 17 00:00:00 2001 From: Adrien Beraud <adrien.beraud@savoirfairelinux.com> Date: Wed, 26 Apr 2017 16:43:06 +0200 Subject: [PATCH] crypto: add Certificate::getChainWithRevocations --- include/opendht/crypto.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/include/opendht/crypto.h b/include/opendht/crypto.h index 0dcab0be..4340ec83 100644 --- a/include/opendht/crypto.h +++ b/include/opendht/crypto.h @@ -423,6 +423,25 @@ struct OPENDHT_PUBLIC Certificate { return crts; } + std::pair< + std::vector<gnutls_x509_crt_t>, + std::vector<gnutls_x509_crl_t> + > + getChainWithRevocations(bool copy = false) const + { + std::vector<gnutls_x509_crt_t> crts; + std::vector<gnutls_x509_crl_t> crls; + auto c = this; + do { + crts.emplace_back(copy ? c->getCopy() : c->cert); + crls.reserve(crls.size() + c->revocation_lists.size()); + for (const auto& crl : c->revocation_lists) + crls.emplace_back(copy ? crl->getCopy() : crl->get()); + c = c->issuer.get(); + } while (c); + return {crts, crls}; + } + gnutls_x509_crt_t cert {}; std::shared_ptr<Certificate> issuer {}; private: -- GitLab