【问题标题】:iOS App Transport Security and Instagram Media CDNiOS 应用传输安全和 Instagram 媒体 CDN
【发布时间】:2015-10-24 03:11:24
【问题描述】:

我正在更新我的 iOS 应用程序,该应用程序从 Instagram for iOS v[已编辑] 中提取图像。有一个新功能可以加强网络安全。它妨碍了我使用以下NSError 获取 Instagram:

Description: {
    NSErrorFailingURLKey = "https:/instagram.com/p/52A5mtpurv/media/?size=l";
    NSErrorFailingURLStringKey = "https:/instagram.com/p/52A5mtpurv/media/?size=l";
    NSLocalizedDescription = "An SSL error has occurred and a secure connection to the server cannot be made.";
    NSLocalizedRecoverySuggestion = "Would you like to connect to the server anyway?";
    NSURLErrorFailingURLPeerTrustErrorKey = "<SecTrustRef: 0x17b1ebe0>";
    NSUnderlyingError = "Error Domain=kCFErrorDomainCFNetwork Code=-1200 \"An SSL error has occurred and a secure connection to the server cannot be made.\" UserInfo={NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., _kCFNetworkCFStreamSSLErrorOriginalValue=-9802, _kCFStreamPropertySSLClientCertificateState=0, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, _kCFStreamErrorCodeKey=-9802, kCFStreamPropertySSLPeerTrust=<SecTrustRef: 0x17b1ebe0>, _kCFStreamErrorDomainKey=3, NSErrorFailingURLStringKey=https://igcdn-photos-f-a.akamaihd.net/hphotos-ak-xaf1/t51.2885-15/11375272_1120995804579077_1215796842_n.jpg, NSErrorFailingURLKey=https://igcdn-photos-f-a.akamaihd.net/hphotos-ak-xaf1/t51.2885-15/11375272_1120995804579077_1215796842_n.jpg}";
    "_kCFStreamErrorCodeKey" = "-9802";
    "_kCFStreamErrorDomainKey" = 3;
}

简单的答案是禁用新的安全功能。许多人显然正在采用这种方法。我认为这是不明智的。

阅读上述错误后,很明显 Akamai CDN、akamaihd.net 和 Instagram 正在结合以显示问题。

我在info.plist 中声明了以下异常:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSExceptionDomains</key>
    <dict>
        <key>instagram.com</key>
        <dict>
            <key>NSExceptionAllowInsecureHTTPSLoads</key>
            <true/>
            <key>NSExceptionRequiresForwardSecrecy</key>
            <false/>
            <key>NSExceptionMinimumTLSVersion</key>
            <string>TLSv1.0</string>
            <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
            <true/>
            <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
            <false/>
            <key>NSThirdPartyExceptionMinimumTLSVersion</key>
            <string>TLSv1.0</string>
        </dict>
    </dict>

上述异常并没有起作用。关于如何进行的任何想法?同样,禁用新的安全功能并不能解决处理通过 CDN 运行的公共服务的问题。

【问题讨论】:

    标签: ios instagram-api akamai app-transport-security


    【解决方案1】:

    问题是我的代码中有一个激进的斜线减速器。它将https:// 折叠为https:/。这导致了错误。

    【讨论】:

      【解决方案2】:

      对我来说,这对完美无缺:

              <key>instagram.com</key>
              <dict>
                  <key>NSIncludesSubdomains</key>
                  <true/>
                  <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
                  <false/>
              </dict>
      

      【讨论】:

        猜你喜欢
        • 2015-12-28
        • 2016-02-12
        • 2016-01-17
        • 2016-08-27
        • 2015-12-25
        • 1970-01-01
        • 2016-01-02
        • 1970-01-01
        • 2016-06-07
        相关资源
        最近更新 更多