1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>detect_ssl</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="../../index.html" title="Chapter 1. Boost.Beast"> 8<link rel="up" href="../ref.html" title="This Page Intentionally Left Blank 2/2"> 9<link rel="prev" href="boost__beast__buffers_to_string.html" title="buffers_to_string"> 10<link rel="next" href="boost__beast__async_detect_ssl.html" title="async_detect_ssl"> 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="boost__beast__buffers_to_string.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../ref.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost__beast__async_detect_ssl.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h4 class="title"> 27<a name="beast.ref.boost__beast__detect_ssl"></a><a class="link" href="boost__beast__detect_ssl.html" title="detect_ssl">detect_ssl</a> 28</h4></div></div></div> 29<p> 30 <a class="indexterm" name="idm46057512933008"></a> 31 </p> 32<p> 33 Detect a TLS client handshake on a stream. 34 </p> 35<h5> 36<a name="beast.ref.boost__beast__detect_ssl.h0"></a> 37 <span class="phrase"><a name="beast.ref.boost__beast__detect_ssl.synopsis"></a></span><a class="link" href="boost__beast__detect_ssl.html#beast.ref.boost__beast__detect_ssl.synopsis">Synopsis</a> 38 </h5> 39<p> 40 Defined in header <code class="literal"><<a href="../../../../../../boost/beast/core/detect_ssl.hpp" target="_top">boost/beast/core/detect_ssl.hpp</a>></code> 41 </p> 42<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> 43 <span class="keyword">class</span> <a href="../../../../../../doc/html/boost_asio/reference/SyncReadStream.html" target="_top"><span class="emphasis"><em>SyncReadStream</em></span></a><span class="special">,</span> 44 <span class="keyword">class</span> <a class="link" href="../concepts/DynamicBuffer.html" title="DynamicBuffer"><span class="emphasis"><em>DynamicBuffer</em></span></a><span class="special">></span> 45<span class="keyword">bool</span> 46<span class="identifier">detect_ssl</span><span class="special">(</span> 47 <span class="identifier">SyncReadStream</span><span class="special">&</span> <span class="identifier">stream</span><span class="special">,</span> 48 <span class="identifier">DynamicBuffer</span><span class="special">&</span> <span class="identifier">buffer</span><span class="special">,</span> 49 <span class="identifier">error_code</span><span class="special">&</span> <span class="identifier">ec</span><span class="special">);</span> 50</pre> 51<h5> 52<a name="beast.ref.boost__beast__detect_ssl.h1"></a> 53 <span class="phrase"><a name="beast.ref.boost__beast__detect_ssl.description"></a></span><a class="link" href="boost__beast__detect_ssl.html#beast.ref.boost__beast__detect_ssl.description">Description</a> 54 </h5> 55<p> 56 This function reads from a stream to determine if a client handshake message 57 is being received. The call blocks until one of the following is true: 58 </p> 59<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 60<li class="listitem"> 61 A TLS client opening handshake is detected, 62 </li> 63<li class="listitem"> 64 The received data is invalid for a TLS client handshake, or 65 </li> 66<li class="listitem"> 67 An error occurs. 68 </li> 69</ul></div> 70<p> 71 The algorithm, known as a <span class="emphasis"><em>composed operation</em></span>, is implemented 72 in terms of calls to the next layer's <code class="computeroutput"><span class="identifier">read_some</span></code> 73 function. Bytes read from the stream will be stored in the passed dynamic 74 buffer, which may be used to perform the TLS handshake if the detector returns 75 true, or be otherwise consumed by the caller based on the expected protocol. 76 </p> 77<h5> 78<a name="beast.ref.boost__beast__detect_ssl.h2"></a> 79 <span class="phrase"><a name="beast.ref.boost__beast__detect_ssl.parameters"></a></span><a class="link" href="boost__beast__detect_ssl.html#beast.ref.boost__beast__detect_ssl.parameters">Parameters</a> 80 </h5> 81<div class="informaltable"><table class="table"> 82<colgroup> 83<col> 84<col> 85</colgroup> 86<thead><tr> 87<th> 88 <p> 89 Name 90 </p> 91 </th> 92<th> 93 <p> 94 Description 95 </p> 96 </th> 97</tr></thead> 98<tbody> 99<tr> 100<td> 101 <p> 102 <code class="computeroutput"><span class="identifier">stream</span></code> 103 </p> 104 </td> 105<td> 106 <p> 107 The stream to read from. This type must meet the requirements of 108 <span class="emphasis"><em>SyncReadStream</em></span>. 109 </p> 110 </td> 111</tr> 112<tr> 113<td> 114 <p> 115 <code class="computeroutput"><span class="identifier">buffer</span></code> 116 </p> 117 </td> 118<td> 119 <p> 120 The dynamic buffer to use. This type must meet the requirements 121 of <span class="emphasis"><em>DynamicBuffer</em></span>. 122 </p> 123 </td> 124</tr> 125<tr> 126<td> 127 <p> 128 <code class="computeroutput"><span class="identifier">ec</span></code> 129 </p> 130 </td> 131<td> 132 <p> 133 Set to the error if any occurred. 134 </p> 135 </td> 136</tr> 137</tbody> 138</table></div> 139<h5> 140<a name="beast.ref.boost__beast__detect_ssl.h3"></a> 141 <span class="phrase"><a name="beast.ref.boost__beast__detect_ssl.return_value"></a></span><a class="link" href="boost__beast__detect_ssl.html#beast.ref.boost__beast__detect_ssl.return_value">Return 142 Value</a> 143 </h5> 144<p> 145 <code class="computeroutput"><span class="keyword">true</span></code> if the buffer contains 146 a TLS client handshake and no error occurred, otherwise <code class="computeroutput"><span class="keyword">false</span></code>. 147 </p> 148</div> 149<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 150<td align="left"></td> 151<td align="right"><div class="copyright-footer">Copyright © 2016-2019 Vinnie 152 Falco<p> 153 Distributed under the Boost Software License, Version 1.0. (See accompanying 154 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>) 155 </p> 156</div></td> 157</tr></table> 158<hr> 159<div class="spirit-nav"> 160<a accesskey="p" href="boost__beast__buffers_to_string.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../ref.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost__beast__async_detect_ssl.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> 161</div> 162</body> 163</html> 164