[英]Get certificate's revocation time for signature validation in Java
我需要獲取撤銷日期,以便將其與簽名驗證框架中的簽名時間進行比較。 下一個代碼,使用 CertPathValidator java 類,允許我驗證證書鏈,但如果鏈中存在任何證書被撤銷,它會拋出異常。
private boolean validateChain(List<X509Certificate> certificates) {
PKIXParameters params;
CertPath certPath;
CertPathValidator certPathValidator;
Boolean valid = Boolean.FALSE;
params = new PKIXParameters(keyStore);
params.setRevocationEnabled(true);
Security.setProperty("ocsp.enable", "true");
certPath = cf.generateCertPath(certificates);
certPathValidator = CertPathValidator.getInstance("PKIX");
PKIXCertPathValidatorResult result = (PKIXCertPathValidatorResult)
certPathValidator.validate(certPath, params);
if(null != result) {
valid = Boolean.TRUE;
}
return valid;
}
我需要一些方法來檢查鏈中是否有一些證書被撤銷,而不會引發異常並停止驗證過程。 此外,由於最后的代碼不允許,我需要獲取撤銷日期。 我需要一個非專有的解決方案,因為我已經知道 Sun 類 OCSP http://www.docjar.com/html/api/sun/security/provider/certpath/OCSP.java.html
最后我找到了一個解決方法。 可以將確定路徑有效性的日期確定為參數。 我無法恢復每個證書的吊銷日期,但添加了以下行:
params.setDate(signingDate)
此時檢查CertPath的有效性
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.