简体   繁体   English

iOS 13 NSURLSession websocket 不使用 TLS 1.3

[英]iOS 13 NSURLSession websocket does not use TLS 1.3

I'm trying to use TLS 1.3 on my websocket connection that is based on NSURLSession webSocketTaskWithRequest: .我正在尝试在基于NSURLSession webSocketTaskWithRequest: websocket 连接上使用 TLS 1.3。 Strangely it does not ask the server for TLS 1.3.奇怪的是,它没有向服务器询问 TLS 1.3。 But when I use pretty much same code for HTTPS request, it uses TLS 1.3 for its request.但是当我对 HTTPS 请求使用几乎相同的代码时,它使用 TLS 1.3 作为其请求。 Any idea how to properly use TLS 1.3 for websocket?知道如何为 websocket 正确使用 TLS 1.3 吗?

//HTTPS
NSURLSessionConfiguration *sessionConfig = [NSURLSessionConfiguration defaultSessionConfiguration];
sessionConfig.TLSMaximumSupportedProtocol = kTLSProtocolMaxSupported;
NSURLSession *session = [NSURLSession sessionWithConfiguration:sessionConfig 
                                                      delegate:self 
                                                 delegateQueue:[NSOperationQueue mainQueue]];

[request setURL:url];
NSURLSessionDataTask *task = [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response) {

...
}];

//WebSocket 
NSURLSessionConfiguration *config = [NSURLSessionConfiguration ephemeralSessionConfiguration];
config.TLSMaximumSupportedProtocol = kTLSProtocolMaxSupported;
NSURLSession *session = [NSURLSession sessionWithConfiguration:config
                                                          delegate:self
                                                     delegateQueue:[NSOperationQueue mainQueue]];
self.task = [session webSocketTaskWithRequest:request];
[self listen];
[self.task resume];

Apparently Xcode 11.3.1 will use TLS 1.2 over TLS 1.3.显然 Xcode 11.3.1 将使用 TLS 1.2 而不是 TLS 1.3。 I'm not sure why this happens.. but using Xcode 11.5 fixed my issue我不确定为什么会发生这种情况……但是使用 Xcode 11.5 解决了我的问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 iOS 13 上为 WebSocket over TLS 信任自签名证书 - Trust self-signed certificates on iOS 13 for WebSocket over TLS 为什么iOS 13.x 13.4以下的版本还在使用TLS 1.0/1.1,如何强制使用TLS 1.2及以上? - Why iOS 13.x below the 13.4 version is still using TLS 1.0/1.1 and how to force it to use TLS 1.2 and above? 与 Swift iOS 的 WSS/TLS websocket 连接 - WSS/TLS websocket connection with Swift iOS ios NSURLSession(默认配置)不缓存请求 - ios NSURLSession (default configuration) does not cache requests NSURLSession-在AWS IOS SDK中使用uploadTaskWithStreamedRequest - NSURLSession - use uploadTaskWithStreamedRequest with AWS IOS SDK iOS是否支持TLS压缩? - Does iOS support TLS compression? 如何从iOS NSURLSession访问Node JS TLS服务器 - How do I access Node JS TLS Server from iOS NSURLSession nsurlsession ios 13 蜂窝错误域=NSURLErrorDomain 代码=-1009 “Internet 连接似乎已脱机。” - nsurlsession ios 13 cellular Error Domain=NSURLErrorDomain Code=-1009 “The Internet connection appears to be offline.” 'initWithRequest:delegate:'不推荐使用:首先在iOS 9.0中弃用 - 使用NSURLSession(参见NSURLSession.h) - 'initWithRequest:delegate:' is deprecated: first deprecated in iOS 9.0 - use NSURLSession(see NSURLSession.h) iOS NSURLSession是否支持HTTP 100-continue? - Does iOS NSURLSession support HTTP 100-continue?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM