Enable SNI in ssl adapter.
Bug: webrtc:6973 Change-Id: I13d28cf41c586880bd7fea523005233921794cdf Reviewed-on: https://chromium-review.googlesource.com/523024 Reviewed-by: Zeke Chin <tkchin@webrtc.org> Reviewed-by: Sami Kalliomäki <sakal@webrtc.org> Reviewed-by: Justin Uberti <juberti@chromium.org> Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> Commit-Queue: Emad Omara <emadomara@google.com> Cr-Commit-Position: refs/heads/master@{#18640}
This commit is contained in:
@ -18,6 +18,7 @@
|
||||
@synthesize username = _username;
|
||||
@synthesize credential = _credential;
|
||||
@synthesize tlsCertPolicy = _tlsCertPolicy;
|
||||
@synthesize hostname = _hostname;
|
||||
|
||||
- (instancetype)initWithURLStrings:(NSArray<NSString *> *)urlStrings {
|
||||
return [self initWithURLStrings:urlStrings
|
||||
@ -38,21 +39,36 @@
|
||||
username:(NSString *)username
|
||||
credential:(NSString *)credential
|
||||
tlsCertPolicy:(RTCTlsCertPolicy)tlsCertPolicy {
|
||||
return [self initWithURLStrings:urlStrings
|
||||
username:username
|
||||
credential:credential
|
||||
tlsCertPolicy:RTCTlsCertPolicySecure
|
||||
hostname:nil];
|
||||
}
|
||||
|
||||
- (instancetype)initWithURLStrings:(NSArray<NSString *> *)urlStrings
|
||||
username:(NSString *)username
|
||||
credential:(NSString *)credential
|
||||
tlsCertPolicy:(RTCTlsCertPolicy)tlsCertPolicy
|
||||
hostname:(NSString *)hostname {
|
||||
NSParameterAssert(urlStrings.count);
|
||||
if (self = [super init]) {
|
||||
_urlStrings = [[NSArray alloc] initWithArray:urlStrings copyItems:YES];
|
||||
_username = [username copy];
|
||||
_credential = [credential copy];
|
||||
_tlsCertPolicy = tlsCertPolicy;
|
||||
_hostname = [hostname copy];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString *)description {
|
||||
return
|
||||
[NSString stringWithFormat:@"RTCIceServer:\n%@\n%@\n%@\n%@", _urlStrings,
|
||||
_username, _credential,
|
||||
[self stringForTlsCertPolicy:_tlsCertPolicy]];
|
||||
return [NSString stringWithFormat:@"RTCIceServer:\n%@\n%@\n%@\n%@\n%@",
|
||||
_urlStrings,
|
||||
_username,
|
||||
_credential,
|
||||
[self stringForTlsCertPolicy:_tlsCertPolicy],
|
||||
_hostname];
|
||||
}
|
||||
|
||||
#pragma mark - Private
|
||||
@ -71,6 +87,7 @@
|
||||
|
||||
iceServer.username = [NSString stdStringForString:_username];
|
||||
iceServer.password = [NSString stdStringForString:_credential];
|
||||
iceServer.hostname = [NSString stdStringForString:_hostname];
|
||||
|
||||
[_urlStrings enumerateObjectsUsingBlock:^(NSString *url,
|
||||
NSUInteger idx,
|
||||
@ -100,6 +117,7 @@
|
||||
}
|
||||
NSString *username = [NSString stringForStdString:nativeServer.username];
|
||||
NSString *credential = [NSString stringForStdString:nativeServer.password];
|
||||
NSString *hostname = [NSString stringForStdString:nativeServer.hostname];
|
||||
RTCTlsCertPolicy tlsCertPolicy;
|
||||
|
||||
switch (nativeServer.tls_cert_policy) {
|
||||
@ -114,7 +132,8 @@
|
||||
self = [self initWithURLStrings:urls
|
||||
username:username
|
||||
credential:credential
|
||||
tlsCertPolicy:tlsCertPolicy];
|
||||
tlsCertPolicy:tlsCertPolicy
|
||||
hostname:hostname];
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
@ -36,6 +36,13 @@ RTC_EXPORT
|
||||
*/
|
||||
@property(nonatomic, readonly) RTCTlsCertPolicy tlsCertPolicy;
|
||||
|
||||
/**
|
||||
If the URIs in |urls| only contain IP addresses, this field can be used
|
||||
to indicate the hostname, which may be necessary for TLS (using the SNI
|
||||
extension). If |urls| itself contains the hostname, this isn't necessary.
|
||||
*/
|
||||
@property(nonatomic, readonly, nullable) NSString *hostname;
|
||||
|
||||
- (nonnull instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
/** Convenience initializer for a server with no authentication (e.g. STUN). */
|
||||
@ -53,11 +60,20 @@ RTC_EXPORT
|
||||
* Initialize an RTCIceServer with its associated URLs, optional username,
|
||||
* optional credential, and TLS cert policy.
|
||||
*/
|
||||
- (instancetype)initWithURLStrings:(NSArray<NSString *> *)urlStrings
|
||||
username:(nullable NSString *)username
|
||||
credential:(nullable NSString *)credential
|
||||
tlsCertPolicy:(RTCTlsCertPolicy)tlsCertPolicy;
|
||||
|
||||
/**
|
||||
* Initialize an RTCIceServer with its associated URLs, optional username,
|
||||
* optional credential, TLS cert policy and hostname.
|
||||
*/
|
||||
- (instancetype)initWithURLStrings:(NSArray<NSString *> *)urlStrings
|
||||
username:(nullable NSString *)username
|
||||
credential:(nullable NSString *)credential
|
||||
tlsCertPolicy:(RTCTlsCertPolicy)tlsCertPolicy
|
||||
NS_DESIGNATED_INITIALIZER;
|
||||
hostname:(nullable NSString *)hostname NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@ -62,11 +62,26 @@
|
||||
EXPECT_EQ("credential", iceStruct.password);
|
||||
}
|
||||
|
||||
- (void)testHostname {
|
||||
RTCIceServer *server = [[RTCIceServer alloc] initWithURLStrings:@[ @"turn1:turn1.example.net" ]
|
||||
username:@"username"
|
||||
credential:@"credential"
|
||||
tlsCertPolicy:RTCTlsCertPolicySecure
|
||||
hostname:@"hostname"];
|
||||
webrtc::PeerConnectionInterface::IceServer iceStruct = server.nativeServer;
|
||||
EXPECT_EQ(1u, iceStruct.urls.size());
|
||||
EXPECT_EQ("turn1:turn1.example.net", iceStruct.urls.front());
|
||||
EXPECT_EQ("username", iceStruct.username);
|
||||
EXPECT_EQ("credential", iceStruct.password);
|
||||
EXPECT_EQ("hostname", iceStruct.hostname);
|
||||
}
|
||||
|
||||
- (void)testInitFromNativeServer {
|
||||
webrtc::PeerConnectionInterface::IceServer nativeServer;
|
||||
nativeServer.username = "username";
|
||||
nativeServer.password = "password";
|
||||
nativeServer.urls.push_back("stun:stun.example.net");
|
||||
nativeServer.hostname = "hostname";
|
||||
|
||||
RTCIceServer *iceServer =
|
||||
[[RTCIceServer alloc] initWithNativeServer:nativeServer];
|
||||
@ -75,6 +90,7 @@
|
||||
[NSString stdStringForString:iceServer.urlStrings.firstObject]);
|
||||
EXPECT_EQ("username", [NSString stdStringForString:iceServer.username]);
|
||||
EXPECT_EQ("password", [NSString stdStringForString:iceServer.credential]);
|
||||
EXPECT_EQ("hostname", [NSString stdStringForString:iceServer.hostname]);
|
||||
}
|
||||
|
||||
@end
|
||||
@ -100,6 +116,13 @@ TEST(RTCIceServerTest, PasswordCredentialTest) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(RTCIceServerTest, HostnameTest) {
|
||||
@autoreleasepool {
|
||||
RTCIceServerTest *test = [[RTCIceServerTest alloc] init];
|
||||
[test testHostname];
|
||||
}
|
||||
}
|
||||
|
||||
TEST(RTCIceServerTest, InitFromNativeServerTest) {
|
||||
@autoreleasepool {
|
||||
RTCIceServerTest *test = [[RTCIceServerTest alloc] init];
|
||||
|
||||
Reference in New Issue
Block a user