Repository navigation
Conversation
|
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved critical findings allow strict-error overrides to bypass additional enforced checks and revocation validation, or report a successful CA load without installing the CA.
6 open issues
Prevent strict errors from overriding failed CA loads · New Run context CRL and date checks before strict-error overrides · New Require approval for every enforced strict-check failure · New Enable certificate events by default in the all-features bundle · New Log CRL signature and signer errors before normalization · New Report actual bit sizes for non-byte-aligned curves · New
What changed in this PR
Adds optional certificate and CRL validation events to wolfSSL for structured security logging, alongside configurable strict-profile checks.
Changes:
- Introduces event callbacks with stable condition codes, certificate identity, algorithm details, and verification outcomes.
- Integrates reporting and strict checks into certificate parsing, TLS, certificate-manager, X509-store, and CRL paths.
- Adds build options, API documentation, test registrations, certificate fixtures, and CI configurations.
| File | Description |
|---|---|
wolfssl/wolfcrypt/error-crypt.h |
Defines six strict-check error codes. |
wolfssl/wolfcrypt/asn.h |
Adds parser event state and helper declarations. |
wolfssl/wolfcrypt/asn_public.h |
Defines public event types and strict-check flags. |
wolfssl/ssl.h |
Declares event callback and enforcement APIs. |
wolfssl/internal.h |
Adds certificate-manager and handshake event state. |
wolfcrypt/src/error.c |
Adds strict-check error strings. |
wolfcrypt/src/asn.c |
Implements event reporting and strict certificate checks. |
wolfcrypt/src/asn_orig.c |
Adds original-parser failure reporting. |
tests/api/test_certman.h |
Registers certificate-event tests. |
src/x509_str.c |
Integrates events into X509-store verification. |
src/ssl_certman.c |
Adds manager APIs and verification events. |
src/ssl_api_cert.c |
Exposes TLS-context configuration APIs. |
src/internal.c |
Reports TLS certificate events and deferred status results. |
src/crl.c |
Adds CRL events and strict thisUpdate checks. |
doc/dox_comments/header_files/ssl.h |
Documents manager, context, and store APIs. |
doc/dox_comments/header_files/asn_public.h |
Documents standalone parser APIs. |
configure.ac |
Adds the Autotools feature option. |
CMakeLists.txt |
Adds the CMake feature option. |
cmake/options.h.in |
Exports the event feature define. |
ChangeLog.md |
Describes validation events and strict checks. |
certs/test/include.am |
Includes event fixtures in source distributions. |
certs/test/gen-cert-events.py |
Generates certificate, chain, and CRL fixtures. |
certs/test/cert-events/chain-signer-not-ca.pem |
Tests a signer without CA status. |
certs/test/cert-events/chain-signer-no-certsign.pem |
Tests missing certificate-signing permission. |
certs/test/cert-events/chain-pathlen-exceeded.pem |
Tests a path-length violation. |
certs/test/cert-events/chain-leaf-ku-no-digsig.pem |
Tests missing leaf digital-signature usage. |
certs/test/cert-events/chain-leaf-eku-client-only.pem |
Tests a server leaf restricted to client authentication. |
certs/test/cert-events/chain-good.pem |
Provides a valid reference chain. |
certs/test/catalog.txt |
Describes fixtures and regeneration. |
.github/configs/os-check-linux.json |
Adds three certificate-event CI configurations. |
Review effort: Balanced
|
this is too big to review as one 5.3k line commit, can you split it into a stack? rough cut: 1) event struct, cm/ctx setters, defect+result on the tls peer chain and CertManagerVerify, template asn.c only, with the sel conditions. 2) x509_store, trust anchor load, no-cm parsing. 3) crl. 4) info events. 5) asn_orig parity. 6) strict checks and the 6 new error codes, those change accept/reject so they need their own review and maybe aren't needed for zd 21876. i'll review 1 first. after your vacation is fine |
f797ab9 to
d80f4a1
Compare
An optional callback that reports what happened while wolfSSL checked a certificate, for security logging. Today an application gets one error code for a whole chain and cannot tell which certificate, field or check failed. Built with --enable-cert-events (WOLFSSL_CERT_EVENTS, also in CMake and --enable-all); off by default. When off, no struct or ABI changes. Each WOLFSSL_CERT_EVENT says: - kind: DEFECT for each failed certificate check, RESULT when a verification ends (0 when it passed, so a DEFECT then a passed RESULT means the verify callback allowed it). - the certificate's role and chain depth, the RFC 5280 field, the reason and the error code. - a stable condition value for each kind of failure, named after the IEC 62351-9 and IEC 62351-3 audit events. - the extension OID as content octets, since OID sums depend on the build. - which certificate: its subject, issuer and serial number, and the TLS connection. Set with wolfSSL_CertManagerSetCertEventCb() or wolfSSL_CTX_SetCertEventCb(). Events come from the TLS peer chain (ProcessPeerCerts) and wolfSSL_CertManagerVerify*(). Field-level defects come from the template ASN.1 parser. The callback only observes: it cannot change a result, and the verify callback still decides. Co-authored-by: Cursor <cursoragent@cursor.com>
4e1e0c3 to
5d78f84
Compare
|
@mark-atwood Thanks for the review. I split this PR into a stack, as you asked. Each PR targets
I will open parts 3 to 5 when the parts below them are in review. The old full branch is still in my fork if you want to compare. Where the Copilot fixes went:
One question: do you want part 6 at all? With |


