我有一个文件(pdf)签署与1帕迪斯签名和2卡迪斯签名,我需要提取每个签名的签名者的信息。
我使用的是CMSSignedData (弹跳城堡库),但是当我试图获取信息时,我只得到关于最后一个签名的信息。
byte[] buffer = new byte[(int) tmpFile.length()];
DataInputStream dataIn = new DataInputStream(new FileInputStream(tmpFile));
dataIn.readFully(buffer);
dataIn.close();
CMSSignedData signature = new CMSSignedData(buffer);
Store cs = signature.getCertificates();
SignerInformationStore signers = signature.getSignerInfos();
String hashOriginalFile = DigestUtils.sha256Hex(
(byte[])signature.getSignedContent().getContent());
List<SignInfo> certificatesInfo = signers.getSigners().stream()
.map(si -> cs.getMatches(si.getSID()))
.flatMap(Collection::stream)
.map(o -> (X509CertificateHolder) o)
.map(cert -> new SignInfo(hashOriginalFile, getCommonName(cert.getSubject()), cert.getIssuer().toString(), null, null))
.collect(Collectors.toList());有办法获取所有的签名信息吗?甚至使用另一个图书馆。
谢谢!
发布于 2022-03-29 12:58:29
我想说,这取决于文件是如何签署的:
如果以并行方式添加签名(包含相同文档哈希的3个签名),则应该能够使用代码查看签名;如果按顺序添加签名,则应该能够看到签名(原始文档第一次签名,然后再次签名,等等),则应该实现递归方法。
我建议看一看SD-DSS库,它提供了这种功能--参见https://github.com/esig/dss。您可能需要验证签名才能检索到此信息。
https://stackoverflow.com/questions/71047773
复制相似问题