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

Side by Side Diff: webrtc/base/sslidentity.h

Issue 2259283002: Refactor certificate stats collection, added SSLCertificateStats. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Another unittest for the case of certificate chains using fake certificates Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 10 matching lines...) Expand all
21 #include "webrtc/base/buffer.h" 21 #include "webrtc/base/buffer.h"
22 #include "webrtc/base/constructormagic.h" 22 #include "webrtc/base/constructormagic.h"
23 #include "webrtc/base/messagedigest.h" 23 #include "webrtc/base/messagedigest.h"
24 #include "webrtc/base/timeutils.h" 24 #include "webrtc/base/timeutils.h"
25 25
26 namespace rtc { 26 namespace rtc {
27 27
28 // Forward declaration due to circular dependency with SSLCertificate. 28 // Forward declaration due to circular dependency with SSLCertificate.
29 class SSLCertChain; 29 class SSLCertChain;
30 30
31 struct SSLCertificateStats {
32 SSLCertificateStats(std::string&& fingerprint,
33 std::string&& fingerprint_algorithm,
34 std::string&& base64_certificate,
35 std::unique_ptr<SSLCertificateStats>&& issuer);
36 ~SSLCertificateStats();
37 std::string fingerprint;
38 std::string fingerprint_algorithm;
39 std::string base64_certificate;
40 std::unique_ptr<SSLCertificateStats> issuer;
41 };
42
31 // Abstract interface overridden by SSL library specific 43 // Abstract interface overridden by SSL library specific
32 // implementations. 44 // implementations.
33 45
34 // A somewhat opaque type used to encapsulate a certificate. 46 // A somewhat opaque type used to encapsulate a certificate.
35 // Wraps the SSL library's notion of a certificate, with reference counting. 47 // Wraps the SSL library's notion of a certificate, with reference counting.
36 // The SSLCertificate object is pretty much immutable once created. 48 // The SSLCertificate object is pretty much immutable once created.
37 // (The OpenSSL implementation only does reference counting and 49 // (The OpenSSL implementation only does reference counting and
38 // possibly caching of intermediate results.) 50 // possibly caching of intermediate results.)
39 class SSLCertificate { 51 class SSLCertificate {
40 public: 52 public:
(...skipping 27 matching lines...) Expand all
68 80
69 // Compute the digest of the certificate given algorithm 81 // Compute the digest of the certificate given algorithm
70 virtual bool ComputeDigest(const std::string& algorithm, 82 virtual bool ComputeDigest(const std::string& algorithm,
71 unsigned char* digest, 83 unsigned char* digest,
72 size_t size, 84 size_t size,
73 size_t* length) const = 0; 85 size_t* length) const = 0;
74 86
75 // Returns the time in seconds relative to epoch, 1970-01-01T00:00:00Z (UTC), 87 // Returns the time in seconds relative to epoch, 1970-01-01T00:00:00Z (UTC),
76 // or -1 if an expiration time could not be retrieved. 88 // or -1 if an expiration time could not be retrieved.
77 virtual int64_t CertificateExpirationTime() const = 0; 89 virtual int64_t CertificateExpirationTime() const = 0;
90
91 // Gets information (fingerprint, etc.) about this certificate and its chain
92 // (if it has a certificate chain). This is used for certificate stats, see
93 // https://w3c.github.io/webrtc-stats/#certificatestats-dict*.
94 std::unique_ptr<SSLCertificateStats> GetStats() const;
95
96 private:
97 std::unique_ptr<SSLCertificateStats> GetStats(
98 std::unique_ptr<SSLCertificateStats> issuer) const;
78 }; 99 };
79 100
80 // SSLCertChain is a simple wrapper for a vector of SSLCertificates. It serves 101 // SSLCertChain is a simple wrapper for a vector of SSLCertificates. It serves
81 // primarily to ensure proper memory management (especially deletion) of the 102 // primarily to ensure proper memory management (especially deletion) of the
82 // SSLCertificate pointers. 103 // SSLCertificate pointers.
83 class SSLCertChain { 104 class SSLCertChain {
84 public: 105 public:
85 // These constructors copy the provided SSLCertificate(s), so the caller 106 // These constructors copy the provided SSLCertificate(s), so the caller
86 // retains ownership. 107 // retains ownership.
87 explicit SSLCertChain(const std::vector<SSLCertificate*>& certs); 108 explicit SSLCertChain(const std::vector<SSLCertificate*>& certs);
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 // |s| is not 0-terminated; its char count is defined by |length|. 265 // |s| is not 0-terminated; its char count is defined by |length|.
245 int64_t ASN1TimeToSec(const unsigned char* s, size_t length, bool long_format); 266 int64_t ASN1TimeToSec(const unsigned char* s, size_t length, bool long_format);
246 267
247 extern const char kPemTypeCertificate[]; 268 extern const char kPemTypeCertificate[];
248 extern const char kPemTypeRsaPrivateKey[]; 269 extern const char kPemTypeRsaPrivateKey[];
249 extern const char kPemTypeEcPrivateKey[]; 270 extern const char kPemTypeEcPrivateKey[];
250 271
251 } // namespace rtc 272 } // namespace rtc
252 273
253 #endif // WEBRTC_BASE_SSLIDENTITY_H_ 274 #endif // WEBRTC_BASE_SSLIDENTITY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698