Description
Adds an optional callback that reports what happened while wolfSSL checked a
certificate. It is for security logging: an application can log each failed
check with a stable code. Regulations and standards such as the EU Cyber
Resilience Act and IEC 62351 ask for this kind of logging. Today the
application gets one error code for a whole chain and cannot tell which
certificate, field or check failed.
Fixes zd#21876
Built with
--enable-cert-events(WOLFSSL_CERT_EVENTS); off by default,included in
--enable-all. When off, no struct field or ABI changes. This PRadds no error codes.
Stack
As requested in review, this work is now a stack of PRs. Each PR targets
masterand holds one commit on top of the PR before it. Review only the topcommit of each PR. Merge them in order.
WOLFSSL_CTXsetters, DEFECT and RESULT events on the TLS peer chain and
wolfSSL_CertManagerVerify*(), template ASN.1 parser only, with theconditions SEL asked for.
X509_verify_cert(), trust anchors, parsing without acertificate manager.
asn_orig.c(to come, if wanted).What the callback receives
One
WOLFSSL_CERT_EVENTper event:(peer or CA in the chain) and chain depth, the RFC 5280 field, the reason
(malformed, missing, unsupported, expired, signature, no signer, revoked,
policy, constraint), and the wolfSSL error code.
DEFECT followed by a passed RESULT means the verify callback allowed it.
A TLS 1.2 client that asked for the server's certificate status sends it
once that status was checked at ServerHelloDone, since revocation can
still fail there.
Every event carries a
conditionvalue: a stable key for each kind offailure, named after the IEC 62351-9 and IEC 62351-3 audit events. Extension
OIDs come as content octets as well as OID sums, because the sums depend on
the build.
Each event also says which certificate it is about (subject, issuer, serial
number, when decoded) and, during a handshake, the
WOLFSSL*connection, soa log line can be tied to a peer. Host name and OCSP failures appear only in
the RESULT's error for now.
The callback only observes. The verify callback still decides; nothing about
accepting or rejecting a certificate changes.
API
wolfSSL_CertManagerSetCertEventCb()wolfSSL_CTX_SetCertEventCb()Paths covered
TLS peer chains (each certificate with its depth) and
wolfSSL_CertManagerVerify*(). Field-level DEFECTs come from the templateASN.1 parser. With
--enable-asn=originalit builds, and the RESULT and thechain-level DEFECTs still come.
FIPS
The hooks are in asn.c, internal.c, ssl_certman.c and ssl_api_cert.c. No
FIPS module source changed.
Found while checking the RFC 5280 rules, to be fixed on their own: a
certificate version value of 3 is accepted, and a valid critical
certificatePolicies, policyConstraints or inhibitAnyPolicy extension is
rejected in the default build.
Testing
certs/test/gen-cert-events.py(Python 3 and the openssl command line)generates
certs/test/cert-events/: copies ofserver-cert.derwith onedefect each, and chains with one fault each. All valid until 2049.
tests/api/test_certman.c, over the certificate manager andTLS (memio), with at least one for each condition this PR reports. Includes
a regression test that the RESULT waits for the TLS 1.2 certificate status.
--enable-cert-events --enable-crl;--enable-cert-eventswithWOLFSSL_X509_TINY;--enable-all(full APIsuite). All with
-Werror -Wdeclaration-after-statement. Built only:--enable-asn=original(the event tests skip there), events off, and--enable-all --disable-cert-events.os-check-linux.json:cert-events-crlandcert-events-tiny.--enable-allentries already cover the rest.Checklist