我需要验证 pdf 文件中的数字签名。
我使用itextpdf
和cryptopro
cryptopro
为所需算法提供这些别名:
, JCP: Signature.GOST3411withGOST3410EL -> ru.CryptoPro.JCP.Sign.GostElSign
aliases: [1.2.643.2.2.3, OID.1.2.643.2.2.3, 1.2.643.2.2.9with1.2.643.2.2.19]
itextpdf
尝试获取“GOST3411withECGOST3410”并失败:“没有这样的算法:提供者 JCP 的 GOST3411withECGOST3410”
这有效:
Provider prov = Security.getProvider(PROVIDER_NAME);
prov.put("Alg.Alias.Signature.GOST3411withECGOST3410", "GOST3411withGOST3410EL");
虽然不确定这是正确的方法。
Exception in thread "main" ExceptionConverter: java.security.NoSuchAlgorithmException: no such algorithm: GOST3411withECGOST3410 for provider JCP
at sun.security.jca.GetInstance.getService(GetInstance.java:70)
at sun.security.jca.GetInstance.getInstance(GetInstance.java:190)
at java.security.Signature.getInstance(Signature.java:324)
at com.itextpdf.text.pdf.security.PdfPKCS7.initSignature(PdfPKCS7.java:692)
at com.itextpdf.text.pdf.security.PdfPKCS7.<init>(PdfPKCS7.java:452)
at com.itextpdf.text.pdf.AcroFields.verifySignature(AcroFields.java:2349)
at org.foo.PdfVerifier.verify(PdfVerifier.java:83)
at org.foo.PdfVerifier.main(PdfVerifier.java:53)