【问题标题】:NSURLSessionConfiguration TLSMinimumSupportedProtocol looks like doesn't work on iOSNSURLSessionConfiguration TLSMinimumSupportedProtocol 看起来在 iOS 上不起作用
【发布时间】:2017-03-16 12:29:42
【问题描述】:

从一开始,我如何配置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 返回成功,不报告错误(而且应该)!

与我对套接字(NSInputStream 和 NSOutputStream)所做的测试完全相同,并且在 Mac 和 iOS 模拟器上运行并且它们正在通过,所以问题不是模拟器上的端口转发。

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

有没有人有任何建议,线索? 或者我应该向 Apple 提交错误报告(我讨厌 Apple 使用的错误跟踪器)?

【问题讨论】:

    标签: ios objective-c macos ssl nsurlsession


    【解决方案1】:

    好的问题在 iOS 10 上无法重现,所以显然 Apple 已经修复了这个错误(我已经使用 Xcode 8.2.1 重新运行测试)。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-08
      • 2020-04-22
      • 2014-02-05
      • 2018-12-27
      • 1970-01-01
      • 2013-05-17
      相关资源
      最近更新 更多