我正在使用Boost Beast连接到一个Web Socket服务器,但是我一直收到一个错误

Resolving push-private.kucoin.com:443...

Performing SSL handshake...

terminate called after throwing an instance of 'boost::wrapexcept<:system::system_error>'

what(): handshake: sslv3 alert handshake failure

Aborted (core dumped)

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include "root_certificates.hpp"

using namespace std;

namespace beast = boost::beast; // from

namespace http = beast::http; // from

namespace websocket = beast::websocket; // from

namespace net = boost::asio; // from

namespace ssl = boost::asio::ssl; // from

using tcp = boost::asio::ip::tcp; // from

int main() {

// for a new token, make a POST request to https://api.kucoin.com/api/v1/bullet-public

const auto token = "2neAiuYvAU61ZDXANAGAsiL4-iAExhsBXZxftpOeh_55i3Ysy2q2LEsEWU64mdzUOPusi34M_wGoSf7iNyEWJ3XLno4x6QqZaEm7Ya4KUfToabAuI1Do9tiYB9J6i9GjsxUuhPw3BlrzazF6ghq4L2ls_Ixv_6qQ8ZRhwt_6WmM=.ianWlE3VQZogjKRmJ-tpyg==";

auto const host = "push-private.kucoin.com";

auto const port = "443";

auto const text = "hello world";

// The io_context is required for all I/O

net::io_context ioc;

// The SSL context is required, and holds certificates

boost::asio::ssl::context ctx(boost::asio::ssl::context::sslv23);

ctx.set_options(

boost::asio::ssl::context::default_workarounds

| boost::asio::ssl::context::no_sslv2

| boost::asio::ssl::context::no_sslv3

);

ctx.set_default_verify_paths();

// This holds the root certificate used for verification

load_root_certificates(ctx);

// These objects perform our I/O

tcp::resolver resolver{ioc};

websocket::stream<:ssl_stream>> ws{ioc, ctx};

// Look up the domain name

cout << "Resolving " << host << ":" << port << "..." << endl;

auto const results = resolver.resolve(host, port);

// Make the connection on the IP address we get from a lookup

net::connect(ws.next_layer().next_layer(), results.begin(), results.end());

// Perform the SSL handshake

cout << "Performing SSL handshake..." << endl;

ws.next_layer().handshake(ssl::stream_base::client);

// Set a decorator to change the User-Agent of the handshake

ws.set_option(websocket::stream_base::decorator([](websocket::request_type& req){

req.set(http::field::user_agent,

std::string(BOOST_BEAST_VERSION_STRING) +

" websocket-client-coro");

}));

// Perform the websocket handshake

cout << "Performing the websocket handshake..." << endl;

ws.handshake(host, "/endpoint");

// Send the message

cout << "Sending '" << text << "'..." << endl;

ws.write(net::buffer(std::string(text)));

// This buffer will hold the incoming message

beast::flat_buffer buffer;

// Read a message into our buffer

cout << "Waiting for web socket server to respond..." << endl;

ws.read(buffer);

// Close the WebSocket connection

ws.close(websocket::close_code::normal);

// The make_printable() function helps print a ConstBufferSequence

cout << "This is the data received from the server:" << endl;

std::cout << beast::make_printable(buffer.data()) << std::endl;

return 0;

}

编译选项:

g++ -std=c++17 test.cpp -l boost_system -l crypto -l ssl -pthread && ./a.out

gcc版本9.1.0(Ubuntu9.1.0-2ubuntu2~19.04)

任何建议都将不胜感激。

