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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2013 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 #include "webrtc/api/rtpreceiverinterface.h" 57 #include "webrtc/api/rtpreceiverinterface.h"
58 #include "webrtc/api/rtpsenderinterface.h" 58 #include "webrtc/api/rtpsenderinterface.h"
59 #include "webrtc/api/webrtcsdp.h" 59 #include "webrtc/api/webrtcsdp.h"
60 #include "webrtc/base/bind.h" 60 #include "webrtc/base/bind.h"
61 #include "webrtc/base/checks.h" 61 #include "webrtc/base/checks.h"
62 #include "webrtc/base/event_tracer.h" 62 #include "webrtc/base/event_tracer.h"
63 #include "webrtc/base/logging.h" 63 #include "webrtc/base/logging.h"
64 #include "webrtc/base/logsinks.h" 64 #include "webrtc/base/logsinks.h"
65 #include "webrtc/base/messagequeue.h" 65 #include "webrtc/base/messagequeue.h"
66 #include "webrtc/base/networkmonitor.h" 66 #include "webrtc/base/networkmonitor.h"
67 #include "webrtc/base/rtccertificategenerator.h"
67 #include "webrtc/base/ssladapter.h" 68 #include "webrtc/base/ssladapter.h"
68 #include "webrtc/base/stringutils.h" 69 #include "webrtc/base/stringutils.h"
69 #include "webrtc/media/base/videocapturer.h" 70 #include "webrtc/media/base/videocapturer.h"
70 #include "webrtc/media/devices/videorendererfactory.h" 71 #include "webrtc/media/devices/videorendererfactory.h"
71 #include "webrtc/media/engine/webrtcvideodecoderfactory.h" 72 #include "webrtc/media/engine/webrtcvideodecoderfactory.h"
72 #include "webrtc/media/engine/webrtcvideoencoderfactory.h" 73 #include "webrtc/media/engine/webrtcvideoencoderfactory.h"
73 #include "webrtc/system_wrappers/include/field_trial_default.h" 74 #include "webrtc/system_wrappers/include/field_trial_default.h"
74 #include "webrtc/system_wrappers/include/logcat_trace_context.h" 75 #include "webrtc/system_wrappers/include/logcat_trace_context.h"
75 #include "webrtc/system_wrappers/include/trace.h" 76 #include "webrtc/system_wrappers/include/trace.h"
76 #include "webrtc/voice_engine/include/voe_base.h" 77 #include "webrtc/voice_engine/include/voe_base.h"
(...skipping 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after
1558 factoryFromJava(factory))); 1559 factoryFromJava(factory)));
1559 1560
1560 PeerConnectionInterface::RTCConfiguration rtc_config; 1561 PeerConnectionInterface::RTCConfiguration rtc_config;
1561 JavaRTCConfigurationToJsepRTCConfiguration(jni, j_rtc_config, &rtc_config); 1562 JavaRTCConfigurationToJsepRTCConfiguration(jni, j_rtc_config, &rtc_config);
1562 1563
1563 jclass j_rtc_config_class = GetObjectClass(jni, j_rtc_config); 1564 jclass j_rtc_config_class = GetObjectClass(jni, j_rtc_config);
1564 jfieldID j_key_type_id = GetFieldID(jni, j_rtc_config_class, "keyType", 1565 jfieldID j_key_type_id = GetFieldID(jni, j_rtc_config_class, "keyType",
1565 "Lorg/webrtc/PeerConnection$KeyType;"); 1566 "Lorg/webrtc/PeerConnection$KeyType;");
1566 jobject j_key_type = GetObjectField(jni, j_rtc_config, j_key_type_id); 1567 jobject j_key_type = GetObjectField(jni, j_rtc_config, j_key_type_id);
1567 1568
1568 // Create ECDSA certificate. 1569 // Generate non-default certificate.
1569 if (JavaKeyTypeToNativeType(jni, j_key_type) == rtc::KT_ECDSA) { 1570 rtc::KeyType key_type = JavaKeyTypeToNativeType(jni, j_key_type);
1570 std::unique_ptr<rtc::SSLIdentity> ssl_identity( 1571 if (key_type != rtc::KT_DEFAULT) {
1571 rtc::SSLIdentity::Generate(webrtc::kIdentityName, rtc::KT_ECDSA)); 1572 rtc::scoped_refptr<rtc::RTCCertificate> certificate =
1572 if (ssl_identity.get()) { 1573 rtc::RTCCertificateGenerator::GenerateCertificate(
1573 rtc_config.certificates.push_back( 1574 rtc::KeyParams(key_type), rtc::Optional<uint64_t>());
1574 rtc::RTCCertificate::Create(std::move(ssl_identity))); 1575 if (!certificate) {
1575 LOG(LS_INFO) << "ECDSA certificate created."; 1576 LOG(LS_ERROR) << "Failed to generate certificate. KeyType: " << key_type;
1576 } else { 1577 return 0;
1577 // Failing to create certificate should not abort peer connection
1578 // creation. Instead default encryption (currently RSA) will be used.
1579 LOG(LS_WARNING) <<
1580 "Failed to generate SSLIdentity. Default encryption will be used.";
1581 } 1578 }
1579 rtc_config.certificates.push_back(certificate);
1582 } 1580 }
1583 1581
1584 PCOJava* observer = reinterpret_cast<PCOJava*>(observer_p); 1582 PCOJava* observer = reinterpret_cast<PCOJava*>(observer_p);
1585 observer->SetConstraints(new ConstraintsWrapper(jni, j_constraints)); 1583 observer->SetConstraints(new ConstraintsWrapper(jni, j_constraints));
1586 rtc::scoped_refptr<PeerConnectionInterface> pc(f->CreatePeerConnection( 1584 rtc::scoped_refptr<PeerConnectionInterface> pc(f->CreatePeerConnection(
1587 rtc_config, observer->constraints(), NULL, NULL, observer)); 1585 rtc_config, observer->constraints(), NULL, NULL, observer));
1588 return (jlong)pc.release(); 1586 return (jlong)pc.release();
1589 } 1587 }
1590 1588
1591 static rtc::scoped_refptr<PeerConnectionInterface> ExtractNativePC( 1589 static rtc::scoped_refptr<PeerConnectionInterface> ExtractNativePC(
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
2209 return JavaStringFromStdString( 2207 return JavaStringFromStdString(
2210 jni, 2208 jni,
2211 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->id()); 2209 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->id());
2212 } 2210 }
2213 2211
2214 JOW(void, RtpReceiver_free)(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) { 2212 JOW(void, RtpReceiver_free)(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) {
2215 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->Release(); 2213 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->Release();
2216 } 2214 }
2217 2215
2218 } // namespace webrtc_jni 2216 } // namespace webrtc_jni
OLDNEW
« 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