[Qt-interest] https with self-signing cert

Bryce Allen qt at bda.ath.cx
Fri Feb 5 01:59:23 CET 2010


I'm trying to POST to a page with https, and the server uses a
self-signing cert. I've tried many approaches and I can't get the error
ignored. Has anyone had success with this? I am using Qt 4.6.0 on linux
amd64, from the debian experimental repository.

The first approach I tried was ignoring the self-signing error with the
certificate specified, as suggested in the docs.
http://doc.qt.nokia.com/4.6/qnetworkreply.html#ignoreSslErrors-2

Next I tried omitting the certificate:

QSslError error(QSslError::SelfSignedCertificate);
QList<QSslError> expectedSslErrors;
expectedSslErrors.append(error);
QNetworkReply *reply =
   manager.get(QNetworkRequest(QUrl("https://localhost/")));
reply->ignoreSslErrors(expectedSslErrors);

Finally I tried setPeerVerifyMode(QSslSocket::VerifyNone) on the
QNetworkRequest object. This at least is not advertised to work:
http://doc.qt.nokia.com/4.6/qnetworkrequest.html#setSslConfiguration
"The settings that apply are the private key, the local certificate,
the SSL protocol (SSLv2, SSLv3, TLSv1 where applicable) and the ciphers
that the SSL backend is allowed to use."

PeerVerifyMode is not in that list, and of course the error is still
triggered and the request fails.

QNetworkRequest request;
request.setUrl(QUrl("https://localhost/post.php"));
request.setHeader(QNetworkRequest::ContentTypeHeader,
                  "application/x-www-form-urlencoded");
QSslConfiguration config = QSslConfiguration::defaultConfiguration();
config.setPeerVerifyMode(QSslSocket::VerifyNone);
request.setSslConfiguration(config);

Any ideas?

Thanks,
Bryce



More information about the Qt-interest-old mailing list