I'm trying to get HTTPS running using the POCO library using this little program:
int main()
{
// For debugging purposes to inspect verification errors.
SharedPtr<InvalidCertHandler> invalidCertHandler(new InvalidCertHandler());
URI uri("https://google.com/");
Context::Ptr ctx = new Context(Context::CLIENT_USE, "", Context::VerificationMode::VERIFY_RELAXED, 9, true);
SSLManager::instance().initializeClient(nullptr, invalidCertHandler, ctx);
HTTPSClientSession httpSession(uri.getHost(), uri.getPort(), ctx);
HTTPRequest request(HTTPRequest::HTTP_GET, uri.getPath(), HTTPRequest::HTTP_1_1);
HTTPResponse response;
try
{
httpSession.sendRequest(request);
httpSession.receiveResponse(response);
}
catch (Exception ex)
{
cout << ex.message() << endl;
return -1;
}
cout << "Success" << endl;
return 0;
}
Unfortunately I always get the following exception message when running the program:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed
And the following message in my InvalidCertHandler:
unable to get local issuer certificate
After that I opened https://google.com/in Google Chrome and exported the certificate in Base64-encoded X.509 Format (.CER) and initialized the Context with the absolute path of the .cer file instead of just an empty string. That didn't work too.
I don't know what I'm doing wrong here but I would like to know.
Can anyone of you help me out on this?
Aucun commentaire:
Enregistrer un commentaire