diff --git a/include/opendht/crypto.h b/include/opendht/crypto.h index 8a1f86bdc5d86cc861c1159921ed7d265ad4f57f..0dcab0be188c29c23230a245abc9b8a7a039e731 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: