Я использую http proxy-sever с boost libs.Например: WebBrowser <-> Socket-ProxyServer <-> http-сервер.Это нормально работает.Но у меня есть SSL-сертификат, и его нужно добавить на мой Proxy-сервер.Мой код:
proxy-server.cpp:
server::server(const ios_deque& io_services, int port, std::string interface_address, int num)
: io_services_(io_services),
endpoint_(interface_address.empty()?
(ba::ip::tcp::endpoint(ba::ip::tcp::v4(), port)):
ba::ip::tcp::endpoint(ba::ip::address().from_string(interface_address), port) ),
acceptor_(*io_services.front(), endpoint_)
{
start_accept(num);
}
void server::start_accept(int num) {
io_services_.push_back(io_services_.front());
io_services_.pop_front();
connection::pointer new_connection = connection::create(*io_services_.front());
acceptor_.async_accept(new_connection->socket(),
boost::bind(&server::handle_accept, this, new_connection,
ba::placeholders::error, num));
}
void server::handle_accept(connection::pointer new_connection, const bs::error_code& error, int num) {
if (!error) {
new_connection->start(GlobalSett.CheckIp(inet_addr(new_connection->socket().remote_endpoint().address().to_string().c_str())), num);
start_accept(num);
}
}
proxy-server.hpp:
typedef std::deque<io_service_ptr> ios_deque;
class server {
public:
server(const ios_deque& io_services, int port, std::string interface_address, int);
private:
void start_accept(int);
void handle_accept(connection::pointer new_connection, const bs::error_code& error, int);
ios_deque io_services_;
const ba::ip::tcp::endpoint endpoint_;
ba::ip::tcp::acceptor acceptor_;
function FUNC;
};
и запуск сервера:
try {
int thread_num = atoi(GlobalSett.GetSetConfig("PROXY_THREAD[" + std::to_string(num) + "]")), port = atoi(GlobalSett.GetSetConfig("PROXY_LISTNER_PORT["+std::to_string(num)+"]"));
std::string interface_address = GlobalSett.GetSetConfig("PROXY_LISTNER_IP["+ std::to_string(num)+"]");
ios_deque io_services;
std::deque<ba::io_service::work> io_service_work;
boost::thread_group thr_grp;
for (int i = 0; i < thread_num; ++i) {
io_service_ptr ios(new ba::io_service);
io_services.push_back(ios);
io_service_work.push_back(ba::io_service::work(*ios));
thr_grp.create_thread(boost::bind(&ba::io_service::run, ios));
}
server server(io_services, port, interface_address, num);
thr_grp.join_all();
}
catch (std::exception& e) {
std::cerr << e.what() << std::endl;
}
Необходимо добавить ssl в сокет сервера.Кто-нибудь может помочь с этим?Спасибо!