diff --git a/src/ripple/app/main/RPCHTTPServer.cpp b/src/ripple/app/main/RPCHTTPServer.cpp index 37780e4e5..eb8fc5466 100644 --- a/src/ripple/app/main/RPCHTTPServer.cpp +++ b/src/ripple/app/main/RPCHTTPServer.cpp @@ -75,7 +75,13 @@ public: //if (! is_unspecified (ep)) { HTTP::Port port; - port.security = HTTP::Port::Security::allow_ssl; + + if (setup_.secure == 0) + port.security = HTTP::Port::Security::no_ssl; + else if (setup_.secure == 1) + port.security = HTTP::Port::Security::allow_ssl; + else + port.security = HTTP::Port::Security::require_ssl; port.addr = ep.at_port(0); if (setup_.port != 0) port.port = setup_.port; diff --git a/src/ripple/core/Config.h b/src/ripple/core/Config.h index 5b27e3505..0d8436908 100644 --- a/src/ripple/core/Config.h +++ b/src/ripple/core/Config.h @@ -497,7 +497,7 @@ struct Setup int port = 5001; std::string user; std::string password; - bool secure = false; + int secure = 0; std::string ssl_cert; std::string ssl_chain; std::string ssl_key; diff --git a/src/ripple/net/impl/RPCCall.cpp b/src/ripple/net/impl/RPCCall.cpp index 0bde8e7f1..3061aefc2 100644 --- a/src/ripple/net/impl/RPCCall.cpp +++ b/src/ripple/net/impl/RPCCall.cpp @@ -987,29 +987,31 @@ int RPCCall::fromCommandLine (const std::vector& vCmd) } else { + auto setup = setup_RPC (getConfig()["rpc"]); + Json::Value jvParams (Json::arrayValue); jvParams.append (jvRequest); - if (!getConfig ().RPC_ADMIN_USER.empty ()) - jvRequest["admin_user"] = getConfig ().RPC_ADMIN_USER; + if (!setup.admin_user.empty ()) + jvRequest["admin_user"] = setup.admin_user; - if (!getConfig ().RPC_ADMIN_PASSWORD.empty ()) - jvRequest["admin_password"] = getConfig ().RPC_ADMIN_PASSWORD; + if (!setup.admin_password.empty ()) + jvRequest["admin_password"] = setup.admin_password; - boost::asio::io_service isService; + boost::asio::io_service isService; fromNetwork ( isService, - getConfig ().getRpcIP (), - getConfig ().getRpcPort (), - getConfig ().RPC_USER, - getConfig ().RPC_PASSWORD, + setup.ip, + setup.port, + setup.admin_user, + setup.admin_password, "", jvRequest.isMember ("method") // Allow parser to rewrite method. ? jvRequest["method"].asString () : vCmd[0], jvParams, // Parsed, execute. - false, + setup.secure != 0, // Use SSL std::bind (RPCCallImp::callRPCHandler, &jvOutput, std::placeholders::_1)); @@ -1083,15 +1085,16 @@ void RPCCall::fromNetwork ( // Connect to localhost if (!getConfig ().QUIET) { - std::cerr << "Connecting to: " << strIp << ":" << iPort << std::endl; + std::cerr << (bSSL ? "Securely connecting to " : "Connecting to ") << + strIp << ":" << iPort << std::endl; } // HTTP basic authentication - std::string strUserPass64 = RPCParser::EncodeBase64 (strUsername + ":" + strPassword); + auto const auth = RPCParser::EncodeBase64 (strUsername + ":" + strPassword); std::map mapRequestHeaders; - mapRequestHeaders["Authorization"] = std::string ("Basic ") + strUserPass64; + mapRequestHeaders["Authorization"] = std::string ("Basic ") + auth; // Send request