[ACCEPTED]-Exception running boost asio ssl example-boost-asio
OK, for anyone finding this in the future, you 9 need to create your certificates and sign 8 them appropriately. Here are the commands 7 for linux:
//Generate a private key
openssl genrsa -des3 -out server.key 1024
//Generate 6 Certificate signing request
openssl req -new -key server.key -out server.csr
//Sign certificate 5 with private key
openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt
//Remove password requirement 4 (needed for example)
cp server.key server.key.secure
openssl rsa -in server.key.secure -out server.key
//Generate dhparam file
openssl dhparam -out dh512.pem 512
Once 3 you've done that, you need to change the 2 filenames in server.cpp and client.cpp.
server.cpp
context_.use_certificate_chain_file("server.crt");
context_.use_private_key_file("server.key", boost::asio::ssl::context::pem);
context_.use_tmp_dh_file("dh512.pem");
client.cpp
ctx.load_verify_file("server.crt");
Then 1 it should all work!
Execute the tests again with strace to see 9 which syscall gets the EINVAL
, as a bonus you'll 8 get to see the args for the failing call. It's 7 likely part of the security context setup 6 that's failing, unless you have the right 5 files and data from the example:
context_.use_certificate_chain_file("server.pem");
context_.use_private_key_file("server.pem", boost::asio::ssl::context::pem);
context_.use_tmp_dh_file("dh512.pem");
You were 4 getting EPERM
because you were trying to bind 3 to a privileged TCP port (one whose value 2 is less than 1024). That's why ./server 10000
does not 1 get EPERM
.
When following the answer of @Shootfast an error appered: 'bad 7 SSL configuration: use_certificate_chain_file: ee 6 key too small'
Changing the first line:
openssl genrsa -des3 -out server.key 1024
to:
openssl genrsa -des3 -out server.key 2048
fixed 5 it for me.
After that I got the error: 'bad 4 SSL configuration: use_private_key_file: no 3 start line' the reason and solution to this 2 is explained here: solution (It is more or less 1 the reason for the last command of @Shootfast answer.)
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.