Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 外部CA证书链验证_Java_Security_Cryptography_Certificate_Bouncycastle - Fatal编程技术网

Java 外部CA证书链验证

Java 外部CA证书链验证,java,security,cryptography,certificate,bouncycastle,Java,Security,Cryptography,Certificate,Bouncycastle,假设有一个外部CA,假设有一个URL和其他配置参数。 在运行时,我获得了需要使用CA进行验证的证书链 因此,链的根证书必须以某种方式在CA中注册。CA还处理CRL,链中的一些证书可能会被吊销 我有这样的代码 CertificateFactory cf = CertificateFactory.getInstance(certificateType); List<Certificate> certx = //list of certificates obtaining //creat

假设有一个外部CA,假设有一个URL和其他配置参数。 在运行时,我获得了需要使用CA进行验证的证书链

因此,链的根证书必须以某种方式在CA中注册。CA还处理CRL,链中的一些证书可能会被吊销

我有这样的代码

CertificateFactory cf = CertificateFactory.getInstance(certificateType);
List<Certificate> certx = //list of certificates obtaining

//creating certification path (chain to be validated)
CertPath path = cf.generateCertPath(certx);
//validator creation. Algorithm to be defined
CertPathValidator validator = CertPathValidator.getInstance(certPathValidatorAlgorithm);

//get key store
KeyStore keystore = getKeyStore(keyStorePassword);
//get list of CRLs (certificate revoke list)
Collection<? extends CRL> crls = getCrls(cf);

PKIXParameters params = new PKIXParameters(keystore);
CertStore store = CertStore.getInstance(certStoreType, new CollectionCertStoreParameters(crls));
params.addCertStore(store);
//Validate will throw an exception on invalid chains.
PKIXCertPathValidatorResult r = (PKIXCertPathValidatorResult) validator.validate(path, params);
r.getTrustAnchor();
CertificateFactory cf=CertificateFactory.getInstance(certificateType);
List certx=//获取证书的列表
//创建证书路径(要验证的链)
CertPath path=cf.generateCertPath(certx);
//验证程序创建。待定义的算法
CertPathValidator validator=CertPathValidator.getInstance(CertPathValidator算法);
//获取密钥存储
keystorekeystore=getKeyStore(keyStorePassword);
//获取CRL列表(证书吊销列表)

从您的代码中收集我不明白您对外部CA的看法。您正在生成新证书吗?如果没有,那么您只需要根CA和下属的证书。为了验证证书,您需要一个新的CRL。通常,它是通过HTTP访问证书扩展名CRLDistributionPoints中指定的URL的。在执行吊销检查的过程中,您没有看到骷髅和交叉骨标志吗?这是一场噩梦。众所周知,程序员会咬断手臂逃避任务。@Egl CA生成证书(有时是链)。我得到链条,需要验证它们。询问CA链是否有效,证书是否都未吊销。@JamesReinstateMonicaPolk它与HTTPS访问无关,与浏览器无关。谢谢,但我从未提到HTTPS和浏览器。首先,信任系统必须有一个锚,在本例中是根CA证书。根据定义,该锚无法在不安全的通道上安全地检索。通常这意味着它是硬编码到系统中的。现在,关于撤销,您需要处理至少3个常用的系统:1)证书中根本没有指定撤销系统,2)指定了URL标识为@egl的基于CRL的系统,以及3)证书中有URL的基于OCSP的系统。我在这里只触及了表面。