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/sdk/objc/Framework/Classes/RTCConfiguration.mm

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: jni returning null instead 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
« no previous file with comments | « webrtc/base/sslidentity.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2015 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
11 #import "RTCConfiguration+Private.h" 11 #import "RTCConfiguration+Private.h"
12 12
13 #include <memory> 13 #include <memory>
14 14
15 #import "RTCIceServer+Private.h" 15 #import "RTCIceServer+Private.h"
16 #import "WebRTC/RTCLogging.h" 16 #import "WebRTC/RTCLogging.h"
17 17
18 #include "webrtc/base/rtccertificategenerator.h"
18 #include "webrtc/base/sslidentity.h" 19 #include "webrtc/base/sslidentity.h"
19 20
20 @implementation RTCConfiguration 21 @implementation RTCConfiguration
21 22
22 @synthesize iceServers = _iceServers; 23 @synthesize iceServers = _iceServers;
23 @synthesize iceTransportPolicy = _iceTransportPolicy; 24 @synthesize iceTransportPolicy = _iceTransportPolicy;
24 @synthesize bundlePolicy = _bundlePolicy; 25 @synthesize bundlePolicy = _bundlePolicy;
25 @synthesize rtcpMuxPolicy = _rtcpMuxPolicy; 26 @synthesize rtcpMuxPolicy = _rtcpMuxPolicy;
26 @synthesize tcpCandidatePolicy = _tcpCandidatePolicy; 27 @synthesize tcpCandidatePolicy = _tcpCandidatePolicy;
27 @synthesize audioJitterBufferMaxPackets = _audioJitterBufferMaxPackets; 28 @synthesize audioJitterBufferMaxPackets = _audioJitterBufferMaxPackets;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 [[self class] nativeBundlePolicyForPolicy:_bundlePolicy]; 80 [[self class] nativeBundlePolicyForPolicy:_bundlePolicy];
80 nativeConfig.rtcp_mux_policy = 81 nativeConfig.rtcp_mux_policy =
81 [[self class] nativeRtcpMuxPolicyForPolicy:_rtcpMuxPolicy]; 82 [[self class] nativeRtcpMuxPolicyForPolicy:_rtcpMuxPolicy];
82 nativeConfig.tcp_candidate_policy = 83 nativeConfig.tcp_candidate_policy =
83 [[self class] nativeTcpCandidatePolicyForPolicy:_tcpCandidatePolicy]; 84 [[self class] nativeTcpCandidatePolicyForPolicy:_tcpCandidatePolicy];
84 nativeConfig.audio_jitter_buffer_max_packets = _audioJitterBufferMaxPackets; 85 nativeConfig.audio_jitter_buffer_max_packets = _audioJitterBufferMaxPackets;
85 nativeConfig.ice_connection_receiving_timeout = 86 nativeConfig.ice_connection_receiving_timeout =
86 _iceConnectionReceivingTimeout; 87 _iceConnectionReceivingTimeout;
87 nativeConfig.ice_backup_candidate_pair_ping_interval = 88 nativeConfig.ice_backup_candidate_pair_ping_interval =
88 _iceBackupCandidatePairPingInterval; 89 _iceBackupCandidatePairPingInterval;
89 if (_keyType == RTCEncryptionKeyTypeECDSA) { 90 rtc::KeyType keyType =
90 std::unique_ptr<rtc::SSLIdentity> identity( 91 [[self class] nativeEncryptionKeyTypeForKeyType:_keyType];
91 rtc::SSLIdentity::Generate(webrtc::kIdentityName, rtc::KT_ECDSA)); 92 // Generate non-default certificate.
92 if (identity) { 93 if (keyType != rtc::KT_DEFAULT) {
93 nativeConfig.certificates.push_back( 94 rtc::scoped_refptr<rtc::RTCCertificate> certificate =
94 rtc::RTCCertificate::Create(std::move(identity))); 95 rtc::RTCCertificateGenerator::GenerateCertificate(
95 } else { 96 rtc::KeyParams(keyType), rtc::Optional<uint64_t>());
96 RTCLogWarning(@"Failed to generate ECDSA identity. RSA will be used."); 97 RTC_CHECK(certificate);
hbos 2016/05/12 08:27:08 Here I still crash though. Since it is converting
hbos 2016/05/12 08:39:08 Wait let me see if I can make setConfiguration ret
97 } 98 nativeConfig.certificates.push_back(certificate);
98 } 99 }
99 100
100 return nativeConfig; 101 return nativeConfig;
101 } 102 }
102 103
103 + (webrtc::PeerConnectionInterface::IceTransportsType) 104 + (webrtc::PeerConnectionInterface::IceTransportsType)
104 nativeTransportsTypeForTransportPolicy:(RTCIceTransportPolicy)policy { 105 nativeTransportsTypeForTransportPolicy:(RTCIceTransportPolicy)policy {
105 switch (policy) { 106 switch (policy) {
106 case RTCIceTransportPolicyNone: 107 case RTCIceTransportPolicyNone:
107 return webrtc::PeerConnectionInterface::kNone; 108 return webrtc::PeerConnectionInterface::kNone;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 + (webrtc::PeerConnectionInterface::TcpCandidatePolicy) 209 + (webrtc::PeerConnectionInterface::TcpCandidatePolicy)
209 nativeTcpCandidatePolicyForPolicy:(RTCTcpCandidatePolicy)policy { 210 nativeTcpCandidatePolicyForPolicy:(RTCTcpCandidatePolicy)policy {
210 switch (policy) { 211 switch (policy) {
211 case RTCTcpCandidatePolicyEnabled: 212 case RTCTcpCandidatePolicyEnabled:
212 return webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled; 213 return webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled;
213 case RTCTcpCandidatePolicyDisabled: 214 case RTCTcpCandidatePolicyDisabled:
214 return webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled; 215 return webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled;
215 } 216 }
216 } 217 }
217 218
219 + (rtc::KeyType)nativeEncryptionKeyTypeForKeyType:
220 (RTCEncryptionKeyType)keyType {
221 switch (keyType) {
222 case RTCEncryptionKeyTypeRSA:
223 return rtc::KT_RSA;
224 case RTCEncryptionKeyTypeECDSA:
225 return rtc::KT_ECDSA;
226 }
227 }
228
218 + (RTCTcpCandidatePolicy)tcpCandidatePolicyForNativePolicy: 229 + (RTCTcpCandidatePolicy)tcpCandidatePolicyForNativePolicy:
219 (webrtc::PeerConnectionInterface::TcpCandidatePolicy)nativePolicy { 230 (webrtc::PeerConnectionInterface::TcpCandidatePolicy)nativePolicy {
220 switch (nativePolicy) { 231 switch (nativePolicy) {
221 case webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled: 232 case webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled:
222 return RTCTcpCandidatePolicyEnabled; 233 return RTCTcpCandidatePolicyEnabled;
223 case webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled: 234 case webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled:
224 return RTCTcpCandidatePolicyDisabled; 235 return RTCTcpCandidatePolicyDisabled;
225 } 236 }
226 } 237 }
227 238
228 + (NSString *)stringForTcpCandidatePolicy:(RTCTcpCandidatePolicy)policy { 239 + (NSString *)stringForTcpCandidatePolicy:(RTCTcpCandidatePolicy)policy {
229 switch (policy) { 240 switch (policy) {
230 case RTCTcpCandidatePolicyEnabled: 241 case RTCTcpCandidatePolicyEnabled:
231 return @"TCP_ENABLED"; 242 return @"TCP_ENABLED";
232 case RTCTcpCandidatePolicyDisabled: 243 case RTCTcpCandidatePolicyDisabled:
233 return @"TCP_DISABLED"; 244 return @"TCP_DISABLED";
234 } 245 }
235 } 246 }
236 247
237 @end 248 @end
OLDNEW
« no previous file with comments | « webrtc/base/sslidentity.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698