asio: client::configure_tls_context takes error_code

This commit is contained in:
Tatsuhiro Tsujikawa 2015-03-06 23:24:59 +09:00
parent 018e9eaf6d
commit d7cfe464a2
4 changed files with 14 additions and 4 deletions

View File

@ -34,13 +34,14 @@ using namespace nghttp2::asio_http2::client;
int main(int argc, char *argv[]) {
try {
boost::system::error_code ec;
boost::asio::io_service io_service;
boost::asio::ssl::context tls_ctx(boost::asio::ssl::context::sslv23);
tls_ctx.set_default_verify_paths();
// disabled to make development easier...
// tls_ctx.set_verify_mode(boost::asio::ssl::verify_peer);
configure_tls_context(tls_ctx);
configure_tls_context(ec, tls_ctx);
session sess(io_service, tls_ctx, "localhost", "3000");
sess.on_connect([&sess](tcp::resolver::iterator endpoint_it) {

View File

@ -58,13 +58,14 @@ void print_header(const request &req) {
int main(int argc, char *argv[]) {
try {
boost::system::error_code ec;
boost::asio::io_service io_service;
boost::asio::ssl::context tls_ctx(boost::asio::ssl::context::sslv23);
tls_ctx.set_default_verify_paths();
// disabled to make development easier...
// tls_ctx.set_verify_mode(boost::asio::ssl::verify_peer);
configure_tls_context(tls_ctx);
configure_tls_context(ec, tls_ctx);
session sess(io_service, tls_ctx, "localhost", "3000");
sess.on_connect([&sess](tcp::resolver::iterator endpoint_it) {

View File

@ -47,10 +47,16 @@ int client_select_next_proto_cb(SSL *ssl, unsigned char **out,
}
} // namespace
void configure_tls_context(boost::asio::ssl::context &tls_ctx) {
boost::system::error_code
configure_tls_context(boost::system::error_code &ec,
boost::asio::ssl::context &tls_ctx) {
ec.clear();
auto ctx = tls_ctx.native_handle();
SSL_CTX_set_next_proto_select_cb(ctx, client_select_next_proto_cb, nullptr);
return ec;
}
} // namespace client

View File

@ -173,7 +173,9 @@ private:
// configure |tls_ctx| for client use. Currently, we just set NPN
// callback for HTTP/2.
void configure_tls_context(boost::asio::ssl::context &tls_ctx);
boost::system::error_code
configure_tls_context(boost::system::error_code &ec,
boost::asio::ssl::context &tls_ctx);
} // namespace client