gpt4 book ai didi

ios - 如果 https 服务器使用不安全的 SSL 证书托管,则限制 Web 服务调用

转载 作者:太空宇宙 更新时间:2023-11-03 13:32:45 25 4
gpt4 key购买 nike

一个 https 服务器托管了一个不安全的 SSL 证书,但如果我尝试使用 NSURLSession 从 iOS 进行 Web 服务调用,则同一服务器返回成功消息( http 状态代码 200) 和一个警告,

challenge : <NSURLProtectionSpace: 0x60000000e050>: Host:ucsmv2012.xx.xxxxx.com, Server:https, Auth-Scheme:NSURLAuthenticationMethodServerTrust, Realm:(null), Port:7002, Proxy:NO, Proxy-Type:(null)

如果我尝试在浏览器中访问 URL,我会收到隐私错误消息,

Privacy Error

如果证书不安全,是否有办法限制 API 调用?

最佳答案

您必须在 .plist 文件中的 NSAppTransportSecurity 字典下设置以下键。

<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>testdomain.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<false/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.2</string>
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
<false/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSThirdPartyExceptionMinimumTLSVersion</key>
<string>TLSv1.2</string>
<key>NSRequiresCertificateTransparency</key>
<false/>
</dict>
</dict>
</dict>

关于ios - 如果 https 服务器使用不安全的 SSL 证书托管,则限制 Web 服务调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49637269/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com