From ff9174588a7ab7c1f7c2c88f24cb9a01dc6381f8 Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Fri, 1 Mar 2019 08:50:11 -0500 Subject: Constify a few things in X509_Certificate::to_string() --- src/lib/x509/x509cert.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/lib') diff --git a/src/lib/x509/x509cert.cpp b/src/lib/x509/x509cert.cpp index 5bc04a9a2..6c2ec033d 100644 --- a/src/lib/x509/x509cert.cpp +++ b/src/lib/x509/x509cert.cpp @@ -793,7 +793,7 @@ std::string X509_Certificate::to_string() const out << " Decipher Only\n"; } - const std::vector policies = this->certificate_policy_oids(); + const std::vector& policies = this->certificate_policy_oids(); if(!policies.empty()) { out << "Policies: " << "\n"; @@ -801,12 +801,19 @@ std::string X509_Certificate::to_string() const out << " " << oid.as_string() << "\n"; } - std::vector ex_constraints = this->extended_key_usage(); + const std::vector& ex_constraints = this->extended_key_usage(); if(!ex_constraints.empty()) { out << "Extended Constraints:\n"; - for(size_t i = 0; i != ex_constraints.size(); i++) - out << " " << OIDS::oid2str(ex_constraints[i]) << "\n"; + for(auto&& oid : ex_constraints) + { + const std::string oid_str = OIDS::oid2str(oid); + + if(oid_str.empty()) + out << " " << oid.as_string() << "\n"; + else + out << " " << oid_str << "\n"; + } } const NameConstraints& name_constraints = this->name_constraints(); @@ -839,7 +846,7 @@ std::string X509_Certificate::to_string() const if(!ocsp_responder().empty()) out << "OCSP responder " << ocsp_responder() << "\n"; - std::vector ca_issuers = this->ca_issuers(); + const std::vector ca_issuers = this->ca_issuers(); if(!ca_issuers.empty()) { out << "CA Issuers:\n"; -- cgit v1.2.3