0

I'm trying to use TLS 1.3 on my websocket connection that is based on NSURLSession webSocketTaskWithRequest:. Strangely it does not ask the server for TLS 1.3. But when I use pretty much same code for HTTPS request, it uses TLS 1.3 for its request. Any idea how to properly use TLS 1.3 for websocket?

//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];
REALFREE
  • 4,378
  • 7
  • 40
  • 73

1 Answers1

0

Apparently Xcode 11.3.1 will use TLS 1.2 over TLS 1.3. I'm not sure why this happens.. but using Xcode 11.5 fixed my issue

REALFREE
  • 4,378
  • 7
  • 40
  • 73