CertPathBuilder fixes for disabledAlgorithms, date handling, and edge cases#200
CertPathBuilder fixes for disabledAlgorithms, date handling, and edge cases#200rlm2002 merged 7 commits intowolfSSL:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR enhances the WolfCrypt JCE provider's certificate path building and validation to properly enforce Java security constraints and improve edge case handling. The changes ensure compliance with jdk.certpath.disabledAlgorithms security property, fix date handling for different wolfSSL versions, and improve robustness when CertStores are absent.
Changes:
- Added enforcement of
jdk.certpath.disabledAlgorithmsin both CertPathBuilder and CertPathValidator for signature algorithms, public key algorithms, and key sizes - Modified date handling in CertPathBuilder to use native wolfSSL date checking when available, falling back to Java-based chain building with deferred date validation otherwise
- Enhanced CertPathBuilder to find target certificates among trust anchors when no CertStores are provided
- Added validation to reject non-X509CertSelector target constraints with InvalidAlgorithmParameterException
- Fixed trust anchor public key constraint checking in CertPathValidator
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| src/main/java/com/wolfssl/provider/jce/WolfCryptPKIXCertPathBuilder.java | Implements algorithm constraint checking for certificates, trust anchors, and signer keys; adds fallback path for wolfSSL versions without native date checking; enhances target certificate finding to search trust anchors; filters intermediates based on disabled algorithms |
| src/main/java/com/wolfssl/provider/jce/WolfCryptPKIXCertPathValidator.java | Adds trust anchor public key constraint checking for both normal and zero-length cert paths |
| src/test/java/com/wolfssl/provider/jce/test/WolfCryptPKIXCertPathBuilderTest.java | Adds comprehensive test coverage for algorithm constraints (signature algorithms, key algorithms, key sizes, algorithm variants), trust anchor constraints, date handling with custom dates, intermediate filtering, zero-length paths, and non-X509CertSelector rejection |
| src/test/java/com/wolfssl/provider/jce/test/WolfCryptPKIXCertPathValidatorTest.java | Adds tests for trust anchor public key constraints on both normal and zero-length cert paths |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/main/java/com/wolfssl/provider/jce/WolfCryptPKIXCertPathBuilder.java
Outdated
Show resolved
Hide resolved
src/main/java/com/wolfssl/provider/jce/WolfCryptPKIXCertPathValidator.java
Outdated
Show resolved
Hide resolved
src/test/java/com/wolfssl/provider/jce/test/WolfCryptPKIXCertPathValidatorTest.java
Outdated
Show resolved
Hide resolved
src/main/java/com/wolfssl/provider/jce/WolfCryptPKIXCertPathBuilder.java
Outdated
Show resolved
Hide resolved
src/main/java/com/wolfssl/provider/jce/WolfCryptPKIXCertPathValidator.java
Outdated
Show resolved
Hide resolved
src/main/java/com/wolfssl/provider/jce/WolfCryptPKIXCertPathBuilder.java
Outdated
Show resolved
Hide resolved
src/main/java/com/wolfssl/provider/jce/WolfCryptPKIXCertPathValidator.java
Outdated
Show resolved
Hide resolved
src/main/java/com/wolfssl/provider/jce/WolfCryptPKIXCertPathBuilder.java
Outdated
Show resolved
Hide resolved
8f1586e to
d1f5fe2
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 9 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/main/java/com/wolfssl/provider/jce/WolfCryptPKIXRevocationChecker.java
Outdated
Show resolved
Hide resolved
src/main/java/com/wolfssl/provider/jce/WolfCryptPKIXCertPathValidator.java
Show resolved
Hide resolved
src/main/java/com/wolfssl/provider/jce/WolfCryptPKIXCertPathValidator.java
Show resolved
Hide resolved
src/main/java/com/wolfssl/provider/jce/WolfCryptPKIXCertPathValidator.java
Show resolved
Hide resolved
src/test/java/com/wolfssl/provider/jce/test/WolfCryptPKIXCertPathBuilderTest.java
Outdated
Show resolved
Hide resolved
…er and fix trust anchor key constraint checking in CertPathValidator
…ustom validation date
…lfSSL_d2i_OCSP_RESPONSE()
…for all CA loading
d1f5fe2 to
790f6ac
Compare
This PR includes fixes and improvements to
CertPathBuilderincluding:jdk.certpath.disabledAlgorithmsin CertPathBuilder (signature algo, public key algo/size) and fixes trust anchor key constraint checking in CertPathValidatorcheck_timesupport, fall back to Java based chain building and defer date validation to CertPathValidatorInvalidAlgorithmParameterExceptionfor nonX509CertSelectortargetsAnd some adjustments to
CertPathValidator:CertManagerLoadCABufferEx()JNI wrapper forwolfSSL_CertManagerLoadCABuffer_ex(), exposing the flags parameterCertPathValidatornow passesWOLFSSL_LOAD_FLAG_DATE_ERR_OKAYwhen loading trust anchors (per RFC 5280, trust anchors should not be date-validated) and verified intermediate CAs. Log and continue on load errors that may be caused by trusted peer cert loading on older wolfSSL builds.WOLFSSL_X509_STORE_CTXto Java via a new default 4-argverify()method onWolfSSLCertManagerVerifyCallback.OcspResponseStatusJNI wrapper for parsing OCSP response status from raw DER bytes.This fixes the following SunJCE tests: