168 lines
6.8 KiB
HTML
168 lines
6.8 KiB
HTML
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
<title>ssl::host_name_verification</title>
|
|
<link rel="stylesheet" href="../../boostbook.css" type="text/css">
|
|
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
|
|
<link rel="home" href="../../index.html" title="Asio">
|
|
<link rel="up" href="../reference.html" title="Reference">
|
|
<link rel="prev" href="ssl__error__stream_errors.html" title="ssl::error::stream_errors">
|
|
<link rel="next" href="ssl__host_name_verification/host_name_verification.html" title="ssl::host_name_verification::host_name_verification">
|
|
</head>
|
|
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="asio C++ library" width="250" height="60" src="../../asio.png"></td></tr></table>
|
|
<hr>
|
|
<div class="spirit-nav">
|
|
<a accesskey="p" href="ssl__error__stream_errors.html"><img src="../../prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../home.png" alt="Home"></a><a accesskey="n" href="ssl__host_name_verification/host_name_verification.html"><img src="../../next.png" alt="Next"></a>
|
|
</div>
|
|
<div class="section">
|
|
<div class="titlepage"><div><div><h3 class="title">
|
|
<a name="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>
|
|
</h3></div></div></div>
|
|
<p>
|
|
Verifies a certificate against a host_name according to the rules described
|
|
in RFC 6125.
|
|
</p>
|
|
<pre class="programlisting">class host_name_verification
|
|
</pre>
|
|
<h5>
|
|
<a name="asio.reference.ssl__host_name_verification.h0"></a>
|
|
<span><a name="asio.reference.ssl__host_name_verification.types"></a></span><a class="link" href="ssl__host_name_verification.html#asio.reference.ssl__host_name_verification.types">Types</a>
|
|
</h5>
|
|
<div class="informaltable"><table class="table">
|
|
<colgroup>
|
|
<col>
|
|
<col>
|
|
</colgroup>
|
|
<thead><tr>
|
|
<th>
|
|
<p>
|
|
Name
|
|
</p>
|
|
</th>
|
|
<th>
|
|
<p>
|
|
Description
|
|
</p>
|
|
</th>
|
|
</tr></thead>
|
|
<tbody><tr>
|
|
<td>
|
|
<p>
|
|
<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>
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
The type of the function object's result.
|
|
</p>
|
|
</td>
|
|
</tr></tbody>
|
|
</table></div>
|
|
<h5>
|
|
<a name="asio.reference.ssl__host_name_verification.h1"></a>
|
|
<span><a name="asio.reference.ssl__host_name_verification.member_functions"></a></span><a class="link" href="ssl__host_name_verification.html#asio.reference.ssl__host_name_verification.member_functions">Member
|
|
Functions</a>
|
|
</h5>
|
|
<div class="informaltable"><table class="table">
|
|
<colgroup>
|
|
<col>
|
|
<col>
|
|
</colgroup>
|
|
<thead><tr>
|
|
<th>
|
|
<p>
|
|
Name
|
|
</p>
|
|
</th>
|
|
<th>
|
|
<p>
|
|
Description
|
|
</p>
|
|
</th>
|
|
</tr></thead>
|
|
<tbody>
|
|
<tr>
|
|
<td>
|
|
<p>
|
|
<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>
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Constructor.
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<p>
|
|
<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>
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
Perform certificate verification.
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table></div>
|
|
<h5>
|
|
<a name="asio.reference.ssl__host_name_verification.h2"></a>
|
|
<span><a name="asio.reference.ssl__host_name_verification.example"></a></span><a class="link" href="ssl__host_name_verification.html#asio.reference.ssl__host_name_verification.example">Example</a>
|
|
</h5>
|
|
<p>
|
|
The following example shows how to synchronously open a secure connection
|
|
to a given host name:
|
|
</p>
|
|
<pre class="programlisting">using asio::ip::tcp;
|
|
namespace ssl = asio::ssl;
|
|
typedef ssl::stream<tcp::socket> ssl_socket;
|
|
|
|
// Create a context that uses the default paths for finding CA certificates.
|
|
ssl::context ctx(ssl::context::sslv23);
|
|
ctx.set_default_verify_paths();
|
|
|
|
// Open a socket and connect it to the remote host.
|
|
asio::io_context io_context;
|
|
ssl_socket sock(io_context, ctx);
|
|
tcp::resolver resolver(io_context);
|
|
tcp::resolver::query query("host.name", "https");
|
|
asio::connect(sock.lowest_layer(), resolver.resolve(query));
|
|
sock.lowest_layer().set_option(tcp::no_delay(true));
|
|
|
|
// Perform SSL handshake and verify the remote host's certificate.
|
|
sock.set_verify_mode(ssl::verify_peer);
|
|
sock.set_verify_callback(ssl::host_name_verification("host.name"));
|
|
sock.handshake(ssl_socket::client);
|
|
|
|
// ... read and write as normal ...
|
|
</pre>
|
|
<h5>
|
|
<a name="asio.reference.ssl__host_name_verification.h3"></a>
|
|
<span><a name="asio.reference.ssl__host_name_verification.requirements"></a></span><a class="link" href="ssl__host_name_verification.html#asio.reference.ssl__host_name_verification.requirements">Requirements</a>
|
|
</h5>
|
|
<p>
|
|
<span class="emphasis"><em>Header: </em></span><code class="literal">asio/ssl/host_name_verification.hpp</code>
|
|
</p>
|
|
<p>
|
|
<span class="emphasis"><em>Convenience header: </em></span><code class="literal">asio/ssl.hpp</code>
|
|
</p>
|
|
</div>
|
|
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
|
<td align="left"></td>
|
|
<td align="right"><div class="copyright-footer">Copyright © 2003-2020 Christopher M.
|
|
Kohlhoff<p>
|
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
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>)
|
|
</p>
|
|
</div></td>
|
|
</tr></table>
|
|
<hr>
|
|
<div class="spirit-nav">
|
|
<a accesskey="p" href="ssl__error__stream_errors.html"><img src="../../prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../home.png" alt="Home"></a><a accesskey="n" href="ssl__host_name_verification/host_name_verification.html"><img src="../../next.png" alt="Next"></a>
|
|
</div>
|
|
</body>
|
|
</html>
|