在浏览器中生成客户端证书并在服务器上签名

发布于 2025-01-03 07:21:25 字数 470 浏览 1 评论 0原文

是否可以在浏览器中请求生成客户端密钥对并将公钥发送到服务器 CA 进行透明签名?然后在用户的浏览器中安装签名的证书?

场景:

  1. 用户打开 https://examle.com/ 网页,服务器身份已验证
  2. 用户请求创建帐户
  3. 密钥对在用户的浏览器中生成,并且不向服务器/CA透露
  4. 公钥发送到服务器进行签名
  5. 服务器对密钥进行签名并生成证书
  6. 证书发送到客户端并与私钥一起安装在浏览器中

下次客户端连接到服务器时,将根据客户端证书验证其身份。

如果服务器可以强制/提示客户端使用密码加密来保护其私钥,那就太好了。

我见过在线银行使用 java applet 来完成此任务。是否可以使用本机浏览器功能来做到这一点? Apache/PHP 或 Node.js 解决方案将受到欢迎。

Is it possible to request generation of client keypair in browser and send the public key to the server CA to be signed transparently? Then installing the signed certificate in user's browser?

Scenario:

  1. User opens https://examle.com/ web page, server identity is verified
  2. User requests an account creation
  3. Keypair is generated in user's browser and not revealed to server/CA
  4. Pubkey is send to server for signing
  5. Server signes the key and generates certificate
  6. Certificate is sent to client and installed in browser along with private key

Next time client connects to server, his identity is verified based on client certificate.

It would be nice if server could force/hint the client to protect his private key using password encryption.

I've seen online banking using java applet for this task. Is it possible to do it using native browser capabilites? Apache/PHP or Node.js solution would be welcome.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

自在安然 2025-01-10 07:21:25

是的,这是可能的。但没有跨浏览器的解决方案。

  • 对于 Internet Explorer,您必须使用 X509Enrollment.CX509EnrollmentWebClassFactoryCEnroll.CEnroll 等 ActiveX 控件,具体取决于它是在 Windows XP 还是 Vista/7 上运行。这将生成 PKCS#10 证书请求(您可能需要将其包含在传统分隔符之间。
  • 其余的,您应该能够使用 标记。这是一个旧版Netscape 标签,以前不是正式的 HTML,但它已成为 HTML 5(尽管 MS 表示他们不会在其实现中支持它),这将生成一个 SPKAC 结构(类似于
  • Firefox 的 ),您可以使用 CRMF 函数

CSR)。 (尽管它支持注册机 //github.com/harbulot/webidrepository/blob/master/core/src/main/resources/uk/ac/manchester/rcs/bruno/webidrepository/htdocs/crosskeygen.js" rel="noreferrer">这里是一个示例脚本,它应该为 ActiveX 或 Keygen 完成大部分工作。

当服务器返回证书时(可能稍后),浏览器应将其导入到其存储中并关联。它带有在请求时生成的私钥。

如何保护私钥将取决于浏览器或底层证书存储机制。例如,在 Firefox 中,安全设备上应该有一个主密码。

在服务器端,您可以使用各种工具实现自己的CA。 OpenSSL 和 BouncyCastle 可以处理 PKCS#10 和 SPKAC。这是 基于 BouncyCastle 的示例(与上面的脚本相关),以及 CRMF 的一些代码

如果您想要现成的解决方案,您可能会对 OpenCA 感兴趣。

Yes, it's possible. There are no cross-browser solutions, though.

  • For Internet Explorer, you will have to use some ActiveX controls using X509Enrollment.CX509EnrollmentWebClassFactory or CEnroll.CEnroll, depending on whether it's running on Windows XP or Vista/7. This will generate a PKCS#10 certificate request (which you may need to wrap between the traditional delimiters.
  • For the rest, you should be able to use the <keygen /> tag. It's a legacy Netscape tag, not officially HTML before, but it has made it into HTML 5 (although MS have said they wouldn't support it in their implementations). This will generate a SPKAC structure (similar to a CSR).
  • For Firefox (although it supports keygen), you can use the CRMF functions.

Here is an example script that should do most of the work for ActiveX or Keygen.

When the server sends a certificate in return (possibly later), the browser should import it into its store and associate it with the private key it had generated at the time of the request.

How the private key is protected will depend on the browser or underlying certificate store mechanism. In Firefox, there should be a master password on the security device, for example.

On the server side, you can implement your own CA using various tools. OpenSSL and BouncyCastle can handle PKCS#10 and SPKAC. Here is a BouncyCastle-based example (associated with the script above), and some code for CRMF.

If you want a ready-made solution, you may be interested in something like OpenCA.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文