简体   繁体   English

使用iOS 8调用Parse.com云功能时出现SSL错误

[英]SSL Error when calling Parse.com cloud functions with iOS 8

I sometimes get an error on iOS 8 when calling CloudCode functions. 在调用CloudCode函数时,我有时会在iOS 8上遇到错误。 It only happens sometimes, and I have no idea why: 它有时只会发生,我不明白为什么:

Error: Error Domain=Parse Code=100 "The operation couldn’t be completed. (Parse error 100.)" UserInfo=0x17ed2150 

{   Code=100, 
    error=Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made."
    UserInfo=0x19d0c750 {
        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?, 
        _kCFStreamErrorCodeKey=-9824, 
        NSErrorFailingURLStringKey=https://api.parse.com/1/functions/weshread,
        _kCFStreamErrorDomainKey=3, 
        NSUnderlyingError=0x19de4f40 "An SSL error has occurred and a secure connection to the server cannot be made.", 
        NSErrorFailingURLKey=https://api.parse.com/1/functions/weshread
    }
    ...
}

As Jack Cox pointed out Parse's TLS isn't up to snuff. 正如杰克考克斯所指出的那样,Parse的TLS不能满足要求。 But you just need to add an exception for the api.parse.com domain, and the exception only needs to accept the less secure ciphers. 但是你只需要为api.parse.com域添加一个例外,而异常只需要接受安全性较低的密码。 See this Tech Note from Apple about App Transport Security. 请参阅Apple关于App Transport Security的技术说明

Here's what needs to be added to your Info.plist : 以下是需要添加到Info.plist

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSExceptionDomains</key>
    <dict>
        <key>api.parse.com</key>
        <dict>
            <key>NSExceptionRequiresForwardSecrecy</key>
            <false/>
        </dict>
    </dict>
</dict>

UPDATE: Parse sent out an email yesterday saying they'd be updating their certs on 8/11/2015, which should get rid of the need for this. 更新: Parse昨天发出一封电子邮件说他们将在2015年8月8日更新他们的证书,这应该摆脱对此的需求。 I'll update my answer when that has happened. 当发生这种情况时,我会更新我的答案。

It appears that the Analytics servers do not support TLSv2 yet. 看来,Analytics服务器尚不支持TLSv2。 To temporarily work around this you need tell the iOS 9 app that it should do insecure connections. 要暂时解决此问题,您需要告诉iOS 9应用程序它应该进行不安全的连接。

Add the following entry to the info.plist file for your app: 将以下条目添加到您的应用的info.plist文件中:

<key>NSAppTransportSecurity</key>
<dict>
  <key>NSAllowsArbitraryLoads</key>
  <true/>
</dict>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM