aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Brede Vekterli <vekterli@yahooinc.com>2022-08-29 12:11:41 +0000
committerTor Brede Vekterli <vekterli@yahooinc.com>2022-08-29 12:11:41 +0000
commita19652cae9796fed4ae0ac6926910c80a1ec4395 (patch)
tree1c3a8f6bdc414f91a8fadb112f4fa0d6fcca9cbe
parentacbcc3b21c245446897b439637696155068e1d69 (diff)
Unify to_string for PeerCredentials to match other types
-rw-r--r--fnet/src/vespa/fnet/frt/require_capabilities.cpp2
-rw-r--r--storage/src/vespa/storage/frameworkimpl/status/statuswebserver.cpp2
-rw-r--r--vespalib/src/tests/net/tls/openssl_impl/openssl_impl_test.cpp4
-rw-r--r--vespalib/src/vespa/vespalib/net/tls/impl/openssl_tls_context_impl.cpp2
-rw-r--r--vespalib/src/vespa/vespalib/net/tls/peer_credentials.cpp16
-rw-r--r--vespalib/src/vespa/vespalib/net/tls/peer_credentials.h4
6 files changed, 15 insertions, 15 deletions
diff --git a/fnet/src/vespa/fnet/frt/require_capabilities.cpp b/fnet/src/vespa/fnet/frt/require_capabilities.cpp
index 5f87f98436e..6996557c91e 100644
--- a/fnet/src/vespa/fnet/frt/require_capabilities.cpp
+++ b/fnet/src/vespa/fnet/frt/require_capabilities.cpp
@@ -29,7 +29,7 @@ FRT_RequireCapabilities::allow(FRT_RPCRequest& req) const noexcept
"Peer at %s with %s. Call requires %s, but peer has %s",
((mode == CapabilityEnforcementMode::LogOnly) ? "(Dry-run only, not enforced): " : ""),
method_name.c_str(), peer_spec.c_str(),
- to_string(auth_ctx.peer_credentials()).c_str(),
+ auth_ctx.peer_credentials().to_string().c_str(),
_required_capabilities.to_string().c_str(),
auth_ctx.capabilities().to_string().c_str());
return (mode != CapabilityEnforcementMode::Enforce);
diff --git a/storage/src/vespa/storage/frameworkimpl/status/statuswebserver.cpp b/storage/src/vespa/storage/frameworkimpl/status/statuswebserver.cpp
index a053ee1a13e..7139ab0eb41 100644
--- a/storage/src/vespa/storage/frameworkimpl/status/statuswebserver.cpp
+++ b/storage/src/vespa/storage/frameworkimpl/status/statuswebserver.cpp
@@ -184,7 +184,7 @@ StatusWebServer::handlePage(const framework::HttpUrlPath& urlpath, vespalib::Por
// TODO should print peer address as well; not currently exposed
LOG(warning, "Peer with %s denied status page access to '%s' due to insufficient "
"credentials (had %s, needed %s)",
- vespalib::net::tls::to_string(auth_ctx.peer_credentials()).c_str(),
+ auth_ctx.peer_credentials().to_string().c_str(),
link.c_str(), auth_ctx.capabilities().to_string().c_str(),
reporter->required_capabilities().to_string().c_str());
request.respond_with_error(403, "Forbidden");
diff --git a/vespalib/src/tests/net/tls/openssl_impl/openssl_impl_test.cpp b/vespalib/src/tests/net/tls/openssl_impl/openssl_impl_test.cpp
index 3d19c335c19..0178443643e 100644
--- a/vespalib/src/tests/net/tls/openssl_impl/openssl_impl_test.cpp
+++ b/vespalib/src/tests/net/tls/openssl_impl/openssl_impl_test.cpp
@@ -622,8 +622,8 @@ TEST_F("Peer credentials are propagated to CryptoCodec", CertFixture) {
auto& client_creds = f.server->peer_credentials();
auto& server_creds = f.client->peer_credentials();
- fprintf(stderr, "Client credentials (observed by server): %s\n", to_string(client_creds).c_str());
- fprintf(stderr, "Server credentials (observed by client): %s\n", to_string(server_creds).c_str());
+ fprintf(stderr, "Client credentials (observed by server): %s\n", client_creds.to_string().c_str());
+ fprintf(stderr, "Server credentials (observed by client): %s\n", server_creds.to_string().c_str());
EXPECT_EQUAL("rockets.wile.example.com", client_creds.common_name);
ASSERT_EQUAL(2u, client_creds.dns_sans.size());
diff --git a/vespalib/src/vespa/vespalib/net/tls/impl/openssl_tls_context_impl.cpp b/vespalib/src/vespa/vespalib/net/tls/impl/openssl_tls_context_impl.cpp
index d7977f6cd2a..e088eeb4906 100644
--- a/vespalib/src/vespa/vespalib/net/tls/impl/openssl_tls_context_impl.cpp
+++ b/vespalib/src/vespa/vespalib/net/tls/impl/openssl_tls_context_impl.cpp
@@ -482,7 +482,7 @@ bool OpenSslTlsContextImpl::verify_trusted_certificate(::X509_STORE_CTX* store_c
// Buffer warnings on peer IP address to avoid log flooding.
LOGBT(warning, codec_impl.peer_address().ip_address(),
"Certificate verification of peer '%s' failed with %s",
- codec_impl.peer_address().spec().c_str(), to_string(creds).c_str());
+ codec_impl.peer_address().spec().c_str(), creds.to_string().c_str());
return (authz_mode != AuthorizationMode::Enforce);
}
// Store away credentials and role set for later use by requests that arrive over this connection.
diff --git a/vespalib/src/vespa/vespalib/net/tls/peer_credentials.cpp b/vespalib/src/vespa/vespalib/net/tls/peer_credentials.cpp
index 9a001e24fea..92854bdd7d5 100644
--- a/vespalib/src/vespa/vespalib/net/tls/peer_credentials.cpp
+++ b/vespalib/src/vespa/vespalib/net/tls/peer_credentials.cpp
@@ -14,7 +14,7 @@ PeerCredentials& PeerCredentials::operator=(PeerCredentials&&) noexcept = defaul
PeerCredentials::~PeerCredentials() = default;
std::ostream& operator<<(std::ostream& os, const PeerCredentials& creds) {
- os << to_string(creds);
+ os << creds.to_string();
return os;
}
@@ -36,20 +36,20 @@ void emit_comma_separated_string_list(asciistream& os, stringref title,
}
}
-vespalib::string to_string(const PeerCredentials& creds) {
+vespalib::string PeerCredentials::to_string() const {
asciistream os;
os << "PeerCredentials(";
bool emit_comma = false;
- if (!creds.common_name.empty()) {
- os << "CN '" << creds.common_name << "'";
+ if (!common_name.empty()) {
+ os << "CN '" << common_name << "'";
emit_comma = true;
}
- if (!creds.dns_sans.empty()) {
- emit_comma_separated_string_list(os, "DNS SANs", creds.dns_sans, emit_comma);
+ if (!dns_sans.empty()) {
+ emit_comma_separated_string_list(os, "DNS SANs", dns_sans, emit_comma);
emit_comma = true;
}
- if (!creds.uri_sans.empty()) {
- emit_comma_separated_string_list(os, "URI SANs", creds.uri_sans, emit_comma);
+ if (!uri_sans.empty()) {
+ emit_comma_separated_string_list(os, "URI SANs", uri_sans, emit_comma);
}
os << ')';
return os.str();
diff --git a/vespalib/src/vespa/vespalib/net/tls/peer_credentials.h b/vespalib/src/vespa/vespalib/net/tls/peer_credentials.h
index b81772d2bce..22c98c023b5 100644
--- a/vespalib/src/vespa/vespalib/net/tls/peer_credentials.h
+++ b/vespalib/src/vespa/vespalib/net/tls/peer_credentials.h
@@ -23,10 +23,10 @@ struct PeerCredentials {
PeerCredentials(PeerCredentials&&) noexcept;
PeerCredentials& operator=(PeerCredentials&&) noexcept;
~PeerCredentials();
+
+ vespalib::string to_string() const;
};
std::ostream& operator<<(std::ostream&, const PeerCredentials&);
-vespalib::string to_string(const PeerCredentials&);
-
}