File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -10923,7 +10923,11 @@ inline long SSLClient::get_openssl_verify_result() const {
1092310923inline SSL_CTX *SSLClient::ssl_context () const { return ctx_; }
1092410924
1092510925inline bool SSLClient::create_and_connect_socket (Socket &socket, Error &error) {
10926- return is_valid () && ClientImpl::create_and_connect_socket (socket, error);
10926+ if (!is_valid ()) {
10927+ error = Error::SSLConnection;
10928+ return false ;
10929+ }
10930+ return ClientImpl::create_and_connect_socket (socket, error);
1092710931}
1092810932
1092910933// Assumes that socket_mutex_ is locked and that there are no requests in
Original file line number Diff line number Diff line change @@ -8366,6 +8366,19 @@ TEST(SSLClientTest, Issue2004_Online) {
83668366 EXPECT_EQ (body.substr (0 , 15 ), " <!doctype html>" );
83678367}
83688368
8369+ TEST (SSLClientTest, ErrorReportingWhenInvalid) {
8370+ // Create SSLClient with invalid cert/key to make is_valid() return false
8371+ SSLClient cli (" localhost" , 8080 , " nonexistent_cert.pem" ,
8372+ " nonexistent_key.pem" );
8373+
8374+ // is_valid() should be false due to cert loading failure
8375+ ASSERT_FALSE (cli.is_valid ());
8376+
8377+ auto res = cli.Get (" /" );
8378+ ASSERT_FALSE (res);
8379+ EXPECT_EQ (Error::SSLConnection, res.error ());
8380+ }
8381+
83698382#if 0
83708383TEST(SSLClientTest, SetInterfaceWithINET6) {
83718384 auto cli = std::make_shared<httplib::Client>("https://httpbin.org");
You can’t perform that action at this time.
0 commit comments