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

Unified 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: 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
« webrtc/api/java/jni/peerconnection_jni.cc ('K') | « webrtc/base/sslidentity.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/sdk/objc/Framework/Classes/RTCConfiguration.mm
diff --git a/webrtc/sdk/objc/Framework/Classes/RTCConfiguration.mm b/webrtc/sdk/objc/Framework/Classes/RTCConfiguration.mm
index b006319cae43ae81e1556cd9035b9051b1a16b62..dbe7b53034fc655c28ef37c0baf7080c79e86789 100644
--- a/webrtc/sdk/objc/Framework/Classes/RTCConfiguration.mm
+++ b/webrtc/sdk/objc/Framework/Classes/RTCConfiguration.mm
@@ -15,6 +15,7 @@
#import "RTCIceServer+Private.h"
#import "WebRTC/RTCLogging.h"
+#include "webrtc/base/rtccertificategenerator.h"
#include "webrtc/base/sslidentity.h"
@implementation RTCConfiguration
@@ -86,15 +87,15 @@
_iceConnectionReceivingTimeout;
nativeConfig.ice_backup_candidate_pair_ping_interval =
_iceBackupCandidatePairPingInterval;
- if (_keyType == RTCEncryptionKeyTypeECDSA) {
- std::unique_ptr<rtc::SSLIdentity> identity(
- rtc::SSLIdentity::Generate(webrtc::kIdentityName, rtc::KT_ECDSA));
- if (identity) {
- nativeConfig.certificates.push_back(
- rtc::RTCCertificate::Create(std::move(identity)));
- } else {
- RTCLogWarning(@"Failed to generate ECDSA identity. RSA will be used.");
- }
+ rtc::KeyType keyType =
+ [[self class] nativeEncryptionKeyTypeForKeyType:_keyType];
+ // Generate non-default certificate.
+ if (keyType != rtc::KT_DEFAULT) {
+ rtc::scoped_refptr<rtc::RTCCertificate> certificate =
+ rtc::RTCCertificateGenerator::GenerateCertificate(
+ rtc::KeyParams(keyType), rtc::Optional<uint64_t>());
+ RTC_CHECK(certificate);
+ nativeConfig.certificates.push_back(certificate);
}
return nativeConfig;
@@ -215,6 +216,16 @@
}
}
++ (rtc::KeyType)nativeEncryptionKeyTypeForKeyType:
+ (RTCEncryptionKeyType)keyType {
+ switch (keyType) {
+ case RTCEncryptionKeyTypeRSA:
+ return rtc::KT_RSA;
+ case RTCEncryptionKeyTypeECDSA:
+ return rtc::KT_ECDSA;
+ }
+}
+
+ (RTCTcpCandidatePolicy)tcpCandidatePolicyForNativePolicy:
(webrtc::PeerConnectionInterface::TcpCandidatePolicy)nativePolicy {
switch (nativePolicy) {
« webrtc/api/java/jni/peerconnection_jni.cc ('K') | « webrtc/base/sslidentity.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698