Chrome下数字签名小程序的替代方案 [英] Alternative for digital signing applet under Chrome

查看:21
本文介绍了Chrome下数字签名小程序的替代方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我们已经开发了一个系统,可以使用 Java 小程序对文档进行数字签名.然而,由于 chrome 下小程序的禁令,我们正在寻找数字签名的替代解决方案.

At the moment we have developed a system that can digitally sign documents using a java applet. However with the ban of applets under chrome we are looking for an alternative solution for digital signing.

目前签署的方式如下:

  1. 一个 HTTP GET 被发送到一个 servlet 以获取将要访问的文档签署;
  2. 小程序启动,数字签名驱动程序从文件系统中提取出来,用户输入 PIN;
  3. 小程序获取认证链,检查 CRL/OSCP 并签署文件;
  4. 小程序将带有已签名文件的多部分帖子发送到系统中的 servlet.

另一种解决方案是在浏览器中导入证书并使用 js 进行签名.但这不会是一个用户友好的解决方案.

One alternative solution would be to import the certificate in the browser and use js to do the signing. But that won't be an user friendly solution.

另一种解决方案可能是要求用户下载一个使用 JNLP 运行的程序,该程序下载并签署文档并使用 HTTP 多部分 POST 自动上传它.这种方法的缺点是它需要额外的用户交互(下载操作)并且我们会丢失浏览器 http 会话,因此我们必须再次进行身份验证.

Another solution could be to ask the user to download a run a program using JNLP that downloads and signs the document and automatically uploads it using HTTP multipart POST. The drawback of this approach would be it requires additional user interactions (the download action) and we lose browser http session, so we have to authenticate again.

哪个更可行?你能想到替代方案吗?

Which is more viable? Can you think of alternative?

推荐答案

以下所有帖子均建议基于 RSA 的签名.

您可以使用纯 Javascript+ Web Crypto api 对其进行签名.

You may sign it in pure Javascript+ Web Crypto api.

关键点是使用 HTML5 标签提取密钥,使用 forge js 库来处理密钥和散列,并使用 deoxxa 规范 xml 并使用网络加密进行签名/verify(此外,forge 也可以签名/验证,但网络加密速度更快).

Key points is extracting key with HTML5 <file> tag, use forge js library to deal with keys and hashes and canonize xml with deoxxa and use web crypto for sign/verify (in addition, forge also may sign/verify but web crypto is faster).

如果您使用独家规范化对 xmls 进行签名,请使用 deoxxa(您应该在使用前浏览它).如果您签署 xml 并需要进行包容性规范化,请使用 我的 deoxxa 分支(托管在自己的 gitlab 服务器上).我懒得将exclusive重命名为inclusive,但我的.js文件执行inclusive,相信我)用法示例forge+deoxxa+html5_p12_file_read insignJs、verifyJs文件.

If you are signing xmls with exclusive canonicalization, use deoxxa (you should browserify it before using). If you sign xml and need to do inclusive canonicalization use my fork of deoxxa (hosted on own gitlab server). I was too lazy to rename exclusive to inclusive but my .js file performs inclusive, believe me) Example of usage forge+deoxxa+html5_p12_file_read in signJs, verifyJs files.

此外,forge 支持对二进制文件(CMS 或旧命名风格 PKCS#7)进行签名,但我的 JSP 文件没有这样的例子.关于 JS 中的 OCSP 和链测试 - 我在伪造中打开了问题,但似乎也是难以在 JS 中处理 CRL/OCSP 和 TSP 协议,这就是为什么您可以登录 JS,但验证可能会被拆分 - 在 JS 中进行哈希检查(伪造用法和附加代码显示在我的 JSP 中)但智能检查如 CRL、链等在您的 Web 服务中执行 - 您可以提取 X509Certificate 并将其发送到您的 Web 服务,然后使用 bouncycastle 或任何其他很酷的库进行智能检查.X509Certificate 无论如何都是公共信息,将其发送到服务没有问题,但是摘要检查需要文件,您可能不想将文件发送到服务,因此使用伪造来检查我的 verifyJS 文件中显示的摘要.

Also, forge supports signing binary files (CMS or in older naming style PKCS#7) but my JSP files doesn't have such example. About OCSP and chain test in JS - I opened the issue in forge, but it seems too difficult to handle CRL/OCSP and TSP protocols in JS, that's why you may sign in JS, but verify may be splitted - hash checking doing in JS(forge usage and additional code showed in my JSP) but smart checks like CRL, chain e.t.c do in your web service - you may extract X509Certificate and send it to your web service and use bouncycastle or any other cool library to do smart checks. X509Certificate is anyway public info, no problem in sending it to service, but digest checking requires files and you may not want to send files to service and thus use forge for checking digest which is showed in my verifyJS file.

我的 JS 代码没有重构,甚至没有在 OOP 中进行,目前我没有在该项目上工作,但在某个阶段,我已经完全使用文件系统中的 p12 密钥进行了 xml RSA 签名.

My JS code is not refactored and even not in OOP and currently I'm not working on that project but on some stage I had fully working xml RSA siging with p12 keys in file system.

我的 repo 中的最新 JSP 仅使用 forge 来解析 p12 文件并将它们中的密钥提供给 Web Crypto API,但我的 repo 历史也有纯 Javascript 签名/验证(如果你不喜欢 web 加密 api).查看项目分支的历史.

这篇关于Chrome下数字签名小程序的替代方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