3
我的代碼大部分基於boost ssl示例客戶端,但是我已經完全同步了,但boost的例子仍然會做同樣的事情。OpenSSL Boost context.use_private_key_file和context.use_rsa_private_key_file毫無例外地終止程序
加載server.pem sslContext.load_verify_file("server.pem");
後,我嘗試加載客戶端密鑰和CRT服務器驗證,爲雙向握手。
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);
當我進入它的程序終止use_private_key_file或use_rsa_private_key_file被稱爲是需要密碼。爲什麼是這樣? - 我的密碼是正確的我已經檢查過
構造函數將是boost示例的唯一更改,這是我如何使用它來進行正常的SSL握手。
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();
}
對於雙向握手。
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();
}