Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用C++ Boost SSL套接字登录BETFAL APIE证书_C++_Ssl_Https_Boost Asio - Fatal编程技术网

使用C++ Boost SSL套接字登录BETFAL APIE证书

使用C++ Boost SSL套接字登录BETFAL APIE证书,c++,ssl,https,boost-asio,C++,Ssl,Https,Boost Asio,首先,谢谢你来这里。我正在尝试使用boost的ssl套接字使用证书登录登录betfair,但是,一旦我发送http登录帖子,我就会收到所需的CERT_AUTH_消息。在betfair网站上,它表示这意味着需要证书或证书存在,但无法使用它进行身份验证。 我能够连接、握手和发送/接收数据。然而,我似乎无法用我的代码登录。我使用curl测试了确切的证书,没有任何问题 * ALPN, server accepted to use http/1.1 * Server certificate: *

首先,谢谢你来这里。我正在尝试使用boost的ssl套接字使用证书登录登录betfair,但是,一旦我发送http登录帖子,我就会收到所需的CERT_AUTH_消息。在betfair网站上,它表示这意味着需要证书或证书存在,但无法使用它进行身份验证。 我能够连接、握手和发送/接收数据。然而,我似乎无法用我的代码登录。我使用curl测试了确切的证书,没有任何问题

* ALPN, server accepted to use http/1.1
* Server certificate:
*        subject: C=IE; ST=Leinster; L=Dublin; O=Paddy Power Betfair Public Limi
ted Company; OU=IT Networks; CN=betfair.com
*        start date: Sep 11 05:50:38 2018 GMT
*        expire date: Sep 11 05:59:00 2020 GMT
*        issuer: C=US; O=HydrantID (Avalanche Cloud Corporation); CN=HydrantID S
SL ICA G2
*        SSL certificate verify result: self signed certificate in certificate c
hain (19), continuing anyway.
> POST /api/certlogin HTTP/1.1
> Host: identitysso-cert.betfair.com
> User-Agent: curl/7.46.0
> Accept: */*
> X-Application: AOxcQMZwVN3jOsLZ4
> Content-Length: 41
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 41 out of 41 bytes
< HTTP/1.1 200 OK
< Content-Type: text/plain;charset=ISO-8859-1
< Content-Length: 87
< Date: Wed, 06 Mar 2019 11:09:35 GMT
<
{"sessionToken":"ZFbyo3HeAh07UFTHzhhGjOyQFeX2MKdHHHHtAm2S7FXw=","loginStatus":"SU
CCESS"}* Connection #0 to host identitysso-cert.betfair.com left intact
我用同样有效的python代码进一步测试了这些证书。 我的C++代码如下。我尝试发送不正确的密码,这会导致服务器状态变为无效的\u用户名\u或\u密码

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

// load certificates
ctx.load_verify_file(cert_filename.c_str());
// ctx.use_private_key_file(private_filename.c_str(), boost::asio::ssl::context::pem);
ctx.use_rsa_private_key_file(private_filename.c_str(), boost::asio::ssl::context::pem);

mSocket.reset(new boost::asio::ssl::stream<tcp::socket>(mIoService, ctx));
mSocket->set_verify_mode(boost::asio::ssl::verify_peer);
mSocket->set_verify_callback(
    boost::bind(&BetfairSession::VerifyCertificate, this, _1, _2));

tcp::resolver resolver(mIoService);
tcp::resolver::query query("identitysso-cert.betfair.com", port);
tcp::resolver::iterator endpointIter = resolver.resolve(query);

提前非常感谢:

我认为您混淆了客户证书和CA列表

这:

正在加载CA证书列表以验证服务器证书

您可以在此处找到此列表的示例:

您还需要设置用于SSL连接的证书,您可以使用use\u certificate\u chain\u file方法进行设置。 e、 g


+非常感谢你!!!!这就成功了。我添加了ctx.use\u certificate\u chain\u文件,它立即生效:
ctx.load_verify_file(cert_filename.c_str());
ctx.use_certificate_chain_file(cert_filename.c_str());