App Transport Security policy requires the use of a secure connection - IOS 9(应用程序传输安全策略需要使用安全连接 - IOS 9)
问题描述
我在使用 IP 地址连接到 API 时遇到问题.即使我将以下代码添加到 plist 中,它仍然显示如下错误:
"
或禁用 ATS:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist 版本="1.0"><字典>...<key>NSAppTransportSecurity</key><字典><!--包括允许所有连接(DANGER)--><key>NSAllowsArbitraryLoads</key><真的/></dict></dict></plist>
编辑 Infor.plist 文件后如下所示:
I'm facing problem connection to API with using IP address. Even I had add the following code to plist, it still show error as below:
"http://xx3.xx.xx8.xx7/xxx/xxx/ error: The resource could not be loaded because the App Transport Security policy requires the use of a secure connection."
This is the code I add to the plist
<key>xx3.xx.xx8.xx7</key>
<dict>
<key>NSThirdPartyExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</key>
Document Allowing Insecure Connection to a Single Server here. So you must add NSAppTransportSecurity
to your info.plist file in truth way like flowing (to show Info.plist in source, in Xcode right click to Info.plist "Open As"->"Source Code")
To configure a per-domain exception:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!--others key-->
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>insecure-domain1.example.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.0</string>
</dict>
<key>insecure-domain2.example.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.0</string>
</dict>
</dict>
</dict>
<!--others key-->
</dict>
</plist>
after edit Infor.plist file look like following:
Or disable ATS:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
...
<key>NSAppTransportSecurity</key>
<dict>
<!--Include to allow all connections (DANGER)-->
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
</dict>
</plist>
after edit Infor.plist file look like following:
这篇关于应用程序传输安全策略需要使用安全连接 - IOS 9的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:应用程序传输安全策略需要使用安全连接 - IOS 9
基础教程推荐
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01