为了将来参考,我将发布我自己问题的答案(部分至少)
OCSP和CRL检查已经在标准Java实现中实现,并且不需要自定义代码或其他提供程序(BC,..)。默认情况下禁用它们。
为此,您必须至少设置两个参数:
(PKIXParameters or PKIXParameterBuilder) params.setRevocationEnabled(true);Security.setProperty("ocsp.enable", "true");当您尝试验证证书路径(PKIXCertPathValidatorResult.validate())时,这将激活OCSP检查。
如果没有可用的OCSP时要添加CRL的后备检查,请添加其他属性:
System.setProperty("com.sun.security.enableCRLDP", "true");由于我必须支持不同的证书格式(PKCS7,PEM),因此发生了很多问题。我的实现对于PEM来说运行良好,但是由于PKCS7不会将证书的顺序保存在链中,因此会有点困难(http://bugs.sun.com/view_bug.do?bug_id=6238093)
X509CertSelector targetConstraints = new X509CertSelector();targetConstraints.setCertificate(certificates.get(0));// Here's the issue for PKCS7 certificates since they are not ordered,// but I havent figured out how I can see what the target certificate// (lowest level) is in the incoming certificates..PKIXBuilderParameters params = new PKIXBuilderParameters(anchors, targetConstraints);
希望这对其他人也有用,也许有人可以阐明如何在无序的PKCS7列表中找到目标证书?



