NSAllowsArbitraryLoads不起作用

时间:2017-08-01 10:00:17

标签: ios reactjs https app-transport-security

我是iOS反应原生应用程序的开发人员。 当我通过react fetch调用执行HTTPS请求时,我得到了这个异常。

2017-08-01 09:18:07.199 [info][tid:com.facebook.react.JavaScript] 
'REQUEST_DATA: ', { method: 'GET',
      headers:
    { Accept: 'application/json',
      'Content-Type': 'application/json',
      credentials: 'include',
      Authorization: 'Basic MzI1MjM0NTo1MjU0' } }
2017-08-01 09:18:07.200 [info][tid:com.facebook.react.JavaScript] 'REQUEST_URL: ', 'https://10.36.6.186/mwprb/rest/personnel-number'
2017-08-01 09:18:07.287393+0300 MobileApp[2954:1413289] [] nw_coretls_callback_handshake_message_block_invoke_3 tls_handshake_continue: [-9812]
2017-08-01 09:18:07.287 UFSConfirmationMobile[2954:1411062] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813)
2017-08-01 09:18:07.291 [info][tid:com.facebook.react.JavaScript] 'GET ERROR: ', { [TypeError: Network request failed]
line: 29785,
  column: 21,
  sourceURL: 'http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false' }

出于开发人员的目的,我想忽略HTTPS安全性。根据本指南(https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW40),我在Info.plist文件中添加了标记。现在它看起来像这样:

<plist version="1.0">
<dict>
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
    </dict>
    .....

我通过[[[NSBundle mainBundle] infoDictionary] objectForKey:@"NSAppTransportSecurity"]检查了我的更改是否已应用,但我仍然遇到此例外情况。

我也尝试使用NSExceptionDomains

NSIncludesSubdomains
NSExceptionAllowsInsecureHTTPLoads
NSExceptionRequiresForwardSecrecy
NSExceptionMinimumTLSVersion
NSThirdPartyExceptionAllowsInsecureHTTPLoads
NSThirdPartyExceptionMinimumTLSVersion
NSThirdPartyExceptionRequiresForwardSecrecy

使用此键的域名,但它也没有帮助。

我在Xcode 8.3.3的iPad Air iOS 10.3模拟器上运行我的应用程序, 网址上的https适用于TLS 1.2

0 个答案:

没有答案