“服务器证书不受信任"iPhone应用程序中的错误

quot;Server certificate untrustedquot; error in iPhone application(“服务器证书不受信任iPhone应用程序中的错误)
本文介绍了“服务器证书不受信任"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应用程序中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
java.lang.IllegalStateException: SimpleTypeImpl should not be created for error type(异常:不应为错误类型创建SimpleTypeImpl)
Android IllegalArgumentException: The tag for fragment_XXX is invalid. Received: layout-sw600dp/fragment_XXX_0(Android IlLegalArgumentException:Fragment_XXX的标签无效。收到:Layout-sw600dp/Fragment_XXX_0)
iOS convert audio sample rate from 16 kHz to 8 kHz(IOS将音频采样率从16 kHz转换为8 kHz)
Enforcing an audio sampling rate in iOS(在iOS中强制音频采样率)
HTTPS request using volley(使用 volley 的 HTTPS 请求)