ssl for restbed comments added

pull/30/head
moneroexamples 7 years ago
parent 1fb4a44119
commit 0b3f115927

@ -1,8 +1,8 @@
{
"daemon-url" :
{
"mainnet" : "http:://127.0.0.1:18081",
"testnet" : "http:://127.0.0.1:28081"
"mainnet" : "http://127.0.0.1:18081",
"testnet" : "http://127.0.0.1:28081"
},
"blockchain-path" :
{
@ -37,8 +37,9 @@
"ssl" :
{
"enable" : false,
"_comment": "below paths to crt and key files need to be given",
"ssl-crt": "",
"ssl-key": ""
"_comment": "below are example paths to crt and key files need to be given",
"ssl-key": "file:///tmp/server.key",
"ssl-crt": "file:///tmp/server.crt",
"dh-pem" : "file:///tmp/dh2048.pem"
}
}

@ -182,23 +182,31 @@ auto settings = make_shared<Settings>( );
if (config_json["ssl"]["enable"])
{
// based on the example provided at
// https://github.com/Corvusoft/restbed/blob/34187502642144ab9f749ab40f5cdbd8cb17a54a/example/https_service/source/example.cpp
auto ssl_settings = make_shared<SSLSettings>( );
ssl_settings->set_http_disabled( true );
Uri ssl_key = Uri(config_json["ssl"]["ssl-key"].get<string>());
Uri ssl_crt = Uri(config_json["ssl"]["ssl-crt"].get<string>());
Uri dh_pem = Uri(config_json["ssl"]["dh-pem"].get<string>());
ssl_settings->set_http_disabled(true);
ssl_settings->set_port(app_port);
ssl_settings->set_private_key( Uri( "file:///tmp/mwo.key" ) );
ssl_settings->set_certificate( Uri( "file:///tmp/mwo.crt" ) );
ssl_settings->set_temporary_diffie_hellman( Uri( "file:///tmp/dh2048.pem" ) );
ssl_settings->set_private_key(ssl_key);
ssl_settings->set_certificate(ssl_crt);
ssl_settings->set_temporary_diffie_hellman(dh_pem);
settings->set_ssl_settings(ssl_settings);
cout << "Start the service at https://localhost:" << app_port << endl;
// can check using: curl -k -v -w'\n' -X POST 'https://127.0.0.1:1984/get_version'
cout << "Start the service at https://127.0.0.1:" << app_port << endl;
}
else
{
settings->set_port(app_port);
cout << "Start the service at http://localhost:" << app_port << endl;
cout << "Start the service at http://127.0.0.1:" << app_port << endl;
}

Loading…
Cancel
Save