gpt4 book ai didi

java - MakeSignature.signDetached 抛出 IllegalArgumentException

转载 作者:太空宇宙 更新时间:2023-11-04 14:34:16 26 4
gpt4 key购买 nike

同时使用 MakeSignature.signDetached 使用 LUNA HSM 1700 将数字签名应用于 PDF。

请指导我解决此问题。

提前致谢。

方法如下:

public static void Digital_signed(String SRC,String DEST) 
throws IOException, GeneralSecurityException, DocumentException , Exception{
try {
char[] pkcs11PIN = "devicepassword".toCharArray();
Provider p = null;
FileInputStream fis = new FileInputStream(configFileName);
p = new SunPKCS11(fis);
String provide_name =p.getName();
Security.addProvider(p);
KeyStore ks = KeyStore.getInstance("PKCS11","SunPKCS11-Luna");
ks.load(null, pkcs11PIN);
String alias = (String)ks.aliases().nextElement();
PrivateKey pk = (PrivateKey) ks.getKey(alias, pkcs11PIN);
Certificate[] chain = ks.getCertificateChain(alias);
TSAClient tsaClient = null;
for (int i = 0; i < chain.length; i++) {
X509Certificate cert = (X509Certificate)chain[i];
String tsaUrl = CertificateUtil.getTSAURL(cert);
if (tsaUrl != null) {
tsaClient = new TSAClientBouncyCastle(tsaUrl);
break;
}
}

List <CrlClient> crlList = new ArrayList<CrlClient>();

PdfReader reader = new PdfReader(SRC);
FileOutputStream os = new FileOutputStream(DEST);
PdfStamper stamper = PdfStamper.createSignature(reader, os, '\0');
PdfSignatureAppearance appearance = stamper.getSignatureAppearance();
appearance.setVisibleSignature(new Rectangle(700, 820, 760, 780), 1, "sig");
ExternalSignature pks = new PrivateKeySignature(pk, DigestAlgorithms.SHA256, provide_name);
ExternalDigest digest = new BouncyCastleDigest();

MakeSignature.signDetached(appearance, digest, pks, chain, crlList, null, tsaClient, 0, CryptoStandard.CMS);
}
catch(Exception e)
{}
finally{ }
}

错误如下:

java.lang.IllegalArgumentException: The name 'iText? 5.5.0 ?2000-2013 iText Group NV (AGPL-version) (AGPL-version) (AGPL-version) (AGPL-version) (AGPL-version) (AGPL-version) (AGPL-version)' is too long (143 characters).

最佳答案

您使用的 iText 版本中的 Version 类存在问题。我们现在已经同步操作,并且从 iText 5.5.3 开始,问题应该已经消失。如果不是:请告诉我,我们将重新审视该问题。

关于java - MakeSignature.signDetached 抛出 IllegalArgumentException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25786384/

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