NSURLSessionConfiguration TLSMinimumSupportedProtocol 看起来在 iOS 上不起作用



从一开始,我如何配置 NSURLSession

auto securityPolicy = self.securityPolicy;
NSURLSessionConfiguration *config = [NSURLSessionConfiguration ephemeralSessionConfiguration];
config.TLSMinimumSupportedProtocol = [CSHTTPSessionWrapper minimumTLSprotocolForSecurityPolicy: securityPolicy]; // this properly sets values kTLSProtocol1, kTLSProtocol11, kTLSProtocol12
self.session = [NSURLSession sessionWithConfiguration: config
                                             delegate: self
                                        delegateQueue: nil];

没什么花哨的。

现在,我编写了一些自动测试,将其设置为TLS 1.0、1.1、1.2,并尝试连接到openssl服务器。我写了python脚本,该脚本启动了此服务器:

def run_ssl_server(name, openSSLBinary, port, params):
    print "Starting {0} server on port {1}".format(name, port)
    proc = subprocess.Popen([openSSLBinary, "s_server", "-cert", "testres/server.cert.pem", "-key", "testres/server.key.pem", "-debug", "-www", "-accept"] + [port] + params)
    atexit.register(proc.terminate)
    print "Server started. Pid={0}".format(proc.pid)
def main() :
    … … …
    openSSLBinary = arguments.openSSLBinary # use custom build of openssl
    server_modes = {
        'normal':         ('4433', []),
        'ssl3_only':      ('4435', ['-ssl3'])
    }
    openSSLVersion = open_ssl_tool_version(openSSLBinary)
    if openSSLVersion >= LooseVersion("1.0.0") :
        print "Adding servers which can be configured for openssl 1.0.0"
        server_modes.update({
            'no_tls2' : ('4434', ['-no_tls1_2']),
            'tls1'    : ('4436', ['-tls1']),
            'tls1_1'  : ('4437', ['-tls1_1']),
            'tls1_2'  : ('4438', ['-tls1_2']),
        })
    … … …

由于预装了openssl是很旧的OpenSSL 0.9.8zh 14 Jan 2016,我已经构建了新版本并将其馈送到我的Python脚本。

现在测试正在检查客户端最小TLS版本和服务器TLS版本的所有组合。在Mac OS上,所有测试都通过!

当客户端具有更高的TLS版本时,iOS模拟器上运行的完全相同的测试是失败的。NSURLSSession返回成功,没有报告错误(他们应该)!

我对插座(NSInputStreamNSOutputStream)进行的测试完全相同,并在Mac和iOS模拟器上运行,它们正在通过,因此问题不是端口转发模拟器上的端口。

看起来NSURLSessionConfiguration TLSMinimumSupportedProtocol在iOS上不起作用!

有人有任何建议,线索吗?还是我应该向Apple提出错误报告(我讨厌apple的使用)?

确定问题在iOS 10上不可再现,因此显然Apple已经修复了此错误(我已经使用Xcode 8.2.1重新运行测试)。

最初我确实使用iOS 9(xcode 7.2)进行了测试。

最新更新