mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-10-24 04:09:07 +03:00
Fenrir 12740: X509_STORE_CTX_set_depth(ctx, 0) was treated as unset and silently got WOLFSSL_X509_STORE_DEFAULT_MAX_DEPTH. - set_depth() now always marks the depth as explicit so 0 means no intermediate CAs are allowed. - An explicit negative depth rejects every chain with CERT_CHAIN_TOO_LONG before any path is built, instead of falling back to the default. - X509_STORE_CTX_init() sets the depth to the default chain max depth. - A positive ctx->depth written directly to the struct (no setter) is still honored. The budget is clamped so INT_MAX cannot overflow it. A trust anchor from X509_STORE_CTX_trusted_stack() or store->certs is found by the same lookup as an untrusted intermediate and cost one extra pass, so explicit depth N only allowed N-1 intermediates there (and depth 0 rejected a leaf issued directly by the anchor). When the budget runs out on a caller-trusted anchor that would end the path (self-issued or PARTIAL_CHAIN), accept it instead of reporting CHAIN_TOO_LONG. An issuer cycle among the untrusted certs (A <- B <- A) was followed until the depth budget ran out, ~2^31 signature checks at INT_MAX. The untrusted-issuer lookup now skips certs already on the path, so the cycle ends the search with UNABLE_TO_GET_ISSUER_CERT_LOCALLY. Adds loop-a/loop-b/loop-leaf fixtures to untrusted_anchor/ for the test. Also fetch the verify callback once in X509_verify_cert() and pass it to X509StoreVerifyCert(), X509StoreCheckPathLen() and the host/IP checks, and factor the PARTIAL_CHAIN test into X509StoreCertIsPartialChain().
3.7 KiB
3.7 KiB