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

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: ...and generateCertificateExpires signature Created 4 years, 9 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..90f3a364ca5d2ed812a50d8e9dcdbcd4830f8ce7 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.
@@ -115,7 +116,8 @@ PeerConnectionIdentityStore::~PeerConnectionIdentityStore() {
}
void PeerConnectionIdentityStore::RequestIdentity(
- rtc::KeyParams key_params,
+ const rtc::KeyParams& key_params,
+ const rtc::Optional<uint64_t>& expires_ms,
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.
+ if (expires_s > kYearInSeconds)
+ expires_s = kYearInSeconds;
+ identity.reset(rtc::SSLIdentity::Generate(
+ kIdentityName, key_params, static_cast<time_t>(expires_s)));
Ryan Sleevi 2016/03/08 17:06:10 BUG: You cannot do this sort of cast. There's no g
hbos_chromium 2016/04/13 17:03:08 From JavaScript we get a uint64_t timestamp. We wa
hbos_chromium 2016/04/13 17:09:39 PS I have a CL in the works that will use uint64_t
hbos_chromium 2016/04/18 10:04:27 Hang on, I'll patch to use this now before asking
hbos_chromium 2016/04/18 13:23:59 Nevermind, using the new API should be done separa
+ }
// Invoke |observer| callbacks asynchronously. The callbacks of
// DtlsIdentityStoreInterface implementations have to be async.

Powered by Google App Engine
This is Rietveld 408576698