【问题标题】:Task <E94BEE4D-E88B-4827-BE0A-E5CF1FE35F5C>.<0> HTTP load failed, 0/0 bytes (error code: -1200 [3:-9858])任务 <E94BEE4D-E88B-4827-BE0A-E5CF1FE35F5C>.<0> HTTP 加载失败,0/0 字节(错误代码:-1200 [3:-9858])
【发布时间】:2021-02-09 09:11:25
【问题描述】:

我正在我的应用程序中使用上传图片的功能。应用程序使用 SOAP 请求将图像发送到服务器。最近我将网址从 http 设置为 https,我遇到了这个问题,

任务。 HTTP 加载失败,0/0 字节(错误代码:-1200 [3:-9858])

NSURLConnection 完成错误 - 代码 -1200

我已经尝试了 info.plist 中的所有更改,但它不起作用。请你帮助我好吗? 谢谢

【问题讨论】:

  • 您是否 100% 确定证书有效?您可以使用浏览器或邮递员访问服务器没有问题还是收到警告?
  • 是的证书是有效的,它适用于具有相同证书的安卓应用程序。是的,我可以使用浏览器访问服务器,我没有收到任何警告。应用中是否需要证书固定或公钥固定?
  • 你必须显示代码...
  • 我已上传代码请检查
  • 嗨 - 我看到你有一个?在网址中。您还需要删除它!

标签: ios objective-c https nsurlconnection


【解决方案1】:

好的,看看这个……

if ([challenge.protectionSpace.authenticationMethod  
isEqualToString:NSURLAuthenticationMethodServerTrust])      
[challenge.sender useCredential:[NSURLCredential    
credentialForTrust:challenge.protectionSpace.serverTrust] 
forAuthenticationChallenge:challenge];

[challenge.sender   
continueWithoutCredentialForAuthenticationChallenge:challenge];

我认为应该是

if ([challenge.protectionSpace.authenticationMethod  
isEqualToString:NSURLAuthenticationMethodServerTrust])      
[challenge.sender useCredential:[NSURLCredential    
credentialForTrust:challenge.protectionSpace.serverTrust] 
forAuthenticationChallenge:challenge];
else // you need to add an else here
[challenge.sender   
continueWithoutCredentialForAuthenticationChallenge:challenge];

编辑

另外,我看到你提供的 URL 为

https://pro-ap.com.au/Mobile/profilepic.asmx?

删除最后一个问号,因为它是请求的一部分,将在构建请求时自动附加。

【讨论】:

  • 没问题,是的,这里的格式可能很困难......我已经删除了那个评论......
猜你喜欢
  • 1970-01-01
  • 2016-02-05
  • 2018-01-06
  • 2016-11-13
  • 2015-09-29
  • 1970-01-01
  • 2015-06-15
  • 2012-12-03
相关资源
最近更新 更多