Betfair API'ing Certificate login using C++ boost SSL Sockets

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cm0use
    Junior Member
    • Feb 2019
    • 6

    #1

    Betfair API'ing Certificate login using C++ boost SSL Sockets

    Firstly, thanks for coming here. I'm trying to login with betfair using a certificate login using boost's ssl sockets however, once I send my http login POST, I receive the message CERT_AUTH_REQUIRED. On the betfair website it says this means "Certificate required or certificate present but could not authenticate with it". I am able to connect, handshake and send/receive data. However, I just can't seem to login with my code. I've tested the exact certificates using curl without any problems.
    Code:
     
      * 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
    I have further tested these certificates with python code that also works. My C++ code is below. I've tried sending incorrect passwords which result in the status from server INVALID_USERNAME_OR_PASSWORD instead.


    Code:
     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);
    Many thanks in advance
    Last edited by cm0use; 06-03-2019, 01:29 PM.
  • cm0use
    Junior Member
    • Feb 2019
    • 6

    #2
    Sorry, c++ code didn't format correctly

    Code:
        boost::asio::ssl::context ctx(boost::asio::ssl::context::tlsv12);
    
        // load certificates
        ctx.load_verify_file(cert_filename.c_str());
        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);

    Comment

    Working...
    X