我正在使用DSS签署Pdf文档。我需要这些文档有时间戳并启用LTV(启用PAdES LTV)。
我遇到了一些关于撤销数据的问题。
我对这个领域有点陌生,所以请容忍我。
我按照DSS本身提供的说明和演示进行操作,但没有效果。
我已经成功地使用PAdES B和PAdES T签署了Pdf,所以我的TSA服务设置正确。
我遇到的问题是,每次我尝试使用LTV签署Pdf时,都会出现以下错误:“eu.europa.esig.dss.dss异常:吊销数据丢失”,我不明白为什么。。。调用“service.signDocument(…)时引发此异常调试之后说
“eu.europa.esig.dss.validation.SignatureValidationContext-找不到证书的吊销数据:(…)”。
这是我的主要签名方法:
public void createSignature(KeyStore ks, Properties props, File inFile, File outFile, String extraName, boolean visible) throws GeneralSecurityException, IOException {
PAdESSignatureParameters params = new PAdESSignatureParameters();
DSSDocument toSignDocument = new FileDocument(inFile);
DSSDocument signedDocument;
try(Pkcs12SignatureToken token = new Pkcs12SignatureToken(
props.getKeystore(), new KeyStore.PasswordProtection(props.getPassword()))) {
List<DSSPrivateKeyEntry> keys = token.getKeys();
params.setDigestAlgorithm(DigestAlgorithm.SHA256);
params.setSigningCertificate(keys.get(0).getCertificate());
params.setCertificateChain(keys.get(0).getCertificateChain());
params.setSignatureLevel(props.signatureProperties().getSignatureLevel());
CertificateVerifier verifier = new CommonCertificateVerifier();
PAdESService service = new PAdESService(verifier);
DataLoader dataLoader = new CommonsDataLoader();
OnlineTSPSource onlineTSPSource;
verifier.setTrustedCertSource(new TrustedListsCertificateSource());
verifier.setCrlSource(onlineCRLSource());
verifier.setOcspSource(ocspSource());
verifier.setDataLoader(dataLoader());
onlineTSPSource = new OnlineTSPSource(TSA_URL);
onlineTSPSource.setDataLoader(new CommonsDataLoader("application/timestamp-query"));
onlineTSPSource.setPolicyOid(POLICY_ID);
service.setTspSource(onlineTSPSource);
ToBeSigned dataToSign = service.getDataToSign(toSignDocument, params);
DigestAlgorithm digestAlgorithm = params.getDigestAlgorithm();
SignatureValue signValue = token.sign(dataToSign, digestAlgorithm, keys.get(0));
signedDocument = service.signDocument(toSignDocument, params, signValue);
signedDocument.save(outFile.getCanonicalPath());
} catch (IOException e) {
e.printStackTrace();
}
}
一些辅助方法:
java prettyprint-override">private OnlineCRLSource onlineCRLSource() {
OnlineCRLSource onlineCRLSource = new OnlineCRLSource();
onlineCRLSource.setDataLoader(dataLoader());
return onlineCRLSource;
}
private OnlineOCSPSource ocspSource() {
OnlineOCSPSource onlineOCSPSource = new OnlineOCSPSource();
onlineOCSPSource.setDataLoader(ocspDataLoader());
return onlineOCSPSource;
}
private OCSPDataLoader ocspDataLoader() {
OCSPDataLoader ocspDataLoader = new OCSPDataLoader();
ocspDataLoader.setContentType("application/ocsp-response");
ocspDataLoader.setProxyConfig(null);
return ocspDataLoader;
}
private CommonsDataLoader dataLoader() {
CommonsDataLoader dataLoader = new CommonsDataLoader();
dataLoader.setProxyConfig(null);
return dataLoader;
}
相关Maven依赖项:
<dependency>
<groupId>com.github.librepdf</groupId>
<artifactId>openpdf</artifactId>
<version>1.2.21</version>
</dependency>
<dependency>
<groupId>org.digidoc4j.dss</groupId>
<artifactId>dss-pades-openpdf</artifactId>
<version>5.4.d4j.1</version>
</dependency>
<dependency>
<groupId>org.digidoc4j</groupId>
<artifactId>digidoc4j</artifactId>
<version>3.2.0</version>
</dependency>
虽然这是一个老问题,以防有人在同样的问题上绊倒:当使用测试TSA时,在没有撤销数据的情况下,您必须添加verifier.setCheckRevocationForUnTrust dChains(true);
这包含在dss示例中eu.europa.esig.dss.cookbook.example.sign.SignXmlXadesLTTest
目前只有 刷卡支付 有此功能。 调用支付接口后请勿立即调用撤销订单API,建议支付后至少15s后再调用撤销订单接口。 通过内部订单号撤销订单 $app->reverse->byOutTradeNumber("商户系统内部的订单号(out_trade_no)"); 通过微信订单号撤销订单 $app->reverse->byTransactionId("微信的订单号(transaction_id)"
说明 微信支付撤销订单SDK。 官方文档:https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_11&index=3 类 请求参数类 请求参数 类名:\Yurun\PaySDK\Weixin\Reverse\Request 属性 名称 类型 说明 $_apiMethod string 接口名称 $transaction_id s
说明 统一收单交易撤销接口SDK。 官方文档:https://docs.open.alipay.com/api_1/alipay.trade.cancel/ 类 请求参数类 请求参数 类名:\Yurun\PaySDK\AlipayApp\Params\Cancel\Request 属性 名称 类型 说明 $method string 接口名称 $app_auth_token string 详见:h
撤销是 Git 提供的一个非常优秀的功能,它可以允许你撤消刚刚所做的操作。这就意味着你不必害怕搞砸你正在工作的项目: Git 一直会让你的项目处于一个安全的状态。 修改最后一次提交 无论你如何精心地推敲你的提交,你总是有可能出错的。比如忘记了把一个改动过的文件添加到提交中,或者是输入了错误的提交注释等等。当你认为提交有问题时,你都可以使用 “git commit” 命令,并附带上 “--amend
通过使用 DROP 语句,可以轻松地删除索引、表和数据库。 DROP INDEX 语句 DROP INDEX 语句用于删除表中的索引。 用于 MS Access 的 DROP INDEX 语法:DROP INDEX index_name ON table_name 用于 MS SQL Server 的 DROP INDEX 语法:DROP INDEX table_name.index_name 用
使用 Vim 编辑文件内容时,经常会有如下 2 种需求: 对文件内容做了修改之后,却发现整个修改过程是错误或者没有必要的,想将文件恢复到修改之前的样子。 将文件内容恢复之后,经过仔细考虑,又感觉还是刚才修改过的内容更好,想撤销之前做的恢复操作。 基于这 2 种需求,Vim 编辑器提供了撤销和恢复撤销的命令,如表 1 所示。 表 1 Linux Vim 撤销和恢复撤销快捷键 快捷键 功能 u(小写)