**关于升级到 HTTPS 的讨论** - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
andyL
0D
V2EX    iDev

**关于升级到 HTTPS 的讨论**

  •  1
     
  •   andyL
    lyleLH 2016-12-13 16:50:40 +08:00 5323 次点击
    这是一个创建于 3228 天前的主题,其中的信息可能已经有所发展或是发生改变。

    背景

    服务端的老大看到 17 年 1 月 1 日 Apple 强制提审的 app 必须是 HTTPS 的安全连接的消息之后就开始准备替换到 HTTPS 环境了,这两天我们在测试环境着手升级。

    服务器端已经部署了 HTTPS 的测试环境

    我的网络基础并不好,只了解一些皮毛, iOS 这边我查了一些博文,获得了一些东拼西凑的知识点,同时发现很多博文的内容本身也是东拼西凑的

    实现

    现在我通过ATS 设置AFN 提供的安全设置

    • AFN 提供的安全设置
     AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; AFSecurityPolicy *securityPolicy = [AFSecurityPolicy defaultPolicy]; securityPolicy.allowInvalidCertificates = YES; [manager setSecurityPolicy:securityPolicy]; 
    • ATS 设置
    <key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> <key>NSExceptionDomains</key> <dict> <key>log.umsns.com</key> <dict> <key>NSIncludesSubdomains</key> <true/> <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key> <true/> <key>NSTemporaryExceptionMinimumTLSVersion</key> <string>TLSv1.1</string> </dict> <key>sns.whalecloud.com</key> <dict> <key>NSIncludesSubdomains</key> <true/> <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key> <true/> <key>NSTemporaryExceptionMinimumTLSVersion</key> <string>TLSv1.1</string> </dict> <key>qq.com</key> <dict> <key>NSIncludesSubdomains</key> <true/> <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key> <true/gt; <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/> </dict> <key>sina.com.cn</key> <dict> <key>NSIncludesSubdomains</key> <true/> <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key> <true/> <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/> </dict> <key>sinaimg.cn</key> <dict> <key>NSIncludesSubdomains</key> <true/> <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key> <true/> <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/> </dict> <key>sinajs.cn</key> <dict> <key>NSIncludesSubdomains</key> <true/> <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key> <true/> <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/> </dict> <key>sina.cn</key> <dict> <key>NSExceptionMinimumTLSVersion</key> <string>TLSv1.0</string> <key>NSIncludesSubdomains</key> <true/> <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/> </dict> <key>weibo.cn</key> <dict> <key>NSExceptionMinimumTLSVersion</key> <string>TLSv1.0</string> <key>NSIncludesSubdomains</key> <true/> <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/> </dict> <key>weibo.com</key> <dict> <key>NSExceptionMinimumTLSVersion</key> <string>TLSv1.0</string> <key>NSIncludesSubdomains</key> <true/> <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key> <true/> <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/> </dict> </dict> 

    结果

    iOS 端能正常发出 HTTPS 请求,测试的时候用 fiddle 和 Charles 等代理软件在不配置证书的情况下无法抓到 HTTPS 请求包内容,配置证书后才能看到明文的请求内容

    问题

    • 请问这样算是成功的升级到 HTTPS 了吗?
    • 如不是的话,满足苹果要求的 HTTPS 请求是什么样的呢?
    第 1 条附言    2016-12-13 17:23:37 +08:00
    • 服务端使用的是腾讯云中申请的证书,免费版,但是属于非自建证书

    • 非自建证书,我本地的工程中没有导入该证书,所以没有和 Trust Object 进行对比的步骤

    • 目前 info.plist 文件中 NSAllowsArbitraryLoads 设置为 NO , HTTPS 请求也是可以成功的.(YES 也可以成功,据说设为 NO 是满足 Apple 要求的,设为 YES 就是允许 HTTP 请求)

    15 条回复    2016-12-21 13:48:16 +08:00
    andyL
        1
    andyL  
    OP
       2016-12-13 17:23:11 +08:00
    - 服务端使用的是腾讯云中申请的证书,免费版,但是属于非自建证书
    - 非自建证书,我本地的工程中没有导入该证书,所以没有和 Trust Object 进行对比的步骤
    - 目前 info.plist 文件中 NSAllowsArbitraryLoads 设置为 NO , HTTPS 请求也是可以成功的.(YES 也可以成功,据说设为 NO 是满足 Apple 要求的,设为 YES 就是允许 HTTP 请求)
    loveuqian
        2
    loveuqian  
       2016-12-13 17:40:20 +08:00
    我记得之前看到一个测试证书能否过 store 检核的测试网站
    好像是腾讯云的
    找不到了
    alex321
        3
    alex321  
       2016-12-13 17:43:49 +08:00   1
    caileijuve
        4
    caileijuve  
       2016-12-13 17:50:56 +08:00
    只要能通过 HTTPS 发送和请求到数据应该就可以了
    alex321
        5
    alex321  
       2016-12-13 17:51:45 +08:00
    @caileijuve 不行, ssl 协议版本有要求的。
    andyL
        6
    andyL  
    OP
       2016-12-13 17:52:06 +08:00
    @alex321 @loveuqian 这个检测我做过了,是通过了的。
    现在就是 iOS 客户端这边 这种做法不知道对不对
    alex321
        7
    alex321  
       2016-12-13 17:54:13 +08:00
    @andyL 等元旦吧。。这东西都是程序处理的,提交的时候如果有问题应该会有提示。
    andyL
        8
    andyL  
    OP
       2016-12-13 17:55:48 +08:00
    @alex321 确实, Apple 的审核标准目前并没有十分明确
    loveuqian
        9
    loveuqian  
       2016-12-13 17:58:10 +08:00
    @andyL
    不着急,我们的图片储存还没转到 HTTPS
    圣诞前再更一版,剩下的就看明年会怎么样了
    andyL
        10
    andyL  
    OP
       2016-12-13 18:02:08 +08:00
    @loveuqian 嗯,我们的图片存储也没有使用 HTTPS ,不过已经在弄了。
    814084764
        11
    814084764  
       2016-12-14 15:37:24 +08:00
    苹果的强迫症又发作了。
    ZernonHuang
        12
    ZernonHuang  
       2016-12-16 00:44:42 +08:00
    直接买一个受苹果信任的证书,客户端基本上不用做修改。
    andyL
        13
    andyL  
    OP
       2016-12-16 10:01:27 +08:00
    @ZernonHuang 是的,客户端只做了我提问中贴出的那些修改,以及 API 的 URL 前缀替换成带 HTTPS 的域名前缀。
    DingSoung
        14
    DingSoung  
       2016-12-20 19:07:27 +08:00
    HTTPS 好说,就是一些第三方 SDK 还得弄,比如微信 QQ 微博分享
    andyL
        15
    andyL  
    OP
       2016-12-21 13:48:16 +08:00
    @dingsoung 这些第三方的 SDK 已经全部更新过了,相信他们会跟进对 HTTPS 的支持的
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     1080 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 29ms UTC 23:09 PVG 07:09 LAX 16:09 JFK 19:09
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86