gpt4 book ai didi

ios - 为什么我的服务器的通配符 SSL 证书被拒绝?

转载 作者:可可西里 更新时间:2023-11-01 05:40:53 32 4
gpt4 key购买 nike

我正在使用 NSURLConnection 连接到带有通配符 TLS 证书(如“*.domain.com”)的服务器,当我在我的代码中调用 SecTrustEvaluate NSURLConnectionDelegate-connection:willSendRequestForAuthenticationChallenge: 方法,证书被拒绝为无效。接受具有完全指定的 TLS 证书(如“server2.domain.com”)的另一台服务器。两个证书均由同一个 CA 颁发,我已将 CA 证书添加到我的设备的受信任证书列表中。

我在我的 iPhone/iOS 8.1 上看到 Safari 的相同行为。具有通配符证书的服务器被报告为具有不受信任的证书,而另一台服务器工作正常。所以看起来 iOS 的默认证书验证拒绝通配符证书。是这样吗?

有没有办法告诉 SecEvaluateTrust 允许通配符证书?这是我的 -connection:willSendRequestForAuthenticationChallenge:

的摘录
- (void)connection:(NSURLConnection *)connection
willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
if ([challenge.protectionSpace.authenticationMethod
isEqualToString:NSURLAuthenticationMethodServerTrust]) {
SecTrustRef trust = [challenge.protectionSpace serverTrust];
SecTrustResultType trustResult;
OSStatus status = SecTrustEvaluate(trust, &trustResult);
if (status == noErr) {
if (trustResult == kSecTrustResultProceed
|| trustResult == kSecTrustResultUnspecified) {
// Success. server2 gets here
} else {
// Server authentication failure. server1 gets here
}
}
}
}

编辑 我们软件的 Android 版本可以很好地接受通配符证书,所以我怀疑这里发生了一些特定于 iOS 证书处理的事情。 Android 客户端正在使用 BrowserCompatHostnameVerifier验证证书,据我所知执行与 SecPolicyCreateSSL 相同的功能 — 执行与浏览器相同的证书检查。

最佳答案

由于您在 Safari 中也看到了相同的行为,这可能是证书问题或您期望证书匹配的问题。请检查(或发布)证书的详细信息以及您如何访问它。示例:仅包含 *.example.com 条目的证书将匹配 foo.example.com,但不匹配 example.combar.foo.example.com。此外,有关名称的任何信息都应位于 SAN 部分(主题备用名称),为此不推荐使用通用名称。

关于ios - 为什么我的服务器的通配符 SSL 证书被拒绝?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26492693/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com