| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2015 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 |
| 11 #ifndef WEBRTC_BASE_RTCCERTIFICATE_H_ | 11 #ifndef WEBRTC_BASE_RTCCERTIFICATE_H_ |
| 12 #define WEBRTC_BASE_RTCCERTIFICATE_H_ | 12 #define WEBRTC_BASE_RTCCERTIFICATE_H_ |
| 13 | 13 |
| 14 #include <memory> |
| 15 |
| 14 #include "webrtc/base/basictypes.h" | 16 #include "webrtc/base/basictypes.h" |
| 15 #include "webrtc/base/refcount.h" | 17 #include "webrtc/base/refcount.h" |
| 16 #include "webrtc/base/scoped_ptr.h" | |
| 17 #include "webrtc/base/scoped_ref_ptr.h" | 18 #include "webrtc/base/scoped_ref_ptr.h" |
| 18 #include "webrtc/base/sslidentity.h" | 19 #include "webrtc/base/sslidentity.h" |
| 19 | 20 |
| 20 namespace rtc { | 21 namespace rtc { |
| 21 | 22 |
| 22 // A thin abstraction layer between "lower level crypto stuff" like | 23 // A thin abstraction layer between "lower level crypto stuff" like |
| 23 // SSLCertificate and WebRTC usage. Takes ownership of some lower level objects, | 24 // SSLCertificate and WebRTC usage. Takes ownership of some lower level objects, |
| 24 // reference counting protects these from premature destruction. | 25 // reference counting protects these from premature destruction. |
| 25 class RTCCertificate : public RefCountInterface { | 26 class RTCCertificate : public RefCountInterface { |
| 26 public: | 27 public: |
| 27 // Takes ownership of |identity|. | 28 // Takes ownership of |identity|. |
| 28 static scoped_refptr<RTCCertificate> Create(scoped_ptr<SSLIdentity> identity); | 29 static scoped_refptr<RTCCertificate> Create( |
| 30 std::unique_ptr<SSLIdentity> identity); |
| 29 | 31 |
| 30 // Returns the expiration time in ms relative to epoch, 1970-01-01T00:00:00Z. | 32 // Returns the expiration time in ms relative to epoch, 1970-01-01T00:00:00Z. |
| 31 uint64_t Expires() const; | 33 uint64_t Expires() const; |
| 32 // Checks if the certificate has expired, where |now| is expressed in ms | 34 // Checks if the certificate has expired, where |now| is expressed in ms |
| 33 // relative to epoch, 1970-01-01T00:00:00Z. | 35 // relative to epoch, 1970-01-01T00:00:00Z. |
| 34 bool HasExpired(uint64_t now) const; | 36 bool HasExpired(uint64_t now) const; |
| 35 const SSLCertificate& ssl_certificate() const; | 37 const SSLCertificate& ssl_certificate() const; |
| 36 | 38 |
| 37 // TODO(hbos): If possible, remove once RTCCertificate and its | 39 // TODO(hbos): If possible, remove once RTCCertificate and its |
| 38 // ssl_certificate() is used in all relevant places. Should not pass around | 40 // ssl_certificate() is used in all relevant places. Should not pass around |
| 39 // raw SSLIdentity* for the sake of accessing SSLIdentity::certificate(). | 41 // raw SSLIdentity* for the sake of accessing SSLIdentity::certificate(). |
| 40 // However, some places might need SSLIdentity* for its public/private key... | 42 // However, some places might need SSLIdentity* for its public/private key... |
| 41 SSLIdentity* identity() const { return identity_.get(); } | 43 SSLIdentity* identity() const { return identity_.get(); } |
| 42 | 44 |
| 43 protected: | 45 protected: |
| 44 explicit RTCCertificate(SSLIdentity* identity); | 46 explicit RTCCertificate(SSLIdentity* identity); |
| 45 ~RTCCertificate() override; | 47 ~RTCCertificate() override; |
| 46 | 48 |
| 47 private: | 49 private: |
| 48 // The SSLIdentity is the owner of the SSLCertificate. To protect our | 50 // The SSLIdentity is the owner of the SSLCertificate. To protect our |
| 49 // ssl_certificate() we take ownership of |identity_|. | 51 // ssl_certificate() we take ownership of |identity_|. |
| 50 scoped_ptr<SSLIdentity> identity_; | 52 std::unique_ptr<SSLIdentity> identity_; |
| 51 }; | 53 }; |
| 52 | 54 |
| 53 } // namespace rtc | 55 } // namespace rtc |
| 54 | 56 |
| 55 #endif // WEBRTC_BASE_RTCCERTIFICATE_H_ | 57 #endif // WEBRTC_BASE_RTCCERTIFICATE_H_ |
| OLD | NEW |