我正在尝试基于SHA256withECDSA
算法验证证书的证书链。
我正在使用Java JDK 11。
运行CertPathValidator.getInstance("PKIX").validate
方法时,我崩溃了Unrecognized algorithm for signature parameters SHA256withECDSA
。
根本原因似乎是:
// null
providerSunEC.getService("AlgorithmParameters", "SHA256withECDSA");
但是,没有这样的签名参数:X509CertImpl
实例包含带有AlgorithmId
algid
和参数1.2.840.10045.4.3.2
的{{1}}(DER编码,它应该为OID.1.2.840.10045.3.1.7
),它应该是默认值,并且仅受支持。
我的感觉可能是错误的,那就是冗余prime256v1
可以并且应该被省略,但是我不知道如何实现它,因为它在Java代码中。
这是堆栈跟踪:
prime256v1
这是证书链:
Caused by: java.security.cert.CertPathValidatorException: signature check failed
at java.base/sun.security.provider.certpath.PKIXMasterCertPathValidator.validate(PKIXMasterCertPathValidator.java:135)
at java.base/sun.security.provider.certpath.PKIXCertPathValidator.validate(PKIXCertPathValidator.java:233)
at java.base/sun.security.provider.certpath.PKIXCertPathValidator.validate(PKIXCertPathValidator.java:141)
at java.base/sun.security.provider.certpath.PKIXCertPathValidator.engineValidate(PKIXCertPathValidator.java:80)
at java.base/java.security.cert.CertPathValidator.validate(CertPathValidator.java:309)
at net.corda.core.internal.InternalUtils.validate(InternalUtils.kt:469)
... 64 more
Caused by: java.security.cert.CertificateException: Unrecognized algorithm for signature parameters SHA256withECDSA
at java.base/sun.security.x509.X509CertImpl.verify(X509CertImpl.java:445)
at java.base/sun.security.provider.certpath.BasicChecker.verifySignature(BasicChecker.java:166)
at java.base/sun.security.provider.certpath.BasicChecker.check(BasicChecker.java:147)
at java.base/sun.security.provider.certpath.PKIXMasterCertPathValidator.validate(PKIXMasterCertPathValidator.java:125)
... 69 more