1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>ssl::host_name_verification</title> 5<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css"> 6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 7<link rel="home" href="../../boost_asio.html" title="Boost.Asio"> 8<link rel="up" href="../reference.html" title="Reference"> 9<link rel="prev" href="ssl__error__stream_errors.html" title="ssl::error::stream_errors"> 10<link rel="next" href="ssl__host_name_verification/host_name_verification.html" title="ssl::host_name_verification::host_name_verification"> 11</head> 12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 13<table cellpadding="2" width="100%"><tr> 14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td> 15<td align="center"><a href="../../../../index.html">Home</a></td> 16<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td> 17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 19<td align="center"><a href="../../../../more/index.htm">More</a></td> 20</tr></table> 21<hr> 22<div class="spirit-nav"> 23<a accesskey="p" href="ssl__error__stream_errors.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../boost_asio.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="ssl__host_name_verification/host_name_verification.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h3 class="title"> 27<a name="boost_asio.reference.ssl__host_name_verification"></a><a class="link" href="ssl__host_name_verification.html" title="ssl::host_name_verification">ssl::host_name_verification</a> 28</h3></div></div></div> 29<p> 30 Verifies a certificate against a host_name according to the rules described 31 in RFC 6125. 32 </p> 33<pre class="programlisting">class host_name_verification 34</pre> 35<h5> 36<a name="boost_asio.reference.ssl__host_name_verification.h0"></a> 37 <span class="phrase"><a name="boost_asio.reference.ssl__host_name_verification.types"></a></span><a class="link" href="ssl__host_name_verification.html#boost_asio.reference.ssl__host_name_verification.types">Types</a> 38 </h5> 39<div class="informaltable"><table class="table"> 40<colgroup> 41<col> 42<col> 43</colgroup> 44<thead><tr> 45<th> 46 <p> 47 Name 48 </p> 49 </th> 50<th> 51 <p> 52 Description 53 </p> 54 </th> 55</tr></thead> 56<tbody><tr> 57<td> 58 <p> 59 <a class="link" href="ssl__host_name_verification/result_type.html" title="ssl::host_name_verification::result_type"><span class="bold"><strong>result_type</strong></span></a> 60 </p> 61 </td> 62<td> 63 <p> 64 The type of the function object's result. 65 </p> 66 </td> 67</tr></tbody> 68</table></div> 69<h5> 70<a name="boost_asio.reference.ssl__host_name_verification.h1"></a> 71 <span class="phrase"><a name="boost_asio.reference.ssl__host_name_verification.member_functions"></a></span><a class="link" href="ssl__host_name_verification.html#boost_asio.reference.ssl__host_name_verification.member_functions">Member 72 Functions</a> 73 </h5> 74<div class="informaltable"><table class="table"> 75<colgroup> 76<col> 77<col> 78</colgroup> 79<thead><tr> 80<th> 81 <p> 82 Name 83 </p> 84 </th> 85<th> 86 <p> 87 Description 88 </p> 89 </th> 90</tr></thead> 91<tbody> 92<tr> 93<td> 94 <p> 95 <a class="link" href="ssl__host_name_verification/host_name_verification.html" title="ssl::host_name_verification::host_name_verification"><span class="bold"><strong>host_name_verification</strong></span></a> <span class="silver">[constructor]</span> 96 </p> 97 </td> 98<td> 99 <p> 100 Constructor. 101 </p> 102 </td> 103</tr> 104<tr> 105<td> 106 <p> 107 <a class="link" href="ssl__host_name_verification/operator_lp__rp_.html" title="ssl::host_name_verification::operator()"><span class="bold"><strong>operator()</strong></span></a> 108 </p> 109 </td> 110<td> 111 <p> 112 Perform certificate verification. 113 </p> 114 </td> 115</tr> 116</tbody> 117</table></div> 118<h5> 119<a name="boost_asio.reference.ssl__host_name_verification.h2"></a> 120 <span class="phrase"><a name="boost_asio.reference.ssl__host_name_verification.example"></a></span><a class="link" href="ssl__host_name_verification.html#boost_asio.reference.ssl__host_name_verification.example">Example</a> 121 </h5> 122<p> 123 The following example shows how to synchronously open a secure connection 124 to a given host name: 125 </p> 126<pre class="programlisting">using boost::asio::ip::tcp; 127namespace ssl = boost::asio::ssl; 128typedef ssl::stream<tcp::socket> ssl_socket; 129 130// Create a context that uses the default paths for finding CA certificates. 131ssl::context ctx(ssl::context::sslv23); 132ctx.set_default_verify_paths(); 133 134// Open a socket and connect it to the remote host. 135boost::asio::io_context io_context; 136ssl_socket sock(io_context, ctx); 137tcp::resolver resolver(io_context); 138tcp::resolver::query query("host.name", "https"); 139boost::asio::connect(sock.lowest_layer(), resolver.resolve(query)); 140sock.lowest_layer().set_option(tcp::no_delay(true)); 141 142// Perform SSL handshake and verify the remote host's certificate. 143sock.set_verify_mode(ssl::verify_peer); 144sock.set_verify_callback(ssl::host_name_verification("host.name")); 145sock.handshake(ssl_socket::client); 146 147// ... read and write as normal ... 148</pre> 149<h5> 150<a name="boost_asio.reference.ssl__host_name_verification.h3"></a> 151 <span class="phrase"><a name="boost_asio.reference.ssl__host_name_verification.requirements"></a></span><a class="link" href="ssl__host_name_verification.html#boost_asio.reference.ssl__host_name_verification.requirements">Requirements</a> 152 </h5> 153<p> 154 <span class="emphasis"><em>Header: </em></span><code class="literal">boost/asio/ssl/host_name_verification.hpp</code> 155 </p> 156<p> 157 <span class="emphasis"><em>Convenience header: </em></span><code class="literal">boost/asio/ssl.hpp</code> 158 </p> 159</div> 160<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 161<td align="left"></td> 162<td align="right"><div class="copyright-footer">Copyright © 2003-2020 Christopher M. 163 Kohlhoff<p> 164 Distributed under the Boost Software License, Version 1.0. (See accompanying 165 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) 166 </p> 167</div></td> 168</tr></table> 169<hr> 170<div class="spirit-nav"> 171<a accesskey="p" href="ssl__error__stream_errors.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../boost_asio.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="ssl__host_name_verification/host_name_verification.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a> 172</div> 173</body> 174</html> 175