Make ECDSA default for RTCPeerConnection
BUG= Review URL: https://codereview.webrtc.org/1649533002 Cr-Commit-Position: refs/heads/master@{#11409}
This commit is contained in:
@ -23,9 +23,6 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@property(nonatomic, readonly)
|
||||
webrtc::PeerConnectionInterface::RTCConfiguration nativeConfiguration;
|
||||
|
||||
- (instancetype)initWithNativeConfiguration:
|
||||
(webrtc::PeerConnectionInterface::RTCConfiguration)nativeConfiguration;
|
||||
|
||||
+ (webrtc::PeerConnectionInterface::IceTransportsType)
|
||||
nativeTransportsTypeForTransportPolicy:(RTCIceTransportPolicy)policy;
|
||||
|
||||
|
||||
@ -42,6 +42,12 @@ typedef NS_ENUM(NSInteger, RTCTcpCandidatePolicy) {
|
||||
RTCTcpCandidatePolicyDisabled
|
||||
};
|
||||
|
||||
/** Represents the encryption key type. */
|
||||
typedef NS_ENUM(NSInteger, RTCEncryptionKeyType) {
|
||||
RTCEncryptionKeyTypeRSA,
|
||||
RTCEncryptionKeyTypeECDSA,
|
||||
};
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface RTCConfiguration : NSObject
|
||||
@ -63,17 +69,10 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@property(nonatomic, assign) int iceConnectionReceivingTimeout;
|
||||
@property(nonatomic, assign) int iceBackupCandidatePairPingInterval;
|
||||
|
||||
- (instancetype)init NS_DESIGNATED_INITIALIZER;
|
||||
/** Key type used to generate SSL identity. Default is ECDSA. */
|
||||
@property(nonatomic, assign) RTCEncryptionKeyType keyType;
|
||||
|
||||
- (instancetype)initWithIceServers:
|
||||
(nullable NSArray<RTCIceServer *> *)iceServers
|
||||
iceTransportPolicy:(RTCIceTransportPolicy)iceTransportPolicy
|
||||
bundlePolicy:(RTCBundlePolicy)bundlePolicy
|
||||
rtcpMuxPolicy:(RTCRtcpMuxPolicy)rtcpMuxPolicy
|
||||
tcpCandidatePolicy:(RTCTcpCandidatePolicy)tcpCandidatePolicy
|
||||
audioJitterBufferMaxPackets:(int)audioJitterBufferMaxPackets
|
||||
iceConnectionReceivingTimeout:(int)iceConnectionReceivingTimeout
|
||||
iceBackupCandidatePairPingInterval:(int)iceBackupCandidatePairPingInterval;
|
||||
- (instancetype)init NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@ -10,8 +10,11 @@
|
||||
|
||||
#import "RTCConfiguration.h"
|
||||
|
||||
#include "webrtc/base/sslidentity.h"
|
||||
|
||||
#import "webrtc/api/objc/RTCConfiguration+Private.h"
|
||||
#import "webrtc/api/objc/RTCIceServer+Private.h"
|
||||
#import "webrtc/base/objc/RTCLogging.h"
|
||||
|
||||
@implementation RTCConfiguration
|
||||
|
||||
@ -24,6 +27,7 @@
|
||||
@synthesize iceConnectionReceivingTimeout = _iceConnectionReceivingTimeout;
|
||||
@synthesize iceBackupCandidatePairPingInterval =
|
||||
_iceBackupCandidatePairPingInterval;
|
||||
@synthesize keyType = _keyType;
|
||||
|
||||
- (instancetype)init {
|
||||
if (self = [super init]) {
|
||||
@ -42,29 +46,7 @@
|
||||
_iceConnectionReceivingTimeout = config.ice_connection_receiving_timeout;
|
||||
_iceBackupCandidatePairPingInterval =
|
||||
config.ice_backup_candidate_pair_ping_interval;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithIceServers:(NSArray<RTCIceServer *> *)iceServers
|
||||
iceTransportPolicy:(RTCIceTransportPolicy)iceTransportPolicy
|
||||
bundlePolicy:(RTCBundlePolicy)bundlePolicy
|
||||
rtcpMuxPolicy:(RTCRtcpMuxPolicy)rtcpMuxPolicy
|
||||
tcpCandidatePolicy:(RTCTcpCandidatePolicy)tcpCandidatePolicy
|
||||
audioJitterBufferMaxPackets:(int)audioJitterBufferMaxPackets
|
||||
iceConnectionReceivingTimeout:(int)iceConnectionReceivingTimeout
|
||||
iceBackupCandidatePairPingInterval:(int)iceBackupCandidatePairPingInterval {
|
||||
if (self = [self init]) {
|
||||
if (iceServers) {
|
||||
_iceServers = [iceServers copy];
|
||||
}
|
||||
_iceTransportPolicy = iceTransportPolicy;
|
||||
_bundlePolicy = bundlePolicy;
|
||||
_rtcpMuxPolicy = rtcpMuxPolicy;
|
||||
_tcpCandidatePolicy = tcpCandidatePolicy;
|
||||
_audioJitterBufferMaxPackets = audioJitterBufferMaxPackets;
|
||||
_iceConnectionReceivingTimeout = iceConnectionReceivingTimeout;
|
||||
_iceBackupCandidatePairPingInterval = iceBackupCandidatePairPingInterval;
|
||||
_keyType = RTCEncryptionKeyTypeECDSA;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@ -103,42 +85,20 @@
|
||||
_iceConnectionReceivingTimeout;
|
||||
nativeConfig.ice_backup_candidate_pair_ping_interval =
|
||||
_iceBackupCandidatePairPingInterval;
|
||||
if (_keyType == RTCEncryptionKeyTypeECDSA) {
|
||||
rtc::scoped_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.");
|
||||
}
|
||||
}
|
||||
|
||||
return nativeConfig;
|
||||
}
|
||||
|
||||
- (instancetype)initWithNativeConfiguration:
|
||||
(webrtc::PeerConnectionInterface::RTCConfiguration)nativeConfig {
|
||||
NSMutableArray *iceServers =
|
||||
[NSMutableArray arrayWithCapacity:nativeConfig.servers.size()];
|
||||
for (auto const &server : nativeConfig.servers) {
|
||||
RTCIceServer *iceServer =
|
||||
[[RTCIceServer alloc] initWithNativeServer:server];
|
||||
[iceServers addObject:iceServer];
|
||||
}
|
||||
|
||||
if (self = [self init]) {
|
||||
if (iceServers) {
|
||||
_iceServers = [iceServers copy];
|
||||
}
|
||||
_iceTransportPolicy =
|
||||
[[self class] transportPolicyForTransportsType:nativeConfig.type];
|
||||
_bundlePolicy =
|
||||
[[self class] bundlePolicyForNativePolicy:nativeConfig.bundle_policy];
|
||||
_rtcpMuxPolicy = [[self class] rtcpMuxPolicyForNativePolicy:
|
||||
nativeConfig.rtcp_mux_policy];
|
||||
_tcpCandidatePolicy = [[self class] tcpCandidatePolicyForNativePolicy:
|
||||
nativeConfig.tcp_candidate_policy];
|
||||
_audioJitterBufferMaxPackets = nativeConfig.audio_jitter_buffer_max_packets;
|
||||
_iceConnectionReceivingTimeout =
|
||||
nativeConfig.ice_connection_receiving_timeout;
|
||||
_iceBackupCandidatePairPingInterval =
|
||||
nativeConfig.ice_backup_candidate_pair_ping_interval;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (webrtc::PeerConnectionInterface::IceTransportsType)
|
||||
nativeTransportsTypeForTransportPolicy:(RTCIceTransportPolicy)policy {
|
||||
switch (policy) {
|
||||
|
||||
@ -86,6 +86,7 @@
|
||||
return RTCSdpTypeAnswer;
|
||||
} else {
|
||||
RTC_NOTREACHED();
|
||||
return RTCSdpTypeOffer;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user