2017-03-16 28 views
0

不工作從一開始,我如何配置NSURLSessionNSURLSessionConfiguration TLSMinimumSupportedProtocol看起來像在iOS

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模擬器上運行,他們通過,所以問題不是模擬器上的端口轉發。

看起來像NSURLSessionConfigurationTLSMinimumSupportedProtocol不適用於iOS!

有沒有人有任何建議,線索? 或者我應該向Apple提出一個錯誤報告(我討厭蘋果公司使用的錯誤跟蹤器)?

回答

0

好的問題在iOS 10上不可重現,所以顯然Apple已經修復了這個錯誤(我重新用Xcode 8.2.1測試過)。

起初我並與iOS 9(7.2的Xcode)測試。

相關問題