mardi 27 mars 2018

Using Boost-Beast (Asio) http client with SSL (HTTPS)

I am new to SSL and the Boost-Beast library, and also C++, but thats a different story. I have a question regarding using HTTPS (SSL) with Beast. I am going to use the library to connect to a REST service and post JSON to a server where I do not control the certificates, the api etc.

And it kind of works. The thing is that I do not clearly understand HOW it works. In the example that comes with Beast it is referenced to a file "example/common/root_certificates.hpp" where it is two certificates in base64 format or somthing like that.

When I tried the example, I got it to work with with POST a JSON string to a server, lets call it "exampleserver.com". Conntected to both port 80 and 443. Even though I commented out the line where it calls the root certificate funtion, "load_root_certificates(ctx);". No errors from handshaking or anything else showed up. And the server responded correctly.

So, my questions are then:

1) Did the Beast library get the certificate from "exampleserver.com" or did I already have it installed and thats why it worked? If so what happens when it expires? Do I have to reinstall a new one on every client that uses my application? I would prefer to not have any hardcoded certificates in my code to check it upon. The certificate says "DigiCert Global Root CA -> DigiCert SHA2 Secure Server CA" is that a standard certificate maybe that comes with the browser?

2) Did it just use plain http over port 443 (no SSL)? Don know if this is possible at all...

Thanks!

Aucun commentaire:

Enregistrer un commentaire