summaryrefslogtreecommitdiffstats
path: root/tests/auto/qsslsocket/tst_qsslsocket.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qsslsocket/tst_qsslsocket.cpp')
-rw-r--r--tests/auto/qsslsocket/tst_qsslsocket.cpp34
1 files changed, 32 insertions, 2 deletions
diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp
index 7f613241a0..ee2d15b1ff 100644
--- a/tests/auto/qsslsocket/tst_qsslsocket.cpp
+++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp
@@ -54,9 +54,10 @@
#include <QNetworkProxy>
#include <QAuthenticator>
-#include <private/qhostinfo_p.h>
+#include "private/qhostinfo_p.h"
#ifndef QT_NO_OPENSSL
-# include <private/qsslsocket_openssl_p.h>
+#include "private/qsslsocket_openssl_p.h"
+#include "private/qsslsocket_openssl_symbols_p.h"
#endif
#include "../network-settings.h"
@@ -148,6 +149,7 @@ private slots:
void peerCertificate();
void peerCertificateChain();
void privateKey();
+ void privateKeyOpaque();
void protocol();
void protocolServerSide_data();
void protocolServerSide();
@@ -766,6 +768,34 @@ void tst_QSslSocket::privateKey()
{
}
+void tst_QSslSocket::privateKeyOpaque()
+{
+ if (!QSslSocket::supportsSsl())
+ return;
+
+ QFile file(SRCDIR "certs/fluke.key");
+ QVERIFY(file.open(QIODevice::ReadOnly));
+ QSslKey key(file.readAll(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey);
+ QVERIFY(!key.isNull());
+
+ EVP_PKEY *pkey = q_EVP_PKEY_new();
+ q_EVP_PKEY_set1_RSA(pkey, reinterpret_cast<RSA *>(key.handle()));
+
+ // This test does not make 100% sense yet. We just set some local CA/cert/key and use it
+ // to authenticate ourselves against the server. The server does not actually check this
+ // values. This test should just run the codepath inside qsslsocket_openssl.cpp
+
+ QSslSocketPtr socket = newSocket();
+ QList<QSslCertificate> localCert = QSslCertificate::fromPath(SRCDIR "certs/qt-test-server-cacert.pem");
+ socket->setCaCertificates(localCert);
+ socket->setLocalCertificate(QLatin1String(SRCDIR "certs/fluke.cert"));
+ socket->setPrivateKey(QSslKey(reinterpret_cast<Qt::HANDLE>(pkey)));
+
+ socket->setPeerVerifyMode(QSslSocket::QueryPeer);
+ socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443);
+ QVERIFY(socket->waitForEncrypted(10000));
+}
+
void tst_QSslSocket::protocol()
{
if (!QSslSocket::supportsSsl())