ssl suport added

master
moneroexamples 8 years ago
parent d44e0ad385
commit b9067189d5

@ -53,8 +53,8 @@ set_property(TARGET common PROPERTY IMPORTED_LOCATION ${MONERO_LIBS_DIR}/libcomm
add_library(blocks STATIC IMPORTED)
set_property(TARGET blocks PROPERTY IMPORTED_LOCATION ${MONERO_LIBS_DIR}/libblocks.a)
add_library(crypto STATIC IMPORTED)
set_property(TARGET crypto
add_library(cryptoxmr STATIC IMPORTED)
set_property(TARGET cryptoxmr
PROPERTY IMPORTED_LOCATION ${MONERO_LIBS_DIR}/libcrypto.a)
add_library(cryptonote_core STATIC IMPORTED)
@ -163,7 +163,7 @@ target_link_libraries(${PROJECT_NAME}
cryptonote_core
cryptonote_protocol
blockchain_db
crypto
cryptoxmr
blocks
lmdb
ringct
@ -173,4 +173,6 @@ target_link_libraries(${PROJECT_NAME}
unbound
unwind
curl
dl)
dl
crypto
ssl)

@ -1,3 +1,4 @@
#define CROW_ENABLE_SSL
#include "ext/crow/crow.h"
@ -41,11 +42,47 @@ int main(int ac, const char* av[]) {
auto bc_path_opt = opts.get_option<string>("bc-path");
auto custom_db_path_opt = opts.get_option<string>("custom-db-path");
auto deamon_url_opt = opts.get_option<string>("deamon-url");
auto ssl_crt_file_opt = opts.get_option<string>("ssl-crt-file");
auto ssl_key_file_opt = opts.get_option<string>("ssl-key-file");
//cast port number in string to uint16
uint16_t app_port = boost::lexical_cast<uint16_t>(*port_opt);
bool use_ssl {false};
string ssl_crt_file;
string ssl_key_file;
// check if ssl enabled and files exist
if (ssl_crt_file_opt and ssl_key_file_opt)
{
if (!boost::filesystem::exists(boost::filesystem::path(*ssl_crt_file_opt)))
{
cerr << "ssl_crt_file path: " << *ssl_crt_file_opt
<< "does not exist!" << endl;
return EXIT_FAILURE;
}
if (!boost::filesystem::exists(boost::filesystem::path(*ssl_key_file_opt)))
{
cerr << "ssl_key_file path: " << *ssl_key_file_opt
<< "does not exist!" << endl;
return EXIT_FAILURE;
}
ssl_crt_file = *ssl_crt_file_opt;
ssl_key_file = *ssl_key_file_opt;
use_ssl = true;
}
// get blockchain path
path blockchain_path;
@ -271,7 +308,18 @@ int main(int ac, const char* av[]) {
});
// run the crow http server
if (use_ssl)
{
cout << "Staring in ssl mode" << endl;
app.port(app_port).ssl_file(ssl_crt_file, ssl_key_file).multithreaded().run();
}
else
{
cout << "Staring in non-ssl mode" << endl;
app.port(app_port).multithreaded().run();
}
return EXIT_SUCCESS;
}

@ -31,6 +31,10 @@ namespace xmreg
"default port")
("bc-path,b", value<string>(),
"path to lmdb blockchain")
("ssl-crt-file", value<string>(),
"A path to crt file for ssl (https) functionality")
("ssl-key-file", value<string>(),
"A path to key file for ssl (https) functionality")
("custom-db-path,c", value<string>(),
"path to the custom lmdb database used for searching things")
("deamon-url,d", value<string>()->default_value("http:://127.0.0.1:18081"),

Loading…
Cancel
Save