“服务器证书不可信任” iPhone应用程序中的错误 [英] "Server certificate untrusted" error in iPhone application

查看:393
本文介绍了“服务器证书不可信任” iPhone应用程序中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在iPhone 3G OS 3.0.1上使用我的iPhone应用程序,没有任何问题。该应用程序通过 https://api.serverdensity.com/1.0/ 连接到API网址请求通过它。

I am using my iPhone application on my iPhone 3G OS 3.0.1 without any problems. The application connects to an API URL at https://api.serverdensity.com/1.0/ and all requests go through it.

该应用程序的用户报告他们现在突然收到错误不受信任的服务器证书。没有其他用户遇到此问题(我知道)并且我无法重现它。

A user of the app has reported that they are now suddenly getting an error "untrusted server certificate". No other users are experiencing this issue (that I'm aware of) and I cannot reproduce it.

SSL证书是* .serverdensity.com上的通配符证书。它是从GoDaddy购买的,有效期至2010年5月。

The SSL certificate is a wildcard certificate on *.serverdensity.com. It is purchased from GoDaddy and is valid until May 2010.

此外,用户正在运行OS 3.0.1,在设备上正确设置时间/日期,如果他访问了Safari中的API网址,它正确加载。

Further, the user is running OS 3.0.1, the time/date are set correctly on the device and if he visits the API URL in Safari, it loads up correctly.

有关此原因的任何建议吗?

Any suggestions for the cause of this?

推荐答案

我们以前在连接到我们的API时使用基本HTTP AUTH的硬编码身份验证方法:

We were previously using a "hardcoded" method of authentication using basic HTTP AUTH when connecting to our API:

NSString *requestURL = [NSString stringWithFormat:@"https://%@:%@@api.serverdensity.com/1.0/?account=%@.serverdensity.com&c=%@", username, password, account, command];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:requestURL] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];

但在我们的最新更新中切换为使用正确方法:

but switched to using a "proper" method in our latest update:

NSString *requestURL = [NSString stringWithFormat:@"https://api.serverdensity.com/1.0/?account=%@.serverdensity.com&c=%@", account, command];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:requestURL] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60.0];

使用 NSURLCredential 以正确处理HTTP身份验证。在此更新之后,相关用户的证书错误消失。

using NSURLCredential to correctly handle the HTTP authentication. Following this update, the certificate error disappeared for the user concerned.

这篇关于“服务器证书不可信任” iPhone应用程序中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