如何通过充气城堡获得x 509证书状态

时间:2014-11-10 12:17:31

标签: java x509certificate bouncycastle

大家好我想通过充气城堡获得x 509证书状态 我遵循以下步骤: -

1)读取用户证书 2)获取用户证书的路径以测试它是好还是被撤销 3)阅读CA证书 4)读取CA证书以连接到ocsp响应者..“); 5)生成OCSP请求 6)OCSP Resonder URL 7)检查错误:

                // check if response code is other than 200 then throw
                // exception
                if (con.getResponseCode() / 100 != 2) {
                    throw new Exception("***Error***");
                }

                // Get Response
                InputStream in = (InputStream) con.getContent();
                OCSPResp ocspResponse = new OCSPResp(in);

                System.out.println(ocspResponse.getStatus());

//这里我们得到所有类型的用户证书的响应代码6,包括撤销证书和良好证书。 有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

状态码6表示响应者不知道请求中的certID。 该代码显示了客户端,中间和根CA证书的一些混淆。 一个好主意是首先确认响应者是否使用OpenSSL。

openssl ocsp -issuer intermediate-ca.pem -cert client.pem -url http://192.168.3.247/ocsp -no_nonce -text

代码中的一个问题似乎是您正在使用GET但未将基本64位编码的请求附加到URI。 缺少的其他东西是验证响应上的签名并检查nonce值。

EJBCA的OCSP测试工具有一个例子: https://svn.cesecore.eu/svn/ejbca/trunk/ejbca/modules/clientToolBox/src/org/ejbca/core/protocol/ocsp/OCSPUnidClient.java