I am currently setting a RESTful API with boost asio.
Connecting from a client works fine via HTTP. But if I try to connect via HTTPS I get an error on the server side: "no shared cipher". The error seems to come from the openssl implementation, but I have no idea what to make of it. My first guess would be that that no cypher algorithm is set, but I cannot see how this can be done in asio.
This is what I put in the code and where the error occurs:
auto acceptHandler = boost::bind(&self::onAccept, this, connection,
boost::asio::placeholders::error);
connection->async_accept(m_acceptor, acceptHandler);
m_sslContext.set_options(
context::default_workarounds | context::no_sslv2 | context::single_dh_use);
m_sslContext.use_certificate_file(filename, context::pem);
m_sslContext.use_private_key_file(filename, context::pem);
Anyone ever had this before or got it working?
I had the same problem and solved it this way.You have to generate a private key and a certificate file for your server. Here is the procedure to do so :
// Generate a new ssl private key :
$openssl genrsa -out privkey.pem 1024
// Create a certificate signing request using your new key
$openssl req -new -key privkey.pem -out certreq.csr
// Self-sign your CSR with your own private key:
$openssl x509 -req -days 3650 -in certreq.csr -signkey privkey.pem -out newcert.pem
// Install the signed certificate and private key for use by an ssl server
// This allows you to use a single file for certificate and private key
$( openssl x509 -in newcert.pem; cat privkey.pem ) > server.pem
// If you use a dh temp file :
$openssl dhparam -outform PEM -out dh512.pem 512
Then, copy the server.pem and dh512.pem files in your server execution directory.
If you use the tmp dh file you also have to add this line of code m_sslContext.use_tmp_dh_file("dh512.pem");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With