I am trying to connect to rest service that has ssl certificates. I have those certificates files(cacert.pem and another file .pem) locally.
For this purpose I use qt library.
I can connect to a rest service without certificates but I cannot connect to a service with certificates.
I try this code(having the certificate in the release folder of the project)
QNetworkAccessManager *m_network = new QNetworkAccessManager(this);
QNetworkRequest request;
wapi_url.setPort(8082);
request.setUrl(wapi_url);
QSslConfiguration SslConfiguration(QSslConfiguration::defaultConfiguration());
QList<QSslCertificate> caList = SslConfiguration.caCertificates();
caList.append(QSslCertificate("cacert.pem")); //Root CA
SslConfiguration.setCaCertificates(caList);
SslConfiguration.setLocalCertificate(QSslCertificate("bla_bla_server.pem"));
SslConfiguration.setProtocol(QSsl::SslV3);
SslConfiguration.setPeerVerifyMode(QSslSocket::VerifyPeer);
request.setSslConfiguration(SslConfiguration);
QNetworkReply *reply = m_network->get(request);
QNetworkAccessManager *m_network = new QNetworkAccessManager(this);
QNetworkRequest request;
QUrl wapi_url=QUrl("...");
wapi_url.setPort(8082);
request.setUrl(wapi_url);
QSslConfiguration SslConfiguration(QSslConfiguration::defaultConfiguration());
QList<QSslCertificate> caList = SslConfiguration.caCertificates();
caList.append(QSslCertificate("cacert.pem")); //Root CA
SslConfiguration.setCaCertificates(caList);
SslConfiguration.setLocalCertificate(QSslCertificate("bla_bla_server.pem"));
SslConfiguration.setProtocol(QSsl::SslV3);
SslConfiguration.setPeerVerifyMode(QSslSocket::VerifyPeer);
request.setSslConfiguration(SslConfiguration);
QNetworkReply *reply = m_network->get(request);
To copy to clipboard, switch view to plain text mode
but I get a SSL handshake failed error.
Any idea how can I pass this error and connect to the rest service?
Bookmarks