2015-04-02 72 views
6

我在调用CloudCode函数时有时会在iOS 8上发生错误。它只是有时发生,我不知道为什么:我不知道为什么:使用iOS调用Parse.com云功能时出现SSL错误8

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 
    } 
    ... 
} 

回答

0

看来,分析服务器还不支持TLSv2呢。要临时解决此问题,您需要告诉iOS 9应用程序它应该执行不安全的连接。

将以下条目添加到Info.plist文件为您的应用程序:

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

Ack!这是禁用所有的ATS。所有你需要做的就是为“api.parse.com”添加一个异常,NSExceptionRequiresForwardSecrecy设置为false。 – aranasaurus 2015-07-29 23:11:38

+0

同意,这是一个快速和肮脏的工作。最好的选择是游说Parse让TLSv2在他们的API上工作。 – 2015-07-30 00:22:11

+0

我在我的Xcode 7.0/Swift 2.0项目中尝试了NSAllowsArbitraryLoads和NSExceptionRequiresForwardSecrecy;并且在尝试联系Parse.com时仍然出现SSL错误 – 2015-08-07 23:44:27

4

正如杰克·考克斯指出解析的TLS是不及格。但是您只需要为api.parse.com域添加例外,并且该例外只需要接受安全性较低的密码即可。请参阅Apple关于App Transport Security的Tech Note

下面是需要添加到你的Info.plist

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

UPDATE:解析昨日发出一封电子邮件,说他们会在2015年8月11日更新他们的证书,这应该摆脱这需要。发生这种情况时我会更新我的答案。

+0

我们如何使用Alamofire处理此异常? 我试过你的解决方案,但仍然收到异常。 (PS:使用iOS9) – 2015-11-18 12:48:26