mirror of
https://github.com/boostorg/beast.git
synced 2025-08-01 05:44:38 +02:00
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:
@@ -1,6 +1,7 @@
|
|||||||
Version 183:
|
Version 183:
|
||||||
|
|
||||||
* Fix a rare case of failed UTF8 validation
|
* Fix a rare case of failed UTF8 validation
|
||||||
|
* Verify certificates in client examples
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -15,6 +15,8 @@
|
|||||||
|
|
||||||
* ([issue 1245]) Fix a rare case of incorrect UTF8 validation
|
* ([issue 1245]) Fix a rare case of incorrect UTF8 validation
|
||||||
|
|
||||||
|
* ([issue 1237]) Verify certificates in client examples
|
||||||
|
|
||||||
[heading Boost 1.68]
|
[heading Boost 1.68]
|
||||||
|
|
||||||
This version fixes a missing executor work guard in all composed operations
|
This version fixes a missing executor work guard in all composed operations
|
||||||
|
@@ -70,26 +70,6 @@ load_root_certificates(ssl::context& ctx, boost::system::error_code& ec)
|
|||||||
Thumbprint(sha1):
|
Thumbprint(sha1):
|
||||||
de 28 f4 a4 ff e5 b9 2f a3 c5 03 d1 a3 49 a7 f9 96 2a 82 12
|
de 28 f4 a4 ff e5 b9 2f a3 c5 03 d1 a3 49 a7 f9 96 2a 82 12
|
||||||
*/
|
*/
|
||||||
"-----BEGIN CERTIFICATE-----\n"
|
|
||||||
"MIIDVDCCAjygAwIBAgIDAjRWMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNVBAYTAlVT\n"
|
|
||||||
"MRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMRswGQYDVQQDExJHZW9UcnVzdCBHbG9i\n"
|
|
||||||
"YWwgQ0EwHhcNMDIwNTIxMDQwMDAwWhcNMjIwNTIxMDQwMDAwWjBCMQswCQYDVQQG\n"
|
|
||||||
"EwJVUzEWMBQGA1UEChMNR2V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JHFwLJhWC9kXtNHjUStedejV0NxPNO3CBWaAocvmMw==\n"
|
|
||||||
"-----END CERTIFICATE-----\n"
|
|
||||||
;
|
;
|
||||||
|
|
||||||
ctx.add_certificate_authority(
|
ctx.add_certificate_authority(
|
||||||
|
@@ -225,6 +225,9 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
// This holds the root certificate used for verification
|
// This holds the root certificate used for verification
|
||||||
load_root_certificates(ctx);
|
load_root_certificates(ctx);
|
||||||
|
|
||||||
|
// Verify the remote server's certificate
|
||||||
|
ctx.set_verify_mode(ssl::verify_peer);
|
||||||
|
|
||||||
// Launch the asynchronous operation
|
// Launch the asynchronous operation
|
||||||
std::make_shared<session>(ioc, ctx)->run(host, port, target, version);
|
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
|
// This holds the root certificate used for verification
|
||||||
load_root_certificates(ctx);
|
load_root_certificates(ctx);
|
||||||
|
|
||||||
|
// Verify the remote server's certificate
|
||||||
|
ctx.set_verify_mode(ssl::verify_peer);
|
||||||
|
|
||||||
// Launch the asynchronous operation
|
// Launch the asynchronous operation
|
||||||
boost::asio::spawn(ioc, std::bind(
|
boost::asio::spawn(ioc, std::bind(
|
||||||
|
@@ -59,7 +59,10 @@ int main(int argc, char** argv)
|
|||||||
// This holds the root certificate used for verification
|
// This holds the root certificate used for verification
|
||||||
load_root_certificates(ctx);
|
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};
|
tcp::resolver resolver{ioc};
|
||||||
ssl::stream<tcp::socket> stream{ioc, ctx};
|
ssl::stream<tcp::socket> stream{ioc, ctx};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user