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


基础教程推荐
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01