Repository navigation
Add four X509 OpenSSL compatibility APIs - #12285
Open
julek-wolfssl wants to merge 4 commits into
Open
julek-wolfssl wants to merge 4 commits into
julek-wolfssl wants to merge 4 commits into
Conversation
X509_VERIFY_PARAM_get_hostflags() returns the flags stored by X509_VERIFY_PARAM_set_hostflags(), or 0 for a NULL param. X509_check_ip() is the binary counterpart of X509_check_ip_asc(). The 4 byte IPv4 or 16 byte IPv6 address is printed in the form the certificate parser gives iPAddress names and checked with X509_check_ip_asc(), so both share one matching path and return 1 on a match and 0 otherwise. The uncompressed IPv6 form also matches without the inet_pton() based comparison, which WOLFSSL_USER_IO builds lack. Any other length returns 0. OpenSSL compares lengths, so it never matches either. NULL arguments return 0 like X509_check_ip_asc(); OpenSSL returns -2 for a NULL address. X509_STORE_CTX_get_ex_new_index() is CRYPTO_get_ex_new_index() with CRYPTO_EX_INDEX_X509_STORE_CTX in OpenSSL. That class now has its own counter, shared by both calls, so CRYPTO_get_ex_new_index() returns an index for it too. Counting starts at 1. During verification the handshake keeps the WOLFSSL object at index 0, the value of SSL_get_ex_data_X509_STORE_CTX_idx(), and an application index must not alias it. OpenSSL never hands out 0 either. As for the SSL, SSL_CTX and X509 classes, the new, dup and free callbacks are not used. X509_STORE_CTX_get0_untrusted() returns ctxIntermediates, the stack passed as the chain argument of X509_STORE_CTX_init(). It is the only stack in the context that holds the untrusted certificates as the caller set them up. The others are owned (issuers the context decoded and frees), chain (the path X509_verify_cert() built) and setTrustedSk (the trusted override from X509_STORE_CTX_trusted_stack()). X509_verify_cert() works on a private shallow copy and leaves ctxIntermediates unchanged. Ownership matches OpenSSL: the pointer is returned as is, the context never copies or frees the stack, and the caller of init keeps ownership. A new init replaces it. X509_STORE_CTX_cleanup() resets it with the rest of the context, while OpenSSL keeps the pointer across cleanup. The handshake sets up its store context without an untrusted stack, so the call returns NULL in a TLS verify callback, where OpenSSL gives the peer chain. .wolfssl_known_macro_extras gains 27 options that users or CI configurations set and check-source-text rejected as unknown: the sources test them, but nothing the check scans defines them. It drops WC_NO_STATIC_ASSERT, WOLFSSL_ALLOW_NO_SUITES and WOLFSSL_SP_FAST_MODEXP_COPY, which the tree defines.
|
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The unsynchronized process-wide ex-data index counter can allocate duplicate indices during concurrent registration, causing independent users’ store-context values to overwrite one another.
4 open issues
What changed in this PR
Extends wolfSSL’s OpenSSL compatibility layer with four X509 APIs for binary IP matching, hostname-check flags, untrusted certificate stacks, and store-context external-data indexes.
Changes:
- Adds implementations, public declarations, and OpenSSL-compatible aliases.
- Adds API tests and updates external-data class expectations.
- Updates documentation references and the known-macro list.
| File | Description |
|---|---|
wolfssl/ssl.h |
Declares the four new public APIs. |
wolfssl/openssl/ssl.h |
Adds OpenSSL-compatible aliases. |
tests/api/test_ossl_x509.h |
Registers the binary IP-check test. |
tests/api/test_ossl_x509.c |
Tests IPv4/IPv6 matching and invalid inputs. |
tests/api/test_ossl_x509_vp.h |
Registers the host-flags getter test. |
tests/api/test_ossl_x509_vp.c |
Tests flag retrieval, copying, and inheritance. |
tests/api/test_ossl_x509_str.h |
Registers the new store-context tests. |
tests/api/test_ossl_x509_str.c |
Tests external-data indexes and untrusted-stack ownership. |
tests/api.c |
Removes the unsupported-class expectation for store contexts. |
src/x509.c |
Implements host-flags retrieval and binary IP matching. |
src/x509_str.c |
Implements the two store-context APIs. |
src/ssl.c |
Adds store-context index allocation, reserving index zero. |
doc/dox_comments/header_files/ssl.h |
Adds an English documentation reference to the index API. |
doc/dox_comments/header_files-ja/ssl.h |
Adds the corresponding Japanese documentation reference. |
.wolfssl_known_macro_extras |
Refreshes the known-macro list. |
Review effort: Balanced
…in verify callbacks The handshake verify callback context keeps the peer certs as DER buffers, not in ctxIntermediates. Build a ctx owned stack from them on demand.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



No description provided.