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

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

问题描述

我在我的 iPhone 3G OS 3.0.1 上使用 我的 iPhone 应用程序 没有任何问题.应用程序连接到位于 https://api.serverdensity.com/1.0/ 的 API URL 和所有请求通过它.

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 URL,它会正确加载.

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.

对此有什么建议吗?

推荐答案

我们之前在连接到我们的 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天全站免登陆