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

Unified Diff: webrtc/api/java/jni/peerconnection_jni.cc

Issue 1965313002: JNI+mm: Generate certificate if non-default key type is specified. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase with master Created 4 years, 7 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
« no previous file with comments | « no previous file | webrtc/base/sslidentity.h » ('j') | webrtc/sdk/objc/Framework/Classes/RTCConfiguration.mm » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/api/java/jni/peerconnection_jni.cc
diff --git a/webrtc/api/java/jni/peerconnection_jni.cc b/webrtc/api/java/jni/peerconnection_jni.cc
index ac328efc2b13d2e15c6a22878ba62cea11aebcc9..02b43f7a2563b8dc7e3734166d7c55112e140782 100644
--- a/webrtc/api/java/jni/peerconnection_jni.cc
+++ b/webrtc/api/java/jni/peerconnection_jni.cc
@@ -64,6 +64,7 @@
#include "webrtc/base/logsinks.h"
#include "webrtc/base/messagequeue.h"
#include "webrtc/base/networkmonitor.h"
+#include "webrtc/base/rtccertificategenerator.h"
#include "webrtc/base/ssladapter.h"
#include "webrtc/base/stringutils.h"
#include "webrtc/media/base/videocapturer.h"
@@ -1565,20 +1566,17 @@ JOW(jlong, PeerConnectionFactory_nativeCreatePeerConnection)(
"Lorg/webrtc/PeerConnection$KeyType;");
jobject j_key_type = GetObjectField(jni, j_rtc_config, j_key_type_id);
- // Create ECDSA certificate.
- if (JavaKeyTypeToNativeType(jni, j_key_type) == rtc::KT_ECDSA) {
- std::unique_ptr<rtc::SSLIdentity> ssl_identity(
- rtc::SSLIdentity::Generate(webrtc::kIdentityName, rtc::KT_ECDSA));
- if (ssl_identity.get()) {
- rtc_config.certificates.push_back(
- rtc::RTCCertificate::Create(std::move(ssl_identity)));
- LOG(LS_INFO) << "ECDSA certificate created.";
- } else {
- // Failing to create certificate should not abort peer connection
- // creation. Instead default encryption (currently RSA) will be used.
- LOG(LS_WARNING) <<
- "Failed to generate SSLIdentity. Default encryption will be used.";
+ // Generate non-default certificate.
+ rtc::KeyType key_type = JavaKeyTypeToNativeType(jni, j_key_type);
+ if (key_type != rtc::KT_DEFAULT) {
+ rtc::scoped_refptr<rtc::RTCCertificate> certificate =
+ rtc::RTCCertificateGenerator::GenerateCertificate(
+ rtc::KeyParams(key_type), rtc::Optional<uint64_t>());
+ if (!certificate) {
+ LOG(LS_ERROR) << "Failed to generate certificate. KeyType: " << key_type;
+ return 0;
}
+ rtc_config.certificates.push_back(certificate);
}
PCOJava* observer = reinterpret_cast<PCOJava*>(observer_p);
« no previous file with comments | « no previous file | webrtc/base/sslidentity.h » ('j') | webrtc/sdk/objc/Framework/Classes/RTCConfiguration.mm » ('J')

Powered by Google App Engine
This is Rietveld 408576698