Skip to content

Commit 1f6a02c

Browse files
committed
JCE: throw InvalidAlgorithmParameterException if TrustAnchors have name constraints in PKIXCertPathValidator
1 parent 40e0df8 commit 1f6a02c

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

README_JCE.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,17 @@ the current system time by wolfSSL. This means that preloaded OCSP responses
520520
thisUpdate and nextUpdate dates. Historical OCSP responses with expired dates
521521
cannot be used, even with a date override.
522522

523+
#### TrustAnchor Name Constraints
524+
525+
Name constraints specified directly on a TrustAnchor (via the
526+
`TrustAnchor(X509Certificate, byte[])` constructor) are not supported.
527+
wolfJCE throws `InvalidAlgorithmParameterException` if any TrustAnchor in
528+
PKIXParameters has name constraints set. This matches SunJCE behavior.
529+
530+
Applications should use TrustAnchors without explicit name constraints; if
531+
name constraint enforcement is needed, the constraints should be embedded in
532+
the trust anchor certificate itself.
533+
523534
### Behavior Discrepancies with SunJCE
524535
---------
525536

src/main/java/com/wolfssl/provider/jce/WolfCryptPKIXCertPathValidator.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,18 @@ public CertPathValidatorResult engineValidate(
926926

927927
pkixParams = (PKIXParameters)params;
928928

929+
/* Check if any TrustAnchors have name constraints. Native wolfSSL
930+
* does not apply TrustAnchor name constraints during chain
931+
* verification, only name constraints from certificates in the
932+
* chain. To match SunJCE behavior, throw InvalidAlgorithmParameter
933+
* Exception if TrustAnchors have name constraints. */
934+
for (TrustAnchor anchor : pkixParams.getTrustAnchors()) {
935+
if (anchor.getNameConstraints() != null) {
936+
throw new InvalidAlgorithmParameterException(
937+
"TrustAnchors with name constraints are not supported");
938+
}
939+
}
940+
929941
/* If we are in FIPS mode, verify wolfJCE is the Signature provider
930942
* to help maintain FIPS compliance */
931943
if (Fips.enabled && pkixParams.getSigProvider() != "wolfJCE") {

0 commit comments

Comments
 (0)