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

Unified Diff: third_party/WebKit/Source/modules/mediastream/RTCPeerConnection.cpp

Issue 1740993002: RTCPeerConnection.generateCertificate: Optionally specify expiration. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments 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
Index: third_party/WebKit/Source/modules/mediastream/RTCPeerConnection.cpp
diff --git a/third_party/WebKit/Source/modules/mediastream/RTCPeerConnection.cpp b/third_party/WebKit/Source/modules/mediastream/RTCPeerConnection.cpp
index 5a7ac66b89e0d312d59b628f3ecbdaf8f03fc264..fbc8b05127dc73f51124406b2df023f6e23443b6 100644
--- a/third_party/WebKit/Source/modules/mediastream/RTCPeerConnection.cpp
+++ b/third_party/WebKit/Source/modules/mediastream/RTCPeerConnection.cpp
@@ -672,6 +672,22 @@ ScriptPromise RTCPeerConnection::generateCertificate(ScriptState* scriptState, c
return promise;
}
+ // Check if |keygenAlgorithm| contains the optional DOMTimeStamp |expires| attribute.
+ Nullable<DOMTimeStamp> expires;
+ if (keygenAlgorithm.isDictionary()) {
+ Dictionary keygenAlgorithmDict = keygenAlgorithm.getAsDictionary();
+ if (keygenAlgorithmDict.hasProperty("expires")) {
+ v8::Local<v8::Value> expiresValue;
+ keygenAlgorithmDict.get("expires", expiresValue);
+ if (expiresValue->IsNumber()) {
+ double expiresDouble = expiresValue->ToNumber(scriptState->isolate()->GetCurrentContext()).ToLocalChecked()->Value();
+ if (expiresDouble >= 0) {
+ expires.set(static_cast<DOMTimeStamp>(expiresDouble));
+ }
+ }
+ }
+ }
+
// Convert from WebCrypto representation to recognized WebRTCKeyParams. WebRTC supports a small subset of what are valid AlgorithmIdentifiers.
const char* unsupportedParamsString = "The 1st argument provided is an AlgorithmIdentifier with a supported algorithm name, but the parameters are not supported.";
Nullable<WebRTCKeyParams> keyParams;
@@ -718,11 +734,20 @@ ScriptPromise RTCPeerConnection::generateCertificate(ScriptState* scriptState, c
// Generate certificate. The |certificateObserver| will resolve the promise asynchronously upon completion.
// The observer will manage its own destruction as well as the resolver's destruction.
- certificateGenerator->generateCertificate(
- keyParams.get(),
- toDocument(scriptState->getExecutionContext())->url(),
- toDocument(scriptState->getExecutionContext())->firstPartyForCookies(),
- std::move(certificateObserver));
+ if (expires.isNull()) {
+ certificateGenerator->generateCertificate(
+ keyParams.get(),
+ toDocument(scriptState->getExecutionContext())->url(),
+ toDocument(scriptState->getExecutionContext())->firstPartyForCookies(),
+ std::move(certificateObserver));
+ } else {
+ certificateGenerator->generateCertificateWithExpiration(
+ keyParams.get(),
+ toDocument(scriptState->getExecutionContext())->url(),
+ toDocument(scriptState->getExecutionContext())->firstPartyForCookies(),
+ expires.get(),
+ std::move(certificateObserver));
+ }
return promise;
}

Powered by Google App Engine
This is Rietveld 408576698