My code is mostly based off the boost ssl example client however I have made it completely synchronous but the example from boost will still do the same thing.
After loading the server.pem sslContext.load_verify_file("server.pem");
I try to load the clients key and crt for the server to verify, for the two way handshake.
context_.use_private_key_file("client.key",boost::asio::ssl::context_base::file_format::pem); // also tried use_rsa_private_key_file
context_.use_certificate_file("client.crt",boost::asio::ssl::context_base::file_format::pem);
When use_private_key_file or use_rsa_private_key_file is called a password is requested when I enter it the program terminates. Why is this? – My password is correct I have checked it with openssl rsa -check -in client.key
The constructor will be the only change to the boost example this is how I would use it for normal SSL handshaking.
server(boost::asio::io_service& io_service, unsigned short port)
: io_service_(io_service),
acceptor_(io_service,
boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), port)),
context_(boost::asio::ssl::context::sslv23)
{
context_.load_verify_file("server.pem");
start_accept();
}
For two way handshaking.
server(boost::asio::io_service& io_service, unsigned short port)
: io_service_(io_service),
acceptor_(io_service,
boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), port)),
context_(boost::asio::ssl::context::sslv23)
{
context_.load_verify_file("server.pem");
context_.use_private_key_file("client.key",boost::asio::ssl::context_base::file_format::pem); // also tried use_rsa_private_key_file
context_.use_certificate_file("client.crt",boost::asio::ssl::context_base::file_format::pem);
start_accept();
}
This failed every time when entering the password using console. However was fine when I used the callback
set_password_callback(boost::bind(&get_password, this));it worked fine.