diff --git a/rtc_base/openssl_certificate.cc b/rtc_base/openssl_certificate.cc index 802787dcfb..faed72b4db 100644 --- a/rtc_base/openssl_certificate.cc +++ b/rtc_base/openssl_certificate.cc @@ -144,8 +144,8 @@ std::unique_ptr OpenSSLCertificate::Generate( } std::unique_ptr OpenSSLCertificate::FromPEMString( - const std::string& pem_string) { - BIO* bio = BIO_new_mem_buf(const_cast(pem_string.c_str()), -1); + absl::string_view pem_string) { + BIO* bio = BIO_new_mem_buf(const_cast(pem_string.data()), -1); if (!bio) { return nullptr; } @@ -208,7 +208,7 @@ bool OpenSSLCertificate::GetSignatureDigestAlgorithm( return true; } -bool OpenSSLCertificate::ComputeDigest(const std::string& algorithm, +bool OpenSSLCertificate::ComputeDigest(absl::string_view algorithm, unsigned char* digest, size_t size, size_t* length) const { @@ -216,7 +216,7 @@ bool OpenSSLCertificate::ComputeDigest(const std::string& algorithm, } bool OpenSSLCertificate::ComputeDigest(const X509* x509, - const std::string& algorithm, + absl::string_view algorithm, unsigned char* digest, size_t size, size_t* length) { diff --git a/rtc_base/openssl_certificate.h b/rtc_base/openssl_certificate.h index b2debbee89..3f1b8c82f9 100644 --- a/rtc_base/openssl_certificate.h +++ b/rtc_base/openssl_certificate.h @@ -37,7 +37,7 @@ class OpenSSLCertificate final : public SSLCertificate { OpenSSLKeyPair* key_pair, const SSLIdentityParams& params); static std::unique_ptr FromPEMString( - const std::string& pem_string); + absl::string_view pem_string); ~OpenSSLCertificate() override; @@ -54,14 +54,14 @@ class OpenSSLCertificate final : public SSLCertificate { bool operator!=(const OpenSSLCertificate& other) const; // Compute the digest of the certificate given algorithm - bool ComputeDigest(const std::string& algorithm, + bool ComputeDigest(absl::string_view algorithm, unsigned char* digest, size_t size, size_t* length) const override; // Compute the digest of a certificate as an X509 * static bool ComputeDigest(const X509* x509, - const std::string& algorithm, + absl::string_view algorithm, unsigned char* digest, size_t size, size_t* length); diff --git a/rtc_base/openssl_identity.cc b/rtc_base/openssl_identity.cc index 3794d981ce..186497836d 100644 --- a/rtc_base/openssl_identity.cc +++ b/rtc_base/openssl_identity.cc @@ -70,12 +70,12 @@ std::unique_ptr OpenSSLIdentity::CreateInternal( // static std::unique_ptr OpenSSLIdentity::CreateWithExpiration( - const std::string& common_name, + absl::string_view common_name, const KeyParams& key_params, time_t certificate_lifetime) { SSLIdentityParams params; params.key_params = key_params; - params.common_name = common_name; + params.common_name = std::string(common_name); time_t now = time(nullptr); params.not_before = now + kCertificateWindowInSeconds; params.not_after = now + certificate_lifetime; @@ -90,8 +90,8 @@ std::unique_ptr OpenSSLIdentity::CreateForTest( } std::unique_ptr OpenSSLIdentity::CreateFromPEMStrings( - const std::string& private_key, - const std::string& certificate) { + absl::string_view private_key, + absl::string_view certificate) { std::unique_ptr cert( OpenSSLCertificate::FromPEMString(certificate)); if (!cert) { @@ -110,8 +110,8 @@ std::unique_ptr OpenSSLIdentity::CreateFromPEMStrings( } std::unique_ptr OpenSSLIdentity::CreateFromPEMChainStrings( - const std::string& private_key, - const std::string& certificate_chain) { + absl::string_view private_key, + absl::string_view certificate_chain) { BIO* bio = BIO_new_mem_buf(certificate_chain.data(), rtc::dchecked_cast(certificate_chain.size())); if (!bio) diff --git a/rtc_base/openssl_identity.h b/rtc_base/openssl_identity.h index 63f46b374d..a7372109c3 100644 --- a/rtc_base/openssl_identity.h +++ b/rtc_base/openssl_identity.h @@ -29,17 +29,17 @@ namespace rtc { class OpenSSLIdentity final : public SSLIdentity { public: static std::unique_ptr CreateWithExpiration( - const std::string& common_name, + absl::string_view common_name, const KeyParams& key_params, time_t certificate_lifetime); static std::unique_ptr CreateForTest( const SSLIdentityParams& params); static std::unique_ptr CreateFromPEMStrings( - const std::string& private_key, - const std::string& certificate); + absl::string_view private_key, + absl::string_view certificate); static std::unique_ptr CreateFromPEMChainStrings( - const std::string& private_key, - const std::string& certificate_chain); + absl::string_view private_key, + absl::string_view certificate_chain); ~OpenSSLIdentity() override; OpenSSLIdentity(const OpenSSLIdentity&) = delete;