iText 使用存储在 HSM 机器中的不可导出证书对 Pdf 进行数字签名

iText Digitally Sign Pdf with an un-exportable certificate stored within HSM machine

我看到了示例代码 C4_01_SignWithPKCS11HSM.java and C4_02_SignWithPKCS11USB.java 他们都使用 java 1.8 附带的 SunPKCS11 提供程序(我错了吗?)。

那么,在 1.8 之前要做什么?我尝试将 sun 库放入 java 1.7 安装,但它当然很生气,说 class 文件格式不兼容。

实际上,您提到的示例是为 Java 7 编写的。获取为这些示例编写的 free ebook,您将阅读:

if you need to upgrade to make this example work on your OS, you may want to avoid the 64-bit version of Java 7, and opt for the 32-bit version. The SunPKCS11 provider is missing in the 64-bit version of Java 6 as well as Java 7. We’ll need that provider in the next chapter. There’s no ETA as to when Oracle will fix this problem.

那是3年前写的。您可能想查看该指控的当前状态。

如您所知,sun 包中的所有 类,例如 sun.security.pkcs11.SunPKCS11 都不受 Oracle 的真正支持。阅读 It is a bad practice to use Sun's proprietary Java classes?

的答案