banner
李大仁博客

李大仁博客

天地虽大,但有一念向善,心存良知,虽凡夫俗子,皆可为圣贤。

[iOS] iOS9.0 關閉系統強制使用HTTPS

iOS9.0 以後出於對請求安全的考量默認將 Foundation.framework 中的 HTTP 請求協議更換為 SSL/TLS,也就是說所有由程序發起的 HTTP 請求默認將請求 HTTPS 的內容,而且在 HTTPS 出現 404 時不會請求 HTTP 的內容,如果你的 APP 原來就使用 HTTPS,基本問題不大,但是如果使用 HTTP 的話,就需要: 1. 修改你的伺服器配置,使它支持 HTTPS 訪問 2. 修改你的 info.plist 配置,讓 APP 能訪問普通的 HTTP 協議網站 否則調試程序時會在 Log 中出現以下提示:

App Transport Security has blocked a cleartext HTTP (http://) resource
load since it is insecure. Temporary exceptions can be configured via
your app's Info.plist file.

修改 info.plist 時,APPLE 也提供了修改方法,在 info.plist 中增加以下內容即可

NSAppTransportSecurity
NSExceptionDomains
lidaren.com
NSIncludesSubdomains
NSTemporaryExceptionAllowsInsecureHTTPLoads
NSTemporaryExceptionMinimumTLSVersion
TLSv1.1

如果你的 app 具有瀏覽器功能,可以這樣改,就可以完全放開 HTTP 訪問功能了

NSAppTransportSecurity

NSAllowsArbitraryLoads

最後附上原文鏈接 https://stackoverflow.com/questions/30720813/cfnetwork-sslhandshake-failed-ios-9

載入中......
此文章數據所有權由區塊鏈加密技術和智能合約保障僅歸創作者所有。