diff --git a/asio/include/asio/ssl/stream.hpp b/asio/include/asio/ssl/stream.hpp index 23b92f15..c31bba98 100644 --- a/asio/include/asio/ssl/stream.hpp +++ b/asio/include/asio/ssl/stream.hpp @@ -141,10 +141,12 @@ public: * * // ... establish connection and perform handshake ... * - * if (SSL_get_verify_result(sock.native_handle()) == X509_V_OK) + * if (X509* cert = SSL_get_peer_certificate(sock.native_handle())) * { - * X509* cert = SSL_get_peer_certificate(sock.native_handle()); - * // ... + * if (SSL_get_verify_result(sock.native_handle()) == X509_V_OK) + * { + * // ... + * } * } * @endcode */ diff --git a/asio/src/doc/reference.qbk b/asio/src/doc/reference.qbk index c9ebc2bb..589bcede 100644 --- a/asio/src/doc/reference.qbk +++ b/asio/src/doc/reference.qbk @@ -83936,10 +83936,12 @@ The `native_handle()` function returns a pointer of type `SSL*` that is suitable // ... establish connection and perform handshake ... - if (SSL_get_verify_result(sock.native_handle()) == X509_V_OK) + if (X509* cert = SSL_get_peer_certificate(sock.native_handle())) { - X509* cert = SSL_get_peer_certificate(sock.native_handle()); - // ... + if (SSL_get_verify_result(sock.native_handle()) == X509_V_OK) + { + // ... + } }