昨天臨近發(fā)包的時(shí)候,測(cè)試告訴我說微博登錄 一直報(bào) SSL 驗(yàn)證失敗,然后就登錄失敗了,但是微信跟qq都沒有問題。。
一開始以為自己代碼有問題,進(jìn)行代理抓包后(抓包的步驟),iOS10系統(tǒng)又可以正常登錄了,這個(gè)就很奇怪了。。。
iOS10之前的版本都可以正常登錄,代理抓包后也可以正常登錄,那只剩下一個(gè)可能,就是微博自己的HTTPS證書有問題!!!
把微博的請(qǐng)求地址放到瀏覽器中,發(fā)現(xiàn) chrome 也報(bào)警告了。。。
在搜索解決方法的時(shí)候,發(fā)現(xiàn) iOS10 系統(tǒng)對(duì)TLS 1.0 加密的證書,是認(rèn)為無效的,要求加密方式要 TLS 1.2,然后去 weibo 的github 上看看有沒有更新SDK (應(yīng)該早點(diǎn)上去看的。。。后悔),
原來已經(jīng)有人提交了 pull request 來解決這個(gè)問題 別人提交的解決方案
<key>NSThirdPartyExceptionMinimumTLSVersion</key>
<string>TLSv1.0</string>
1.對(duì)傳輸安全的支持
在新一代的iOS系統(tǒng)中,默認(rèn)需要為每次網(wǎng)絡(luò)傳輸建立SSL。解決這個(gè)問題有兩種方法:
A. 建立白名單并添加到你的app的plsit中
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>sina.cn</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSThirdPartyExceptionMinimumTLSVersion</key>
<string>TLSv1.0</string>
</dict>
<key>weibo.cn</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSThirdPartyExceptionMinimumTLSVersion</key>
<string>TLSv1.0</string>
</dict>
<key>weibo.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSThirdPartyExceptionMinimumTLSVersion</key>
<string>TLSv1.0</string>
</dict>
<key>sinaimg.cn</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSThirdPartyExceptionMinimumTLSVersion</key>
<string>TLSv1.0</string>
</dict>
<key>sinajs.cn</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSThirdPartyExceptionMinimumTLSVersion</key>
<string>TLSv1.0</string>
</dict>
<key>sina.com.cn</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSThirdPartyExceptionMinimumTLSVersion</key>
<string>TLSv1.0</string>
</dict>
</dict>
</dict>
如果沒有添加可能會(huì)遇到"An SSL error has occurred and a secure connection to
the server cannot be made."這樣的問題。
B. 移除 NSAppTransportSecurity 中的其他設(shè)置,只留下 NSAllowsArbitraryLoads,2017年蘋果將會(huì)拒絕使用該方式的應(yīng)用。
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
2. 等待微博升級(jí) HTTPS 證書,采用 TLSv1.2 加密方式 (遙遙無期)
美柚公司內(nèi)推,有需要可以私信我: