gpt4 book ai didi

iOS - 如何将服务器证书获取到 iOS 客户端钥匙串(keychain)中以进行固定

转载 作者:行者123 更新时间:2023-11-29 11:45:58 26 4
gpt4 key购买 nike

TL;DR 版本:是否有任何方法可以将服务器证书传递给 iOS 客户端,同时不涉及传递服务器的私钥?

我编写了一个与我的 macOS 服务器应用程序通信的 iOS 客户端应用程序(因此我可以控制两端)。我已经使用自签名证书实现了证书锁定,以提高安全性。为了在开发过程中实现这一点,我将服务器证书硬编码到 iOS 客户端应用程序中,并告诉客户端仅连接到在 TLS 握手期间为您提供确切证书的服务器。一切都很好。

但是在现实世界中,我将这个系统作为一个集合(一台服务器,每个客户有多个客户端)出售,所以我不能将服务器证书硬编码到 iOS 客户端中。我的计划是将服务器证书带外(通过电子邮件)发送到 iOS 客户端,如下所述:Making Certificates and Keys Available To Your App:

Apps can only access keychain items in their own keychain access groups.

To use digital identities in your own apps, you will need to write code to import them. This typically means reading in a PKCS#12-formatted blob and then importing the contents of the blob into the app's keychain using the function SecPKCS12Import

One way to provision an identity is via email. When you provision a device, send the associated user an email with their client identity attached as a PKCS#12 file.

我的问题是 .p12 文件包含证书 服务器的私钥 - 传递私钥似乎也是错误的。

有没有其他方法可以将服务器证书传递给 iOS 客户端,同时不涉及传递服务器的私钥?

谢谢!!!

最佳答案

我在这里想太多了,解决方案实际上很简单。

我只需要使用 cert.myCustomExt1234 等自定义扩展将服务器的公共(public)证书带外通过电子邮件发送到客户端设备。这是因为 .crt 扩展名已被 iOS 占用,因此您必须注册您的应用程序才能处理自定义扩展名 (see apple docs here) .然后在我的应用程序中,我可以使用带外交付的服务器公共(public)证书执行证书固定的所有逻辑。

关键是将文件扩展名更改为 iOS 尚未声明的内容。

关于iOS - 如何将服务器证书获取到 iOS 客户端钥匙串(keychain)中以进行固定,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43865568/

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