php sslv3握手失败,Boost Beast握手:sslv3警报握手失败错误相关推荐

  1. mysql 挑战握手协议_[中文协议]PPP挑战握手认证协议(CHAP)

    组织:中国互动出版网(http://www.china-pub.com/) RFC文档中文翻译计划(http://www.china-pub.com/compters/emook/aboutemook ...

  2. 基于Boost::beast模块的异步HTTP客户端

    基于Boost::beast模块的异步HTTP客户端 实现功能 C++实现代码 实现功能 基于Boost::beast模块的异步HTTP客户端 C++实现代码 #include <boost/b ...

  3. 基于Boost::beast模块的HTTP客户端协程

    基于Boost::beast模块的异步HTTP客户端协程 实现功能 C++实现代码 实现功能 基于Boost::beast模块的HTTP客户端协程 C++实现代码 #include <boost ...

  4. 基于Boost::beast模块的同步HTTP客户端

    Boost:基于Boost::beast模块的同步HTTP客户端 实现功能 C++实现代码 实现功能 基于Boost::beast模块的同步HTTP客户端 C++实现代码 #include <b ...

  5. 基于Boost::beast模块的协程HTTP服务器

    Boost:基于Boost::beast模块的协程HTTP服务器 实现功能 C++实现代码 实现功能 基于Boost::beast模块的协程HTTP服务器 C++实现代码 #include <b ...

  6. 基于Boost::beast模块的小型http服务器

    基于Boost::beast模块的小型http服务器 实现功能 C++实现代码 实现功能 基于Boost::beast模块的小型http服务器 C++实现代码 #include <boost/b ...

  7. 基于Boost::beast模块的无栈协程http服务器

    基于Boost::beast模块的无栈协程http服务器 实现功能 C++实现代码 实现功能 基于Boost::beast模块的无栈协程http服务器 C++实现代码 #include <boo ...

  8. 基于Boost::beast模块的同步http服务器

    基于Boost::beast模块的同步http服务器 实现功能 C++实现代码 实现功能 基于Boost::beast模块的同步http服务器 C++实现代码 #include <boost/b ...

  9. 基于Boost::beast模块的异步WebSocket客户端

    基于Boost::beast模块的异步WebSocket客户端 实现功能 C++实现代码 实现功能 基于Boost::beast模块的异步WebSocket客户端 C++实现代码 #include & ...

最新文章

  1. python下载软件-python下载工具
  2. 全连接条件随机场_CRF条件随机场
  3. Codeforces698B【并查集+拆环】
  4. spring timetask 定时任务调度
  5. Devoxx的Red Hat Engineers提供了更多Java EE
  6. float去掉小数点之后_float类型的存储方式
  7. opensource项目_最佳Opensource.com:业务
  8. 4怎样判断动作是否执行_汽车驾驶怎样试验高压火,怎样判断分电器盖是否破裂,来看看吧!...
  9. [10.2模拟] book
  10. 【Spark Summit EU 2016】Glint: Spark的异步参数服务器
  11. 计算机云平台架构,基于虚拟化技术的云计算平台架构研究
  12. bug引发的惨案,拼多多100元话费只需4毛钱,损失上千亿……
  13. CentOS 7查看源代码
  14. MyCat相关知识及测试要点
  15. iOS中UIColor,CGColor,CIColor详解
  16. 华为云linux登录用户名密码,华为云Linux服务器安装宝塔Linux面板详细图文教程
  17. 欧拉角中各种角度的名称
  18. python文件路径path
  19. 点云库pcl从入门到精通 第十章
  20. gdb @entry= 是什么意思

热门文章

  1. SAP ABAP打印MM采购发票打印开发
  2. c语言 %15s,c语言求助
  3. cv2 imwrite中文路径_python3下使用cv2.imwrite存储带有中文路径图片的方法
  4. epp是什么意思_什么是1K/2K/3K注塑?
  5. MySQL 排名函数.md
  6. js中立即执行函数会预编译吗_作为前端你了解JavaScript运行机制吗?
  7. 流放之路材质过滤怎么设置_松下除湿机怎么样 松下除湿机款式有哪些型号【详解】...
  8. linux用户开放crontab权限,linux – / etc / crontab权限
  9. 让apache解析html里的php代码,让Apache解析html文件中的php语句
  10. java windows 2008_Windows server 2008 R2 安装Java环境