-
Notifications
You must be signed in to change notification settings - Fork 919
Support for extracting and validating X.509 Name Constraints extensions #9705
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request adds comprehensive support for extracting and validating X.509 Name Constraints extensions (OID 2.5.29.30) per RFC 5280. The implementation enables parsing name constraint extensions from CA certificates and validating names against permitted/excluded subtrees.
Changes:
- Adds new data structures (
WOLFSSL_GENERAL_SUBTREE,WOLFSSL_NAME_CONSTRAINTS) and API functions for name constraint handling - Implements validation for DNS, Email, IP Address, URI, and Directory Name constraint types
- Extends ASN.1 parsing to support IP address and URI name constraint types
- Adds comprehensive test coverage with 7 new test functions and 4 test certificates
Reviewed changes
Copilot reviewed 19 out of 22 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| wolfssl/ssl.h | Defines new structures for GENERAL_SUBTREE and NAME_CONSTRAINTS, adds API function declarations |
| wolfssl/openssl/x509v3.h | Adds OpenSSL compatibility layer macros and typedefs |
| wolfssl/wolfcrypt/asn.h | Declares IP subnet matching function for name constraint validation |
| wolfssl/internal.h | Adds name constraint storage fields to WOLFSSL_X509 structure and GENERAL_SUBTREE stack type |
| wolfcrypt/src/asn.c | Implements IP subnet matching, integrates IP and URI type support into constraint validation |
| src/x509.c | Implements NAME_CONSTRAINTS extraction from certificates, name validation API, and helper functions |
| src/ssl_sk.c | Extends stack operations to handle GENERAL_SUBTREE type |
| src/internal.c | Adds memory management for name constraint fields in X509 structure |
| tests/api/test_ossl_x509_ext.c | Adds 7 comprehensive test functions covering all constraint types and edge cases |
| tests/api/test_ossl_x509_ext.h | Declares new test functions |
| certs/test/ | Adds 4 new test certificates and configs for DNS, URI, IP, and mixed constraints |
| certs/test/gen-ext-certs.sh | Updates certificate generation script for new test certificates |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
cb566c8 to
94ba174
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 19 out of 22 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
553bbde to
83545f3
Compare
…) and wolfSSL_NAME_CONSTRAINTS_check_name()
83545f3 to
4fa1f95
Compare
|
Retest this please Jenkins:
|
Description
This PR adds support for extracting and validating X.509 Name Constraints extensions (OID 2.5.29.30). Enables parsing name constraint extensions from CA certificates and validate names against permitted/excluded subtrees per RFC 5280.
New Structures (
wolfssl/ssl.h)WOLFSSL_GENERAL_SUBTREE- represents a GeneralSubtree containing a base GeneralNameWOLFSSL_NAME_CONSTRAINTS- contains permitted and excluded subtree stacksNew Functions
wolfSSL_NAME_CONSTRAINTS_free()- free NAME_CONSTRAINTS and all contentswolfSSL_NAME_CONSTRAINTS_check_name()- validate a name against constraintswolfSSL_sk_GENERAL_SUBTREE_num()- get count of subtrees in stackwolfSSL_sk_GENERAL_SUBTREE_value()- get subtree at index from stackwolfssl_local_MatchIpSubnet()- IP address subnet matching for constraintsOpenSSL Compatibility Macros (
wolfssl/openssl/x509v3.h)NAME_CONSTRAINTS,GENERAL_SUBTREEtypedefsNAME_CONSTRAINTS_free,sk_GENERAL_SUBTREE_num,sk_GENERAL_SUBTREE_valuemacrosSupported Name Constraint Types
GEN_DNS) - domain name matching with leading dot subdomain supportGEN_EMAIL) - RFC822 name matching with domain constraintsGEN_IPADD) - IPv4 and IPv6 subnet matching (IP + mask)GEN_URI) - host extraction with IPv6 literal supportGEN_DIRNAME) - X.500 distinguished name matchingNew Test Certificates
cert-ext-nc-combined.pem/der/cfg- Combined DNS and URI constraints (.wolfssl.com)cert-ext-ncip.pem/der/cfg- IP address constraint (192.168.1.0/255.255.255.0)cert-ext-ncdns.pem- DNS-only constraintcert-ext-ncmulti.pem/der/cfg- mixed permitted/excluded constraintsAssociated wolfssljni PR here, which wraps this functionality: wolfSSL/wolfssljni#316
Testing
Added new unit tests to test functionality. Also tested underneath wolfSSL JNI/JSSE (PR to open soon).
Checklist