同时支持http调用和ATS
Support of http call and ATS at the same time
我正在开发一个应用程序,用户可以在其中输入我的应用程序可以连接的任意 URL。目标服务器可以是 http 或 https。我在我的应用程序中添加了以下值 info.plist.
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
由于上述配置,即使缺少任何安全服务器要求(即 TLS1.2、前向保密等),http 调用和安全服务器也能正常工作。
我想确保我的安全服务器满足 iOS 文档中提到的所有要求,即 TLS1.2、前向保密,如果我的安全服务器缺少任何内容,我的请求将失败。如果我的服务器没有针对 SSL 要求(TLS1.2,前向保密)正确配置,我使用了以下配置并且请求失败。
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<false/>
</dict>
使用上述配置后,我无法连接到 http 服务器。如果未正确配置安全服务器,有什么方法可以连接到 http 服务器并请求失败。
注意:我的应用程序可以连接到用户输入的任何服务器。我无法使用 NSExceptionDomains 配置来指定服务器。
NSExceptionDomains
不仅允许在某些域上设置安全性较低的设置,您还可以将其用于相反的情况,例如像您一样默认允许任意加载,然后添加需要更多的例外安全设置:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>example.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<false/>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.2</string>
<key>NSExceptionRequiresForwardSecrecy</key>
<true/>
</dict>
</dict>
</dict>
我正在开发一个应用程序,用户可以在其中输入我的应用程序可以连接的任意 URL。目标服务器可以是 http 或 https。我在我的应用程序中添加了以下值 info.plist.
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
由于上述配置,即使缺少任何安全服务器要求(即 TLS1.2、前向保密等),http 调用和安全服务器也能正常工作。
我想确保我的安全服务器满足 iOS 文档中提到的所有要求,即 TLS1.2、前向保密,如果我的安全服务器缺少任何内容,我的请求将失败。如果我的服务器没有针对 SSL 要求(TLS1.2,前向保密)正确配置,我使用了以下配置并且请求失败。
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<false/>
</dict>
使用上述配置后,我无法连接到 http 服务器。如果未正确配置安全服务器,有什么方法可以连接到 http 服务器并请求失败。
注意:我的应用程序可以连接到用户输入的任何服务器。我无法使用 NSExceptionDomains 配置来指定服务器。
NSExceptionDomains
不仅允许在某些域上设置安全性较低的设置,您还可以将其用于相反的情况,例如像您一样默认允许任意加载,然后添加需要更多的例外安全设置:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>example.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<false/>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.2</string>
<key>NSExceptionRequiresForwardSecrecy</key>
<true/>
</dict>
</dict>
</dict>