mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-03 01:15:53 +00:00
Use better base64 handling in ServerHandlerImp.
This commit is contained in:
@@ -28,6 +28,7 @@
|
|||||||
#include <ripple/overlay/Overlay.h>
|
#include <ripple/overlay/Overlay.h>
|
||||||
#include <ripple/resource/Manager.h>
|
#include <ripple/resource/Manager.h>
|
||||||
#include <ripple/resource/Fees.h>
|
#include <ripple/resource/Fees.h>
|
||||||
|
#include <beast/crypto/base64.h>
|
||||||
#include <beast/cxx14/algorithm.h> // <algorithm>
|
#include <beast/cxx14/algorithm.h> // <algorithm>
|
||||||
#include <beast/http/rfc2616.h>
|
#include <beast/http/rfc2616.h>
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
@@ -307,25 +308,6 @@ ServerHandlerImp::isWebsocketUpgrade (beast::http::message const& request)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// VFALCO DEPRECATED
|
|
||||||
static std::string
|
|
||||||
DecodeBase64 (std::string s)
|
|
||||||
{
|
|
||||||
// FIXME: This performs badly
|
|
||||||
BIO* b64, *bmem;
|
|
||||||
// Its 2014 and we're using calloc?
|
|
||||||
char* buffer = static_cast<char*> (calloc (s.size (), sizeof (char)));
|
|
||||||
b64 = BIO_new (BIO_f_base64 ());
|
|
||||||
BIO_set_flags (b64, BIO_FLAGS_BASE64_NO_NL);
|
|
||||||
bmem = BIO_new_mem_buf (const_cast<char*> (s.data ()), s.size ());
|
|
||||||
bmem = BIO_push (b64, bmem);
|
|
||||||
BIO_read (bmem, buffer, s.size ());
|
|
||||||
BIO_free_all (bmem);
|
|
||||||
std::string result (buffer);
|
|
||||||
free (buffer);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// VFALCO TODO Rewrite to use beast::http::headers
|
// VFALCO TODO Rewrite to use beast::http::headers
|
||||||
bool
|
bool
|
||||||
ServerHandlerImp::authorized (HTTP::Port const& port,
|
ServerHandlerImp::authorized (HTTP::Port const& port,
|
||||||
@@ -339,7 +321,7 @@ ServerHandlerImp::authorized (HTTP::Port const& port,
|
|||||||
return false;
|
return false;
|
||||||
std::string strUserPass64 = it->second.substr (6);
|
std::string strUserPass64 = it->second.substr (6);
|
||||||
boost::trim (strUserPass64);
|
boost::trim (strUserPass64);
|
||||||
std::string strUserPass = DecodeBase64 (strUserPass64);
|
std::string strUserPass = beast::base64_decode (strUserPass64);
|
||||||
std::string::size_type nColon = strUserPass.find (":");
|
std::string::size_type nColon = strUserPass.find (":");
|
||||||
if (nColon == std::string::npos)
|
if (nColon == std::string::npos)
|
||||||
return false;
|
return false;
|
||||||
@@ -595,7 +577,7 @@ to_Port(ParsedPort const& parsed, std::ostream& log)
|
|||||||
throw std::exception();
|
throw std::exception();
|
||||||
}
|
}
|
||||||
p.protocol = parsed.protocol;
|
p.protocol = parsed.protocol;
|
||||||
if (p.websockets() &&
|
if (p.websockets() &&
|
||||||
(parsed.protocol.count("peer") > 0 ||
|
(parsed.protocol.count("peer") > 0 ||
|
||||||
parsed.protocol.count("http") > 0 ||
|
parsed.protocol.count("http") > 0 ||
|
||||||
parsed.protocol.count("https") > 0))
|
parsed.protocol.count("https") > 0))
|
||||||
|
|||||||
Reference in New Issue
Block a user