You've already forked cpp-httplib
							
							Merge branch 'staticlibs-ssl_error_reporting'
This commit is contained in:
		@@ -10923,7 +10923,11 @@ inline long SSLClient::get_openssl_verify_result() const {
 | 
				
			|||||||
inline SSL_CTX *SSLClient::ssl_context() const { return ctx_; }
 | 
					inline SSL_CTX *SSLClient::ssl_context() const { return ctx_; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
inline bool SSLClient::create_and_connect_socket(Socket &socket, Error &error) {
 | 
					inline bool SSLClient::create_and_connect_socket(Socket &socket, Error &error) {
 | 
				
			||||||
  return is_valid() && ClientImpl::create_and_connect_socket(socket, error);
 | 
					  if (!is_valid()) {
 | 
				
			||||||
 | 
					    error = Error::SSLConnection;
 | 
				
			||||||
 | 
					    return false;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  return ClientImpl::create_and_connect_socket(socket, error);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Assumes that socket_mutex_ is locked and that there are no requests in
 | 
					// Assumes that socket_mutex_ is locked and that there are no requests in
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										13
									
								
								test/test.cc
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								test/test.cc
									
									
									
									
									
								
							@@ -8366,6 +8366,19 @@ TEST(SSLClientTest, Issue2004_Online) {
 | 
				
			|||||||
  EXPECT_EQ(body.substr(0, 15), "<!doctype html>");
 | 
					  EXPECT_EQ(body.substr(0, 15), "<!doctype html>");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					TEST(SSLClientTest, ErrorReportingWhenInvalid) {
 | 
				
			||||||
 | 
					  // Create SSLClient with invalid cert/key to make is_valid() return false
 | 
				
			||||||
 | 
					  SSLClient cli("localhost", 8080, "nonexistent_cert.pem",
 | 
				
			||||||
 | 
					                "nonexistent_key.pem");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // is_valid() should be false due to cert loading failure
 | 
				
			||||||
 | 
					  ASSERT_FALSE(cli.is_valid());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  auto res = cli.Get("/");
 | 
				
			||||||
 | 
					  ASSERT_FALSE(res);
 | 
				
			||||||
 | 
					  EXPECT_EQ(Error::SSLConnection, res.error());
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if 0
 | 
					#if 0
 | 
				
			||||||
TEST(SSLClientTest, SetInterfaceWithINET6) {
 | 
					TEST(SSLClientTest, SetInterfaceWithINET6) {
 | 
				
			||||||
  auto cli = std::make_shared<httplib::Client>("https://httpbin.org");
 | 
					  auto cli = std::make_shared<httplib::Client>("https://httpbin.org");
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user