最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - Does OCSP Responder Certificate require digitalSignature key usage? - Stack Overflow

programmeradmin2浏览0评论

I want to verify X.509 Certificates (if they were revoked) using the OCSP Protocol and Java/Kotlin.

As this is a non trivial task I use Java Security together with the Bouncy Castle Crypto lib.

When I run the validation a error is thrown indicating that the certificate which comes back as response from the OCSP Responder is not valid. The problem seems to be that the value for DigitalSignature keyUsage within the certificate is set to false but true is expected.

I try to find evidence of this is a requirement according to RFC. But I did Not found anything about this.

Can you help me with this? Is this implementation correct / the OCSP Response invalid?

More Resources: X.509 Certificate / Key Usage: .2.1.3 OCSP: .1 Bouncy Castle:

Kotlin Source code:

/* validate a given cert against the OCSP Responder */
fun checkOCSPStatus(cert: X509Certificate) {
    // 1. load the java keystore that contains all issuer certs 
    val keystoreFile= File("<Filepath to keystore file>")
    val keystorePassword = "<secret>"
    val keystore = KeyStore.getInstance("JKS")
    FileInputStream(keystoreFile).use { fis ->
      keystore.load(fis, keystorePassword.toCharArray())
    }

    // 2. configure to use OCSP check
    Security.setProperty("ocsp.enable", "true")
    Security.setProperty("ocsp.responderURL", "<OCSP Responder URL>")
    val pkixParams = PKIXParameters(keystore)
    pkixParams.isRevocationEnabled = true

    // 3. validate the cert
    val cf = CertificateFactory.getInstance("X.509")
    val certPath = cf.generateCertPath(listOf(cert))
    val validator = CertPathValidator.getInstance("PKIX")
    validator.validate(certPath, pkixParams) // this line throws java.security.InvalidKeyException: Wrong key usage
}
发布评论

评论列表(0)

  1. 暂无评论