【问题标题】:DSSException: Revocation data is missingDSSException:吊销数据丢失
【发布时间】:2019-07-29 09:08:18
【问题描述】:

我正在使用 DSS 签署 Pdf 文档。我需要为这些文档添加时间戳并启用 LTV(启用 PAdES LTV)。

我遇到了一些关于撤销数据的问题。

我对这个领域有点陌生,所以请耐心等待。

我正在按照 DSS 本身提供的说明和演示进行操作,但无济于事。

我已成功使用 PAdES B 和 PAdES T 签署 Pdf,因此我的 TSA 服务设置正确。

我遇到的问题是,每次我尝试使用 LTV 签署 Pdf 时,都会收到以下错误: “eu.europa.esig.dss.DSSException:撤销数据丢失”,我不知道为什么......调用时抛出此异常 “service.signDocument(...)” 并在 Debugging 之后说

"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();
        }
    }

一些次要的辅助方法:

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>

【问题讨论】:

  • 也许是一个愚蠢的问题,但您是否使用自签名证书进行测试? (看到您依赖 PKCS12 密钥库)
  • @veebee 应该指定,我的错。不,我不是,我使用的是有效证书。
  • 好的,您是否尝试直接访问与您的签名证书和 TSA 证书关联的 CRL 和/或 OCSP 响应程序,例如使用卷曲?还有一点:你的 OCSP 数据加载器的内容类型应该是“application/ocsp-request”(尽管我相信 setter 方法没有做任何事情)

标签: java digital-signature pades openpdf


【解决方案1】:

虽然这是一个老问题,但如果有人偶然发现同样的问题: 当使用没有撤销数据的测试 TSA 时,您必须添加 verifier.setCheckRevocationForUntrustedChains(true); 这包含在 dss 示例中 eu.europa.esig.dss.cookbook.example.sign.SignXmlXadesLTTest

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-07-23
    • 2018-01-15
    • 2012-02-22
    • 2011-07-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-16
    相关资源
    最近更新 更多