forked from boostorg/beast
Verify certificates in client examples:
fix #1237 HTTP client examples now verify the server's certificate and generate an error if the certificate is invalid or expired: * Set certificate verify mode * Remove duplicate root certificate
This commit is contained in:
@@ -225,6 +225,9 @@ int main(int argc, char** argv)
|
||||
|
||||
// This holds the root certificate used for verification
|
||||
load_root_certificates(ctx);
|
||||
|
||||
// Verify the remote server's certificate
|
||||
ctx.set_verify_mode(ssl::verify_peer);
|
||||
|
||||
// Launch the asynchronous operation
|
||||
std::make_shared<session>(ioc, ctx)->run(host, port, target, version);
|
||||
|
||||
@@ -146,6 +146,9 @@ int main(int argc, char** argv)
|
||||
|
||||
// This holds the root certificate used for verification
|
||||
load_root_certificates(ctx);
|
||||
|
||||
// Verify the remote server's certificate
|
||||
ctx.set_verify_mode(ssl::verify_peer);
|
||||
|
||||
// Launch the asynchronous operation
|
||||
boost::asio::spawn(ioc, std::bind(
|
||||
|
||||
@@ -59,7 +59,10 @@ int main(int argc, char** argv)
|
||||
// This holds the root certificate used for verification
|
||||
load_root_certificates(ctx);
|
||||
|
||||
// These objects perform our I/O
|
||||
// Verify the remote server's certificate
|
||||
ctx.set_verify_mode(ssl::verify_peer);
|
||||
|
||||
// These objects perform our I/O
|
||||
tcp::resolver resolver{ioc};
|
||||
ssl::stream<tcp::socket> stream{ioc, ctx};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user