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

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: 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') | no next file with comments »
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..195b54d261af8f0ffcaa28dab39e62a2b37e84db 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,14 @@ 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>());
+ RTC_CHECK(certificate);
magjed_webrtc 2016/05/12 08:04:08 If this can ever fail, I think it's better to log
hta-webrtc 2016/05/12 08:12:25 Does putting a null pointer in rtc_config.certific
hbos 2016/05/12 08:27:08 It returns a pointer (jlong) to the resulting peer
+ 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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698