cpprestsdk
cpprestsdk copied to clipboard
https request handling with listener
Is the listener supposed to be able to handle https requests? When I try a basic test using curl to connect to the http listener sample I get this:
curl --request POST https://localhost:9080/A/B/C curl: (35) OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to localhost:9080
I'm initializing the http_listener with the URI "https://127.0.0.1:9080" When I use http it works fine. I'm testing on Linux
Same problem here! @aprole did you find a solution?
No, I actually switched to using Restbed instead. Works much better and is stable. I would recommend it.
No, I actually switched to using Restbed instead. Works much better and is stable. I would recommend it.
Thanks @aprole ;) Restbed does seems much easier to use.
But just in case anyone else has this issue you need to provide the SSL certificated when creating the listener:
http_listener_config config;
config.set_ssl_context_callback([](boost::asio::ssl::context& context) {
context.use_certificate_chain_file("server.pem");
context.use_private_key_file("server_key.pem", boost::asio::ssl::context::pem);
});
_listener = http_listener(endpointBuilder.to_uri(), config);
Cheers
No, I actually switched to using Restbed instead. Works much better and is stable. I would recommend it.
Thanks @aprole ;) Restbed does seems much easier to use.
But just in case anyone else has this issue you need to provide the SSL certificated when creating the listener:
http_listener_config config; config.set_ssl_context_callback([](boost::asio::ssl::context& context) { context.use_certificate_chain_file("server.pem"); context.use_private_key_file("server_key.pem", boost::asio::ssl::context::pem); }); _listener = http_listener(endpointBuilder.to_uri(), config);
Cheers
seems it does NOT work on window?
No, I actually switched to using Restbed instead. Works much better and is stable. I would recommend it.
Thanks @aprole ;) Restbed does seems much easier to use. But just in case anyone else has this issue you need to provide the SSL certificated when creating the listener:
http_listener_config config; config.set_ssl_context_callback([](boost::asio::ssl::context& context) { context.use_certificate_chain_file("server.pem"); context.use_private_key_file("server_key.pem", boost::asio::ssl::context::pem); }); _listener = http_listener(endpointBuilder.to_uri(), config);
Cheers
seems it does NOT work on window?
Have you addressed the problem?
Anyone else face issue when you need to provide the SSL certificated while creating the listener and validating client certificate on server side. Here my code...[call back function never got hit]
http_listener_config config; config.set_ssl_context_callback([](boost::asio::ssl::context &ctx) { try { std::clog << "set_ssl_context_callback" << std::endl; ctx.set_options( boost::asio::ssl::context::default_workarounds | boost::asio::ssl::context::no_sslv2 | boost::asio::ssl::context::no_tlsv1 | boost::asio::ssl::context::no_tlsv1_1 | boost::asio::ssl::context::single_dh_use); ctx.set_password_callback([](std::size_t max_length, boost::asio::ssl::context::password_purpose purpose) { return "password"; }); ctx.use_certificate_chain_file("F://certificate.crt"); ctx.use_private_key_file("F://certificate.key", boost::asio::ssl::context::pem); } catch (std::exception const& e) { std::clog << "ERROR: " << e.what() << "\n"; }
});