[Boost.Asio] [SSL] Can I set the host name before performing a handshake?
In openssl you call SSL_set_tlsext_host_name to set that Can I do that in boost?
On Sun, 1 May 2022 at 09:11, B Aleck via Boost-users < boost-users@lists.boost.org> wrote:
In openssl you call SSL_set_tlsext_host_name to set that Can I do that in boost?
Yes. Example from one of my projects: asio::awaitable< void > connect(ssl::stream< tcp::socket > &stream, std::string const &host, std::string const &service) { using asio::use_awaitable; co_await connect(stream.next_layer(), host, service); // ==================== Set TLS host name here ==================== if (!SSL_set_tlsext_host_name(stream.native_handle(), host.c_str())) throw sys::system_error(ERR_get_error(), asio::error::get_ssl_category()); // ================================================================ co_await stream.async_handshake(ssl::stream_base::client, use_awaitable); }
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
Thanks a lot. It's helpful ________________________________ 发件人: Boost-users <boost-users-bounces@lists.boost.org> 代表 Richard Hodges via Boost-users <boost-users@lists.boost.org> 发送时间: 2022年5月1日 18:14 收件人: Thomas Quarendon via Boost-users <boost-users@lists.boost.org> 抄送: Richard Hodges <hodges.r@gmail.com> 主题: Re: [Boost-users] [Boost.Asio] [SSL] Can I set the host name before performing a handshake? On Sun, 1 May 2022 at 09:11, B Aleck via Boost-users <boost-users@lists.boost.org<mailto:boost-users@lists.boost.org>> wrote: In openssl you call SSL_set_tlsext_host_name to set that Can I do that in boost? Yes. Example from one of my projects: asio::awaitable< void > connect(ssl::stream< tcp::socket > &stream, std::string const &host, std::string const &service) { using asio::use_awaitable; co_await connect(stream.next_layer(), host, service); // ==================== Set TLS host name here ==================== if (!SSL_set_tlsext_host_name(stream.native_handle(), host.c_str())) throw sys::system_error(ERR_get_error(), asio::error::get_ssl_category()); // ================================================================ co_await stream.async_handshake(ssl::stream_base::client, use_awaitable); } _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org<mailto:Boost-users@lists.boost.org> https://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
B Aleck
-
Richard Hodges