Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(546)

Unified Diff: webrtc/base/rtccertificate.h

Issue 1898383003: RTCCertificate serialization. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase with master (std::unique_ptr) Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/base/opensslidentity.cc ('k') | webrtc/base/rtccertificate.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/rtccertificate.h
diff --git a/webrtc/base/rtccertificate.h b/webrtc/base/rtccertificate.h
index 3d4f36e6a3e9886c70ba516bb77225929a1807b9..46d6fd427cf0e09d63e811c91dd22ab12de9c1e1 100644
--- a/webrtc/base/rtccertificate.h
+++ b/webrtc/base/rtccertificate.h
@@ -20,6 +20,28 @@
namespace rtc {
+// This class contains PEM strings of an RTCCertificate's private key and
+// certificate and acts as a text representation of RTCCertificate. Certificates
+// can be serialized and deserialized to and from this format, which allows for
+// cloning and storing of certificates to disk. The PEM format is that of
+// |SSLIdentity::PrivateKeyToPEMString| and |SSLCertificate::ToPEMString|, e.g.
+// the string representations used by OpenSSL.
+class RTCCertificatePEM {
+ public:
+ RTCCertificatePEM(
+ const std::string& private_key,
+ const std::string& certificate)
+ : private_key_(private_key),
+ certificate_(certificate) {}
+
+ const std::string& private_key() const { return private_key_; }
+ const std::string& certificate() const { return certificate_; }
+
+ private:
+ std::string private_key_;
+ std::string certificate_;
+};
+
// A thin abstraction layer between "lower level crypto stuff" like
// SSLCertificate and WebRTC usage. Takes ownership of some lower level objects,
// reference counting protects these from premature destruction.
@@ -42,6 +64,12 @@ class RTCCertificate : public RefCountInterface {
// However, some places might need SSLIdentity* for its public/private key...
SSLIdentity* identity() const { return identity_.get(); }
+ // To/from PEM, a text representation of the RTCCertificate.
+ RTCCertificatePEM ToPEM() const;
+ static scoped_refptr<RTCCertificate> FromPEM(const RTCCertificatePEM& pem);
+ bool operator==(const RTCCertificate& certificate) const;
+ bool operator!=(const RTCCertificate& certificate) const;
+
protected:
explicit RTCCertificate(SSLIdentity* identity);
~RTCCertificate() override;
« no previous file with comments | « webrtc/base/opensslidentity.cc ('k') | webrtc/base/rtccertificate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698