问题标签 [secure-transport]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
447 浏览

ios - 如何在不收到警告的情况下将套接字转换为 SSLConnectionRef?

我正在学习如何使用 Apple 的安全传输框架为我的网络实现 TLS,这有点令人困惑。我相信我应该只是将我的套接字 fds 转换为 SSLConnectionRefs,但是当我这样做时会收到警告Cast to 'SSLConnectionRef' (aka 'const void *') from smaller integer type 'int'

我不会在这里丢失任何信息,因为void *大于int,对吗?所以这应该是安全的。我只是担心编译器警告。感谢您的任何建议。

0 投票
1 回答
3419 浏览

ios - 为什么在发送任何 SSL 消息之前我的 SSL 握手失败?

我正在尝试使用 TLS 1.2 和 Apple 的安全传输 API 将 iOS 客户端连接到 OS X 服务器。我让 BSD 套接字通信正常工作,但在用 TLS 包裹它时遇到了很多麻烦。据我从 Wireshark 的输出中可以看出,SSL 握手甚至还没有真正开始,所以我可能在一侧或另一侧错误地设置了 SSL,但我不确定我可能做错了什么.

服务器端:

客户端:

Wireshark 尝试握手的转储:

使用 Wireshark 尝试诊断问题,我什至没有看到任何 SSL 握手消息。我看到 TCP 连接已建立,然后立即关闭,没有长度大于 0 的数据包。我做错了什么?

0 投票
1 回答
3557 浏览

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

我正在尝试使用 TLS 1.2 将我的应用程序连接到服务器。服务器正在使用已由设备上已安装的自签名 CA 证书签名的证书(我将 CA 证书通过电子邮件发送给自己,点击它。现在它显示在“设置”->“常规”->“配置文件”下)。这以前在我的应用程序中工作,但我们已经更改了我们正在使用的 CA 证书,所以我也更新了服务器的证书。现在我遇到 SSL 故障。

我看到的错误errSSLXCertChainInvalid来自我SSLHandshake对客户端的调用。据我所知,服务器证书应该是有效的。openssl verify -CAfile ca-cert.pem server-cert.pem返回OK,并且 ca-cert.pem 是我在设备上安装的同一个 CA 证书。

有任何想法吗?谢谢!

0 投票
1 回答
389 浏览

macos - OS X如何检查证书是签名

有没有办法使用类似于 OpenSSL X509_verify 的 SecureTransport API 检查证书是否由给定的根证书签名?

0 投票
1 回答
1007 浏览

ios - 覆盖 TLS 服务器验证主机名似乎不起作用

我正在尝试将我的应用程序连接到具有错误主机名的服务器证书的开发服务器,但它由受信任的锚证书签名。当我评估服务器信任对象时,它按预期失败。我正在尝试更改服务器主机名的信任评估策略,但这似乎没有帮助。

据我了解,第二次调用 SecTrustEvaluate() 时,它应该返回kSecTrustResultUnspecified. 当我初始化 NSURLConnection 时,我已经使用“devhost”连接到开发服务器challenge.protectionSpace.host == @"devhost"。我在这里做错了什么?

0 投票
2 回答
6009 浏览

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

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

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

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

编辑我们软件的Android版本接受通配符证书就好了,所以我怀疑这里有一些特定于iOS证书处理的东西。Android客户端BrowserCompatHostnameVerifier用于验证证书,据我了解,它执行与SecPolicyCreateSSL浏览器相同的证书检查功能。

0 投票
1 回答
272 浏览

macos - Ensuring full certificate chains are provided to Secure Transport peers

Apple's Secure Transport API defines a function, SSLSetCertificate, of which the certRefs parameter is an array of certificates. The documentation states (emphasis added):

You must place in certRefs[0] a SecIdentityRef object that identifies the leaf certificate and its corresponding private key. Specifying a root certificate is optional; if it’s not specified, the root certificate that verifies the certificate chain specified here must be present in the system wide set of trusted anchor certificates.

Whilst it says "the root certificate…must be present", it's not clear whether trust chains so found will actually be provided to the SSL peer (albeit it's difficult to think of any other reason for that requirement to exist).

  1. How does one ensure that the full certificate chain (back to a self-signed root, or else a system trust anchor) is provided to the peer?

  2. In particular, must all constituent certificates be included in this certRefs parameter (or does that have no bearing)?

Background

This question follows an earlier post on ServerFault. Having now RTFS, it's clear that slapd calls SSLSetCertificate with only the host's identity certificate and at no stage attempts to furnish Secure Transport with the certificate chain—perhaps that's okay (because Secure Transport is supposed to sort it all out), but I have a hunch this might be the cause of the problem.

0 投票
0 回答
70 浏览

https - SSLRead 挂起,然后返回读取的零字节

我正在使用 SecureTransport 通过 HTTPS 与 Google Places API 进行通信。但是,当我读取响应时,在它中间的某个地方,SSLRead 例程首先挂起几分钟,然后它返回读取的字节为零,从而使我得到一个不完整的响应。会是什么呢?

0 投票
3 回答
2366 浏览

ios - Swift 中的 BSD 套接字应该如何使用安全传输 TLS?

我正在尝试使用 Swift将安全传输与 BSD 套接字一起使用。看起来它应该足够简单,但我无法让它工作,而且关于这个主题的文档很少。

我将我的问题归结为一个简单的“Socket”类,我(据我所知)在其中满足了安全传输的要求。

我通过制作一个简单的实例测试了非 TLS 套接字通信:

并使用 netcat 在目标机器上运行 echo 服务器。这工作正常。

尝试在安全传输的 TLS 中包装套接字(调用 makeSecure() 方法)在调用 SSLHandshake(...) 时崩溃,并出现 EXC_BAD_ADDRESS(code=2, address=...) 错误。有人对我在这里缺少什么有任何指示吗?

编辑

我可以看到控制台输出:

编辑 2

我让它在 Xcode 7 beta 中与 Swift 2 一起工作。见下文。

0 投票
0 回答
117 浏览

ios - iOS ATS:这个错误是因为App还是服务器?

我从我的应用程序中收到以下错误。

NSURLSession/NSURLConnection HTTP 加载失败 (kCFStreamErrorDomainSSL, -9802)

我知道这很可能是因为我的服务器没有 Apple 想要的推荐安全性。但是,在要求我的 Web 开发人员更新后端的安全性之前,我想确定一下?

我检查了可以在这里查看的安全传输类http://www.opensource.apple.com/source/libsecurity_ssl/libsecurity_ssl-36800/lib/SecureTransport.h

它说由于致命警报,您将收到错误代码-9802。老实说,这很模糊。如果这不是我的错,我会给我的 Web 开发人员 Apple 的官方检查清单。这个错误是我造成的还是后端安全性没有按照 Apple 的建议进行更新?

编辑:这似乎是一个 ATS 问题。
当我在 info plist 中添加 NSAppTransportSecurity 字典并将 NSAllowsArbitaryLoads 设置为 YES 时,问题不再出现。