日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

php sslv3握手失败,Boost Beast握手:sslv3警报握手失败错误

發布時間:2025/3/15 php 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php sslv3握手失败,Boost Beast握手:sslv3警报握手失败错误 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

我正在使用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警报握手失败错误的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。