mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-10-22 11:46:13 +00:00
Parse a CA store PEM through a NUL-terminated copy on Mbed TLS
tls::create_ca_store() on Mbed TLS parsed the caller's buffer with one byte more than its length, so it read past the end of the buffer, and when that byte was not a NUL the PEM was not recognized and the call returned NULL. Parse a NUL-terminated copy instead, as load_ca_pem() does. DER input still parses, since its own length ends it.
This commit is contained in:
1 parent
3599533c24
commit
3b8b9cf9d5
2 files changed
+22
-12
No files matched your search
@@ -18304,6 +18304,17 @@ TEST(SSLClientTest, EmptyCustomCaKeepsSystemCasOut) {
|
||||
}
|
||||
#endif
|
||||
|
||||
// A PEM given to create_ca_store() needs no NUL after it
|
||||
TEST(SSLClientTest, CreateCaStoreFromPemWithoutNul) {
|
||||
std::string pem;
|
||||
read_file(SERVER_CERT2_FILE, pem);
|
||||
auto buf = pem + "X";
|
||||
auto store = tls::create_ca_store(buf.data(), pem.size());
|
||||
EXPECT_TRUE(store != nullptr);
|
||||
SSLClient cli("localhost");
|
||||
cli.set_ca_cert_store(store);
|
||||
}
|
||||
|
||||
// enable_system_ca(false) prevents system CA loading entirely
|
||||
TEST(SSLClientTest, DisableSystemCa_Online) {
|
||||
SSLClient cli("google.com");
|
||||
|
||||
Reference in new issue
Block a user