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

Unified Diff: content/renderer/media/peer_connection_identity_store.cc

Issue 1740993002: RTCPeerConnection.generateCertificate: Optionally specify expiration. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
Index: content/renderer/media/peer_connection_identity_store.cc
diff --git a/content/renderer/media/peer_connection_identity_store.cc b/content/renderer/media/peer_connection_identity_store.cc
index c6f432dc6c465c0553ca3fd97c04beab9657e4fa..e7b9b338a03331540fac5da4e748ec018d9306bd 100644
--- a/content/renderer/media/peer_connection_identity_store.cc
+++ b/content/renderer/media/peer_connection_identity_store.cc
@@ -17,6 +17,7 @@ namespace {
const char kIdentityName[] = "WebRTC";
static unsigned int kRSAChromiumKeyLength = 1024;
static unsigned int kRSAChromiumPubExp = 0x10001;
+static uint64_t kYearInSeconds = 365 * 24 * 60 * 60;
// Bridges identity requests between the main render thread and libjingle's
// signaling thread.
@@ -116,6 +117,7 @@ PeerConnectionIdentityStore::~PeerConnectionIdentityStore() {
void PeerConnectionIdentityStore::RequestIdentity(
rtc::KeyParams key_params,
+ rtc::Optional<uint64_t> expires_ms,
tommi (sloooow) - chröme 2016/03/04 09:55:40 Is there a reason why the arguments need to be pas
hbos_chromium 2016/03/04 12:24:11 No, will update webrtc interface to use const&, ro
const rtc::scoped_refptr<webrtc::DtlsIdentityRequestObserver>& observer) {
DCHECK(signaling_thread_->BelongsToCurrentThread());
DCHECK(observer);
@@ -127,7 +129,8 @@ void PeerConnectionIdentityStore::RequestIdentity(
// header file(s).
if (key_params.type() == rtc::KT_RSA &&
key_params.rsa_params().mod_size == kRSAChromiumKeyLength &&
- key_params.rsa_params().pub_exp == kRSAChromiumPubExp) {
+ key_params.rsa_params().pub_exp == kRSAChromiumPubExp &&
+ !expires_ms) {
// Use Chromium identity generation code for its hardwired parameters (RSA,
// 1024, 0x10001). This generation code is preferred over WebRTC generation
// code due to the performance benefits of caching.
@@ -140,8 +143,18 @@ void PeerConnectionIdentityStore::RequestIdentity(
} else {
// Fall back on WebRTC identity generation code for everything else, e.g.
// RSA with any other parameters or ECDSA. These will not be cached.
- scoped_ptr<rtc::SSLIdentity> identity(rtc::SSLIdentity::Generate(
- kIdentityName, key_params));
+ scoped_ptr<rtc::SSLIdentity> identity;
+ if (!expires_ms) {
+ identity.reset(rtc::SSLIdentity::Generate(kIdentityName, key_params));
+ } else {
+ uint64_t expires_s = *expires_ms / 1000;
+ // Limit the expiration time to something reasonable (a year). This also
+ // ensures that the value is not too large for time_t.
hbos_chromium 2016/03/04 09:26:31 Spec: "a user agent may choose to limit the period
tommi (sloooow) - chröme 2016/03/04 09:55:40 Was there a discussion on what is reasonable or is
hbos_chromium 2016/03/04 12:24:11 Rather arbitrarily, could have chosen something el
+ if (expires_s > kYearInSeconds)
+ expires_s = kYearInSeconds;
+ identity.reset(rtc::SSLIdentity::Generate(
+ kIdentityName, key_params, static_cast<time_t>(expires_s)));
+ }
// Invoke |observer| callbacks asynchronously. The callbacks of
// DtlsIdentityStoreInterface implementations have to be async.

Powered by Google App Engine
This is Rietveld 408576698