mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-10-22 11:46:13 +00:00
Ready PSA Crypto before parsing a CA store on Mbed TLS 4.x
tls::create_ca_store() parses certificates, which on Mbed TLS 4.x needs PSA Crypto. A context readies it when it is created, but a store can be made before any context exists, and then a valid PEM failed to parse and the call returned NULL. Ready PSA Crypto first, as the contexts do.
This commit is contained in:
1 parent
6304fc6abb
commit
fd5dd79bd2
1 file changed
+5
@@ -21924,6 +21924,11 @@ inline std::string error_string(uint64_t code) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline ca_store_t create_ca_store(const char *pem, size_t len) {
|
inline ca_store_t create_ca_store(const char *pem, size_t len) {
|
||||||
|
#ifdef CPPHTTPLIB_MBEDTLS_V4
|
||||||
|
// Parsing certificates needs PSA Crypto, and no context may exist yet
|
||||||
|
if (!detail::ensure_mbedtls_psa_crypto()) { return nullptr; }
|
||||||
|
#endif
|
||||||
|
|
||||||
auto *ca_chain = new (std::nothrow) mbedtls_x509_crt;
|
auto *ca_chain = new (std::nothrow) mbedtls_x509_crt;
|
||||||
if (!ca_chain) { return nullptr; }
|
if (!ca_chain) { return nullptr; }
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user