Use TESTDATA for QSsl* tests
Apparently this (undocumented) TESTDATA feature creates resource files,
but lets you use wildcards as well, which is very handy.
The reason I didn't know/realize this when adapting the tests to use a
".qrc"-file* was because some of the test-cases were using relative
paths instead of the 'testDataDir' variable.
This commit fixes the remaining uses of relative paths, removes a
usage of QDir::setCurrent, and adapts QSslSocket to use TESTDATA.
* in now-reverted commit e1600c1a73
Change-Id: Iee6d88f1e0810eeaadac90e7d44bc6db84bfeabf
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
This commit is contained in:
parent
6b012a30d9
commit
b14934547a
@ -57,11 +57,8 @@ class tst_QSslCertificate : public QObject
|
||||
void compareCertificates(const QSslCertificate & cert1, const QSslCertificate & cert2);
|
||||
#endif
|
||||
|
||||
QString oldCurrentDir;
|
||||
|
||||
public slots:
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
private slots:
|
||||
@ -123,12 +120,6 @@ void tst_QSslCertificate::initTestCase()
|
||||
if (!testDataDir.endsWith(QLatin1String("/")))
|
||||
testDataDir += QLatin1String("/");
|
||||
|
||||
if (QDir::current().absolutePath() != testDataDir) {
|
||||
oldCurrentDir = QDir::current().absolutePath();
|
||||
QVERIFY2(QDir::setCurrent(testDataDir),
|
||||
qPrintable(QString("Cannot change directory to %1").arg(testDataDir)));
|
||||
}
|
||||
|
||||
QDir dir(testDataDir + "certificates");
|
||||
QFileInfoList fileInfoList = dir.entryInfoList(QDir::Files | QDir::Readable);
|
||||
QRegExp rxCert(QLatin1String("^.+\\.(pem|der)$"));
|
||||
@ -153,13 +144,6 @@ void tst_QSslCertificate::initTestCase()
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QSslCertificate::cleanupTestCase()
|
||||
{
|
||||
if (!oldCurrentDir.isEmpty()) {
|
||||
QDir::setCurrent(oldCurrentDir);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
|
||||
void tst_QSslCertificate::hash()
|
||||
@ -447,7 +431,7 @@ void tst_QSslCertificate::subjectAlternativeNames()
|
||||
|
||||
void tst_QSslCertificate::utf8SubjectNames()
|
||||
{
|
||||
QSslCertificate cert = QSslCertificate::fromPath("certificates/cert-ss-san-utf8.pem", QSsl::Pem,
|
||||
QSslCertificate cert = QSslCertificate::fromPath(testDataDir + "certificates/cert-ss-san-utf8.pem", QSsl::Pem,
|
||||
QRegExp::FixedString).first();
|
||||
QVERIFY(!cert.isNull());
|
||||
|
||||
@ -570,60 +554,60 @@ void tst_QSslCertificate::fromPath_data()
|
||||
QTest::newRow("empty regexp der") << QString() << int(QRegExp::RegExp) << false << 0;
|
||||
QTest::newRow("empty wildcard pem") << QString() << int(QRegExp::Wildcard) << true << 0;
|
||||
QTest::newRow("empty wildcard der") << QString() << int(QRegExp::Wildcard) << false << 0;
|
||||
QTest::newRow("\"certificates\" fixed pem") << QString("certificates") << int(QRegExp::FixedString) << true << 0;
|
||||
QTest::newRow("\"certificates\" fixed der") << QString("certificates") << int(QRegExp::FixedString) << false << 0;
|
||||
QTest::newRow("\"certificates\" regexp pem") << QString("certificates") << int(QRegExp::RegExp) << true << 0;
|
||||
QTest::newRow("\"certificates\" regexp der") << QString("certificates") << int(QRegExp::RegExp) << false << 0;
|
||||
QTest::newRow("\"certificates\" wildcard pem") << QString("certificates") << int(QRegExp::Wildcard) << true << 0;
|
||||
QTest::newRow("\"certificates\" wildcard der") << QString("certificates") << int(QRegExp::Wildcard) << false << 0;
|
||||
QTest::newRow("\"certificates/cert.pem\" fixed pem") << QString("certificates/cert.pem") << int(QRegExp::FixedString) << true << 1;
|
||||
QTest::newRow("\"certificates/cert.pem\" fixed der") << QString("certificates/cert.pem") << int(QRegExp::FixedString) << false << 0;
|
||||
QTest::newRow("\"certificates/cert.pem\" regexp pem") << QString("certificates/cert.pem") << int(QRegExp::RegExp) << true << 1;
|
||||
QTest::newRow("\"certificates/cert.pem\" regexp der") << QString("certificates/cert.pem") << int(QRegExp::RegExp) << false << 0;
|
||||
QTest::newRow("\"certificates/cert.pem\" wildcard pem") << QString("certificates/cert.pem") << int(QRegExp::Wildcard) << true << 1;
|
||||
QTest::newRow("\"certificates/cert.pem\" wildcard der") << QString("certificates/cert.pem") << int(QRegExp::Wildcard) << false << 0;
|
||||
QTest::newRow("\"certificates/*\" fixed pem") << QString("certificates/*") << int(QRegExp::FixedString) << true << 0;
|
||||
QTest::newRow("\"certificates/*\" fixed der") << QString("certificates/*") << int(QRegExp::FixedString) << false << 0;
|
||||
QTest::newRow("\"certificates/*\" regexp pem") << QString("certificates/*") << int(QRegExp::RegExp) << true << 0;
|
||||
QTest::newRow("\"certificates/*\" regexp der") << QString("certificates/*") << int(QRegExp::RegExp) << false << 0;
|
||||
QTest::newRow("\"certificates/*\" wildcard pem") << QString("certificates/*") << int(QRegExp::Wildcard) << true << 7;
|
||||
QTest::newRow("\"certificates/ca*\" wildcard pem") << QString("certificates/ca*") << int(QRegExp::Wildcard) << true << 1;
|
||||
QTest::newRow("\"certificates/cert*\" wildcard pem") << QString("certificates/cert*") << int(QRegExp::Wildcard) << true << 4;
|
||||
QTest::newRow("\"certificates/cert-[sure]*\" wildcard pem") << QString("certificates/cert-[sure]*") << int(QRegExp::Wildcard) << true << 3;
|
||||
QTest::newRow("\"certificates/cert-[not]*\" wildcard pem") << QString("certificates/cert-[not]*") << int(QRegExp::Wildcard) << true << 0;
|
||||
QTest::newRow("\"certificates/*\" wildcard der") << QString("certificates/*") << int(QRegExp::Wildcard) << false << 2;
|
||||
QTest::newRow("\"c*/c*.pem\" fixed pem") << QString("c*/c*.pem") << int(QRegExp::FixedString) << true << 0;
|
||||
QTest::newRow("\"c*/c*.pem\" fixed der") << QString("c*/c*.pem") << int(QRegExp::FixedString) << false << 0;
|
||||
QTest::newRow("\"c*/c*.pem\" regexp pem") << QString("c*/c*.pem") << int(QRegExp::RegExp) << true << 0;
|
||||
QTest::newRow("\"c*/c*.pem\" regexp der") << QString("c*/c*.pem") << int(QRegExp::RegExp) << false << 0;
|
||||
QTest::newRow("\"c*/c*.pem\" wildcard pem") << QString("c*/c*.pem") << int(QRegExp::Wildcard) << true << 5;
|
||||
QTest::newRow("\"c*/c*.pem\" wildcard der") << QString("c*/c*.pem") << int(QRegExp::Wildcard) << false << 0;
|
||||
QTest::newRow("\"d*/c*.pem\" fixed pem") << QString("d*/c*.pem") << int(QRegExp::FixedString) << true << 0;
|
||||
QTest::newRow("\"d*/c*.pem\" fixed der") << QString("d*/c*.pem") << int(QRegExp::FixedString) << false << 0;
|
||||
QTest::newRow("\"d*/c*.pem\" regexp pem") << QString("d*/c*.pem") << int(QRegExp::RegExp) << true << 0;
|
||||
QTest::newRow("\"d*/c*.pem\" regexp der") << QString("d*/c*.pem") << int(QRegExp::RegExp) << false << 0;
|
||||
QTest::newRow("\"d*/c*.pem\" wildcard pem") << QString("d*/c*.pem") << int(QRegExp::Wildcard) << true << 0;
|
||||
QTest::newRow("\"d*/c*.pem\" wildcard der") << QString("d*/c*.pem") << int(QRegExp::Wildcard) << false << 0;
|
||||
QTest::newRow("\"c.*/c.*.pem\" fixed pem") << QString("c.*/c.*.pem") << int(QRegExp::FixedString) << true << 0;
|
||||
QTest::newRow("\"c.*/c.*.pem\" fixed der") << QString("c.*/c.*.pem") << int(QRegExp::FixedString) << false << 0;
|
||||
QTest::newRow("\"c.*/c.*.pem\" regexp pem") << QString("c.*/c.*.pem") << int(QRegExp::RegExp) << true << 5;
|
||||
QTest::newRow("\"c.*/c.*.pem\" regexp der") << QString("c.*/c.*.pem") << int(QRegExp::RegExp) << false << 0;
|
||||
QTest::newRow("\"c.*/c.*.pem\" wildcard pem") << QString("c.*/c.*.pem") << int(QRegExp::Wildcard) << true << 0;
|
||||
QTest::newRow("\"c.*/c.*.pem\" wildcard der") << QString("c.*/c.*.pem") << int(QRegExp::Wildcard) << false << 0;
|
||||
QTest::newRow("\"d.*/c.*.pem\" fixed pem") << QString("d.*/c.*.pem") << int(QRegExp::FixedString) << true << 0;
|
||||
QTest::newRow("\"d.*/c.*.pem\" fixed der") << QString("d.*/c.*.pem") << int(QRegExp::FixedString) << false << 0;
|
||||
QTest::newRow("\"d.*/c.*.pem\" regexp pem") << QString("d.*/c.*.pem") << int(QRegExp::RegExp) << true << 0;
|
||||
QTest::newRow("\"d.*/c.*.pem\" regexp der") << QString("d.*/c.*.pem") << int(QRegExp::RegExp) << false << 0;
|
||||
QTest::newRow("\"d.*/c.*.pem\" wildcard pem") << QString("d.*/c.*.pem") << int(QRegExp::Wildcard) << true << 0;
|
||||
QTest::newRow("\"d.*/c.*.pem\" wildcard der") << QString("d.*/c.*.pem") << int(QRegExp::Wildcard) << false << 0;
|
||||
QTest::newRow("\"certificates\" fixed pem") << (testDataDir + "certificates") << int(QRegExp::FixedString) << true << 0;
|
||||
QTest::newRow("\"certificates\" fixed der") << (testDataDir + "certificates") << int(QRegExp::FixedString) << false << 0;
|
||||
QTest::newRow("\"certificates\" regexp pem") << (testDataDir + "certificates") << int(QRegExp::RegExp) << true << 0;
|
||||
QTest::newRow("\"certificates\" regexp der") << (testDataDir + "certificates") << int(QRegExp::RegExp) << false << 0;
|
||||
QTest::newRow("\"certificates\" wildcard pem") << (testDataDir + "certificates") << int(QRegExp::Wildcard) << true << 0;
|
||||
QTest::newRow("\"certificates\" wildcard der") << (testDataDir + "certificates") << int(QRegExp::Wildcard) << false << 0;
|
||||
QTest::newRow("\"certificates/cert.pem\" fixed pem") << (testDataDir + "certificates/cert.pem") << int(QRegExp::FixedString) << true << 1;
|
||||
QTest::newRow("\"certificates/cert.pem\" fixed der") << (testDataDir + "certificates/cert.pem") << int(QRegExp::FixedString) << false << 0;
|
||||
QTest::newRow("\"certificates/cert.pem\" regexp pem") << (testDataDir + "certificates/cert.pem") << int(QRegExp::RegExp) << true << 1;
|
||||
QTest::newRow("\"certificates/cert.pem\" regexp der") << (testDataDir + "certificates/cert.pem") << int(QRegExp::RegExp) << false << 0;
|
||||
QTest::newRow("\"certificates/cert.pem\" wildcard pem") << (testDataDir + "certificates/cert.pem") << int(QRegExp::Wildcard) << true << 1;
|
||||
QTest::newRow("\"certificates/cert.pem\" wildcard der") << (testDataDir + "certificates/cert.pem") << int(QRegExp::Wildcard) << false << 0;
|
||||
QTest::newRow("\"certificates/*\" fixed pem") << (testDataDir + "certificates/*") << int(QRegExp::FixedString) << true << 0;
|
||||
QTest::newRow("\"certificates/*\" fixed der") << (testDataDir + "certificates/*") << int(QRegExp::FixedString) << false << 0;
|
||||
QTest::newRow("\"certificates/*\" regexp pem") << (testDataDir + "certificates/*") << int(QRegExp::RegExp) << true << 0;
|
||||
QTest::newRow("\"certificates/*\" regexp der") << (testDataDir + "certificates/*") << int(QRegExp::RegExp) << false << 0;
|
||||
QTest::newRow("\"certificates/*\" wildcard pem") << (testDataDir + "certificates/*") << int(QRegExp::Wildcard) << true << 7;
|
||||
QTest::newRow("\"certificates/ca*\" wildcard pem") << (testDataDir + "certificates/ca*") << int(QRegExp::Wildcard) << true << 1;
|
||||
QTest::newRow("\"certificates/cert*\" wildcard pem") << (testDataDir + "certificates/cert*") << int(QRegExp::Wildcard) << true << 4;
|
||||
QTest::newRow("\"certificates/cert-[sure]*\" wildcard pem") << (testDataDir + "certificates/cert-[sure]*") << int(QRegExp::Wildcard) << true << 3;
|
||||
QTest::newRow("\"certificates/cert-[not]*\" wildcard pem") << (testDataDir + "certificates/cert-[not]*") << int(QRegExp::Wildcard) << true << 0;
|
||||
QTest::newRow("\"certificates/*\" wildcard der") << (testDataDir + "certificates/*") << int(QRegExp::Wildcard) << false << 2;
|
||||
QTest::newRow("\"c*/c*.pem\" fixed pem") << (testDataDir + "c*/c*.pem") << int(QRegExp::FixedString) << true << 0;
|
||||
QTest::newRow("\"c*/c*.pem\" fixed der") << (testDataDir + "c*/c*.pem") << int(QRegExp::FixedString) << false << 0;
|
||||
QTest::newRow("\"c*/c*.pem\" regexp pem") << (testDataDir + "c*/c*.pem") << int(QRegExp::RegExp) << true << 0;
|
||||
QTest::newRow("\"c*/c*.pem\" regexp der") << (testDataDir + "c*/c*.pem") << int(QRegExp::RegExp) << false << 0;
|
||||
QTest::newRow("\"c*/c*.pem\" wildcard pem") << (testDataDir + "c*/c*.pem") << int(QRegExp::Wildcard) << true << 5;
|
||||
QTest::newRow("\"c*/c*.pem\" wildcard der") << (testDataDir + "c*/c*.pem") << int(QRegExp::Wildcard) << false << 0;
|
||||
QTest::newRow("\"d*/c*.pem\" fixed pem") << (testDataDir + "d*/c*.pem") << int(QRegExp::FixedString) << true << 0;
|
||||
QTest::newRow("\"d*/c*.pem\" fixed der") << (testDataDir + "d*/c*.pem") << int(QRegExp::FixedString) << false << 0;
|
||||
QTest::newRow("\"d*/c*.pem\" regexp pem") << (testDataDir + "d*/c*.pem") << int(QRegExp::RegExp) << true << 0;
|
||||
QTest::newRow("\"d*/c*.pem\" regexp der") << (testDataDir + "d*/c*.pem") << int(QRegExp::RegExp) << false << 0;
|
||||
QTest::newRow("\"d*/c*.pem\" wildcard pem") << (testDataDir + "d*/c*.pem") << int(QRegExp::Wildcard) << true << 0;
|
||||
QTest::newRow("\"d*/c*.pem\" wildcard der") << (testDataDir + "d*/c*.pem") << int(QRegExp::Wildcard) << false << 0;
|
||||
QTest::newRow("\"c.*/c.*.pem\" fixed pem") << (testDataDir + "c.*/c.*.pem") << int(QRegExp::FixedString) << true << 0;
|
||||
QTest::newRow("\"c.*/c.*.pem\" fixed der") << (testDataDir + "c.*/c.*.pem") << int(QRegExp::FixedString) << false << 0;
|
||||
QTest::newRow("\"c.*/c.*.pem\" regexp pem") << (testDataDir + "c.*/c.*.pem") << int(QRegExp::RegExp) << true << 5;
|
||||
QTest::newRow("\"c.*/c.*.pem\" regexp der") << (testDataDir + "c.*/c.*.pem") << int(QRegExp::RegExp) << false << 0;
|
||||
QTest::newRow("\"c.*/c.*.pem\" wildcard pem") << (testDataDir + "c.*/c.*.pem") << int(QRegExp::Wildcard) << true << 0;
|
||||
QTest::newRow("\"c.*/c.*.pem\" wildcard der") << (testDataDir + "c.*/c.*.pem") << int(QRegExp::Wildcard) << false << 0;
|
||||
QTest::newRow("\"d.*/c.*.pem\" fixed pem") << (testDataDir + "d.*/c.*.pem") << int(QRegExp::FixedString) << true << 0;
|
||||
QTest::newRow("\"d.*/c.*.pem\" fixed der") << (testDataDir + "d.*/c.*.pem") << int(QRegExp::FixedString) << false << 0;
|
||||
QTest::newRow("\"d.*/c.*.pem\" regexp pem") << (testDataDir + "d.*/c.*.pem") << int(QRegExp::RegExp) << true << 0;
|
||||
QTest::newRow("\"d.*/c.*.pem\" regexp der") << (testDataDir + "d.*/c.*.pem") << int(QRegExp::RegExp) << false << 0;
|
||||
QTest::newRow("\"d.*/c.*.pem\" wildcard pem") << (testDataDir + "d.*/c.*.pem") << int(QRegExp::Wildcard) << true << 0;
|
||||
QTest::newRow("\"d.*/c.*.pem\" wildcard der") << (testDataDir + "d.*/c.*.pem") << int(QRegExp::Wildcard) << false << 0;
|
||||
#ifdef Q_OS_LINUX
|
||||
QTest::newRow("absolute path wildcard pem") << (testDataDir + "certificates/*.pem") << int(QRegExp::Wildcard) << true << 7;
|
||||
#endif
|
||||
|
||||
QTest::newRow("trailing-whitespace") << QString("more-certificates/trailing-whitespace.pem") << int(QRegExp::FixedString) << true << 1;
|
||||
QTest::newRow("no-ending-newline") << QString("more-certificates/no-ending-newline.pem") << int(QRegExp::FixedString) << true << 1;
|
||||
QTest::newRow("malformed-just-begin") << QString("more-certificates/malformed-just-begin.pem") << int(QRegExp::FixedString) << true << 0;
|
||||
QTest::newRow("malformed-just-begin-no-newline") << QString("more-certificates/malformed-just-begin-no-newline.pem") << int(QRegExp::FixedString) << true << 0;
|
||||
QTest::newRow("trailing-whitespace") << (testDataDir + "more-certificates/trailing-whitespace.pem") << int(QRegExp::FixedString) << true << 1;
|
||||
QTest::newRow("no-ending-newline") << (testDataDir + "more-certificates/no-ending-newline.pem") << int(QRegExp::FixedString) << true << 1;
|
||||
QTest::newRow("malformed-just-begin") << (testDataDir + "more-certificates/malformed-just-begin.pem") << int(QRegExp::FixedString) << true << 0;
|
||||
QTest::newRow("malformed-just-begin-no-newline") << (testDataDir + "more-certificates/malformed-just-begin-no-newline.pem") << int(QRegExp::FixedString) << true << 0;
|
||||
}
|
||||
|
||||
void tst_QSslCertificate::fromPath()
|
||||
@ -724,7 +708,7 @@ void tst_QSslCertificate::certInfo()
|
||||
"dc:c2:eb:b7:bb:50:18:05:ba:ad:af:08:49:fe:98:63"
|
||||
"55:ba:e7:fb:95:5d:91";
|
||||
|
||||
QSslCertificate cert = QSslCertificate::fromPath("certificates/cert.pem", QSsl::Pem,
|
||||
QSslCertificate cert = QSslCertificate::fromPath(testDataDir + "certificates/cert.pem", QSsl::Pem,
|
||||
QRegExp::FixedString).first();
|
||||
QVERIFY(!cert.isNull());
|
||||
|
||||
@ -781,7 +765,7 @@ void tst_QSslCertificate::certInfo()
|
||||
|
||||
void tst_QSslCertificate::certInfoQByteArray()
|
||||
{
|
||||
QSslCertificate cert = QSslCertificate::fromPath("certificates/cert.pem", QSsl::Pem,
|
||||
QSslCertificate cert = QSslCertificate::fromPath(testDataDir + "certificates/cert.pem", QSsl::Pem,
|
||||
QRegExp::FixedString).first();
|
||||
QVERIFY(!cert.isNull());
|
||||
|
||||
@ -898,8 +882,8 @@ void tst_QSslCertificate::largeExpirationDate() // QTBUG-12489
|
||||
|
||||
void tst_QSslCertificate::blacklistedCertificates()
|
||||
{
|
||||
QList<QSslCertificate> blacklistedCerts = QSslCertificate::fromPath("more-certificates/blacklisted*.pem", QSsl::Pem, QRegExp::Wildcard);
|
||||
QVERIFY2(blacklistedCerts.count() > 0, "Please run this test from the source directory");
|
||||
QList<QSslCertificate> blacklistedCerts = QSslCertificate::fromPath(testDataDir + "more-certificates/blacklisted*.pem", QSsl::Pem, QRegExp::Wildcard);
|
||||
QVERIFY(blacklistedCerts.count() > 0);
|
||||
for (int a = 0; a < blacklistedCerts.count(); a++) {
|
||||
QVERIFY(blacklistedCerts.at(a).isBlacklisted());
|
||||
}
|
||||
@ -953,7 +937,7 @@ void tst_QSslCertificate::multipleCommonNames()
|
||||
{
|
||||
QList<QSslCertificate> certList =
|
||||
QSslCertificate::fromPath(testDataDir + "more-certificates/test-cn-two-cns-cert.pem");
|
||||
QVERIFY2(certList.count() > 0, "Please run this test from the source directory");
|
||||
QVERIFY(certList.count() > 0);
|
||||
|
||||
QStringList commonNames = certList[0].subjectInfo(QSslCertificate::CommonName);
|
||||
QVERIFY(commonNames.contains(QString("www.example.com")));
|
||||
@ -964,14 +948,14 @@ void tst_QSslCertificate::subjectAndIssuerAttributes()
|
||||
{
|
||||
QList<QSslCertificate> certList =
|
||||
QSslCertificate::fromPath(testDataDir + "more-certificates/test-cn-with-drink-cert.pem");
|
||||
QVERIFY2(certList.count() > 0, "Please run this test from the source directory");
|
||||
QVERIFY(certList.count() > 0);
|
||||
|
||||
QList<QByteArray> attributes = certList[0].subjectInfoAttributes();
|
||||
QVERIFY(attributes.contains(QByteArray("favouriteDrink")));
|
||||
attributes.clear();
|
||||
|
||||
certList = QSslCertificate::fromPath(testDataDir + "more-certificates/natwest-banking.pem");
|
||||
QVERIFY2(certList.count() > 0, "Please run this test from the source directory");
|
||||
QVERIFY(certList.count() > 0);
|
||||
|
||||
attributes = certList[0].subjectInfoAttributes();
|
||||
QVERIFY(attributes.contains(QByteArray("1.3.6.1.4.1.311.60.2.1.3")));
|
||||
@ -1071,7 +1055,7 @@ void tst_QSslCertificate::extensions()
|
||||
{
|
||||
QList<QSslCertificate> certList =
|
||||
QSslCertificate::fromPath(testDataDir + "more-certificates/natwest-banking.pem");
|
||||
QVERIFY2(certList.count() > 0, "Please run this test from the source directory");
|
||||
QVERIFY(certList.count() > 0);
|
||||
|
||||
QSslCertificate cert = certList[0];
|
||||
QList<QSslCertificateExtension> extensions = cert.extensions();
|
||||
@ -1169,7 +1153,7 @@ void tst_QSslCertificate::extensionsCritical()
|
||||
{
|
||||
QList<QSslCertificate> certList =
|
||||
QSslCertificate::fromPath(testDataDir + "verify-certs/test-addons-mozilla-org-cert.pem");
|
||||
QVERIFY2(certList.count() > 0, "Please run this test from the source directory");
|
||||
QVERIFY(certList.count() > 0);
|
||||
|
||||
QSslCertificate cert = certList[0];
|
||||
QList<QSslCertificateExtension> extensions = cert.extensions();
|
||||
|
@ -9,4 +9,5 @@ qtConfig(private_tests) {
|
||||
|
||||
TARGET = tst_qsslkey
|
||||
|
||||
TESTDATA += keys/* rsa-without-passphrase.pem rsa-with-passphrase.pem
|
||||
TESTDATA += keys/* \
|
||||
rsa-*.pem
|
||||
|
@ -394,9 +394,9 @@ void tst_QSslKey::passphraseChecks_data()
|
||||
{
|
||||
QTest::addColumn<QString>("fileName");
|
||||
|
||||
QTest::newRow("DES") << QString(testDataDir + "rsa-with-passphrase-des.pem");
|
||||
QTest::newRow("3DES") << QString(testDataDir + "rsa-with-passphrase-3des.pem");
|
||||
QTest::newRow("RC2") << QString(testDataDir + "rsa-with-passphrase-rc2.pem");
|
||||
QTest::newRow("DES") << (testDataDir + "rsa-with-passphrase-des.pem");
|
||||
QTest::newRow("3DES") << (testDataDir + "rsa-with-passphrase-3des.pem");
|
||||
QTest::newRow("RC2") << (testDataDir + "rsa-with-passphrase-rc2.pem");
|
||||
}
|
||||
|
||||
void tst_QSslKey::passphraseChecks()
|
||||
|
@ -14,6 +14,8 @@ win32 {
|
||||
}
|
||||
}
|
||||
|
||||
TESTDATA += certs
|
||||
|
||||
DEFINES += SRCDIR=\\\"$$PWD/\\\"
|
||||
|
||||
requires(qtConfig(private_tests))
|
||||
|
@ -278,7 +278,10 @@ private:
|
||||
#endif // QT_NO_SSL
|
||||
private:
|
||||
static int loopLevel;
|
||||
public:
|
||||
static QString testDataDir;
|
||||
};
|
||||
QString tst_QSslSocket::testDataDir;
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
#ifndef QT_NO_OPENSSL
|
||||
@ -332,6 +335,11 @@ void tst_QSslSocket::initTestCase_data()
|
||||
|
||||
void tst_QSslSocket::initTestCase()
|
||||
{
|
||||
testDataDir = QFileInfo(QFINDTESTDATA("certs")).absolutePath();
|
||||
if (testDataDir.isEmpty())
|
||||
testDataDir = QCoreApplication::applicationDirPath();
|
||||
if (!testDataDir.endsWith(QLatin1String("/")))
|
||||
testDataDir += QLatin1String("/");
|
||||
#ifndef QT_NO_SSL
|
||||
qDebug("Using SSL library %s (%ld)",
|
||||
qPrintable(QSslSocket::sslLibraryVersionString()),
|
||||
@ -705,7 +713,7 @@ void tst_QSslSocket::connectToHostEncrypted()
|
||||
|
||||
QSslSocketPtr socket = newSocket();
|
||||
this->socket = socket.data();
|
||||
QVERIFY(socket->addCaCertificates(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem")));
|
||||
QVERIFY(socket->addCaCertificates(testDataDir + "certs/qt-test-server-cacert.pem"));
|
||||
#ifdef QSSLSOCKET_CERTUNTRUSTED_WORKAROUND
|
||||
connect(socket.data(), SIGNAL(sslErrors(QList<QSslError>)),
|
||||
this, SLOT(untrustedWorkaroundSlot(QList<QSslError>)));
|
||||
@ -739,7 +747,7 @@ void tst_QSslSocket::connectToHostEncryptedWithVerificationPeerName()
|
||||
QSslSocketPtr socket = newSocket();
|
||||
this->socket = socket.data();
|
||||
|
||||
socket->addCaCertificates(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem"));
|
||||
socket->addCaCertificates(testDataDir + "certs/qt-test-server-cacert.pem");
|
||||
#ifdef QSSLSOCKET_CERTUNTRUSTED_WORKAROUND
|
||||
connect(socket.data(), SIGNAL(sslErrors(QList<QSslError>)),
|
||||
this, SLOT(untrustedWorkaroundSlot(QList<QSslError>)));
|
||||
@ -803,10 +811,10 @@ void tst_QSslSocket::localCertificate()
|
||||
// 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");
|
||||
QList<QSslCertificate> localCert = QSslCertificate::fromPath(testDataDir + "certs/qt-test-server-cacert.pem");
|
||||
socket->setCaCertificates(localCert);
|
||||
socket->setLocalCertificate(QLatin1String(SRCDIR "certs/fluke.cert"));
|
||||
socket->setPrivateKey(QLatin1String(SRCDIR "certs/fluke.key"));
|
||||
socket->setLocalCertificate(testDataDir + "certs/fluke.cert");
|
||||
socket->setPrivateKey(testDataDir + "certs/fluke.key");
|
||||
|
||||
socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443);
|
||||
QFETCH_GLOBAL(bool, setProxy);
|
||||
@ -832,7 +840,7 @@ void tst_QSslSocket::peerCertificateChain()
|
||||
QSslSocketPtr socket = newSocket();
|
||||
this->socket = socket.data();
|
||||
|
||||
QList<QSslCertificate> caCertificates = QSslCertificate::fromPath(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem"));
|
||||
QList<QSslCertificate> caCertificates = QSslCertificate::fromPath(testDataDir + "certs/qt-test-server-cacert.pem");
|
||||
QCOMPARE(caCertificates.count(), 1);
|
||||
socket->addCaCertificates(caCertificates);
|
||||
#ifdef QSSLSOCKET_CERTUNTRUSTED_WORKAROUND
|
||||
@ -895,7 +903,7 @@ void tst_QSslSocket::privateKeyOpaque()
|
||||
if (!QSslSocket::supportsSsl())
|
||||
return;
|
||||
|
||||
QFile file(SRCDIR "certs/fluke.key");
|
||||
QFile file(testDataDir + "certs/fluke.key");
|
||||
QVERIFY(file.open(QIODevice::ReadOnly));
|
||||
QSslKey key(file.readAll(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey);
|
||||
QVERIFY(!key.isNull());
|
||||
@ -908,9 +916,9 @@ void tst_QSslSocket::privateKeyOpaque()
|
||||
// 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");
|
||||
QList<QSslCertificate> localCert = QSslCertificate::fromPath(testDataDir + "certs/qt-test-server-cacert.pem");
|
||||
socket->setCaCertificates(localCert);
|
||||
socket->setLocalCertificate(QLatin1String(SRCDIR "certs/fluke.cert"));
|
||||
socket->setLocalCertificate(testDataDir + "certs/fluke.cert");
|
||||
socket->setPrivateKey(QSslKey(reinterpret_cast<Qt::HANDLE>(pkey)));
|
||||
|
||||
socket->setPeerVerifyMode(QSslSocket::QueryPeer);
|
||||
@ -928,7 +936,7 @@ void tst_QSslSocket::protocol()
|
||||
|
||||
QSslSocketPtr socket = newSocket();
|
||||
this->socket = socket.data();
|
||||
QList<QSslCertificate> certs = QSslCertificate::fromPath(SRCDIR "certs/qt-test-server-cacert.pem");
|
||||
QList<QSslCertificate> certs = QSslCertificate::fromPath(testDataDir + "certs/qt-test-server-cacert.pem");
|
||||
|
||||
socket->setCaCertificates(certs);
|
||||
#ifdef QSSLSOCKET_CERTUNTRUSTED_WORKAROUND
|
||||
@ -1075,8 +1083,8 @@ class SslServer : public QTcpServer
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SslServer(const QString &keyFile = SRCDIR "certs/fluke.key",
|
||||
const QString &certFile = SRCDIR "certs/fluke.cert",
|
||||
SslServer(const QString &keyFile = tst_QSslSocket::testDataDir + "certs/fluke.key",
|
||||
const QString &certFile = tst_QSslSocket::testDataDir + "certs/fluke.cert",
|
||||
const QString &interFile = QString())
|
||||
: socket(0),
|
||||
config(QSslConfiguration::defaultConfiguration()),
|
||||
@ -1428,7 +1436,7 @@ void tst_QSslSocket::setCaCertificates()
|
||||
|
||||
QSslSocket socket;
|
||||
QCOMPARE(socket.caCertificates(), QSslSocket::defaultCaCertificates());
|
||||
socket.setCaCertificates(QSslCertificate::fromPath(SRCDIR "certs/qt-test-server-cacert.pem"));
|
||||
socket.setCaCertificates(QSslCertificate::fromPath(testDataDir + "certs/qt-test-server-cacert.pem"));
|
||||
QCOMPARE(socket.caCertificates().size(), 1);
|
||||
socket.setCaCertificates(socket.defaultCaCertificates());
|
||||
QCOMPARE(socket.caCertificates(), QSslSocket::defaultCaCertificates());
|
||||
@ -1444,7 +1452,7 @@ void tst_QSslSocket::localCertificateChain()
|
||||
return;
|
||||
|
||||
QSslSocket socket;
|
||||
socket.setLocalCertificate(QLatin1String(SRCDIR "certs/fluke.cert"));
|
||||
socket.setLocalCertificate(testDataDir + "certs/fluke.cert");
|
||||
|
||||
QSslConfiguration conf = socket.sslConfiguration();
|
||||
QList<QSslCertificate> chain = conf.localCertificateChain();
|
||||
@ -1465,9 +1473,9 @@ void tst_QSslSocket::setLocalCertificateChain()
|
||||
if (setProxy)
|
||||
return;
|
||||
|
||||
SslServer server(QLatin1String(SRCDIR "certs/leaf.key"),
|
||||
QLatin1String(SRCDIR "certs/leaf.crt"),
|
||||
QLatin1String(SRCDIR "certs/inter.crt"));
|
||||
SslServer server(testDataDir + "certs/leaf.key",
|
||||
testDataDir + "certs/leaf.crt",
|
||||
testDataDir + "certs/inter.crt");
|
||||
|
||||
QVERIFY(server.listen());
|
||||
|
||||
@ -1536,7 +1544,7 @@ void tst_QSslSocket::setSslConfiguration_data()
|
||||
QTest::newRow("empty") << QSslConfiguration() << false;
|
||||
QSslConfiguration conf = QSslConfiguration::defaultConfiguration();
|
||||
QTest::newRow("default") << conf << false; // does not contain test server cert
|
||||
QList<QSslCertificate> testServerCert = QSslCertificate::fromPath(SRCDIR "certs/qt-test-server-cacert.pem");
|
||||
QList<QSslCertificate> testServerCert = QSslCertificate::fromPath(testDataDir + "certs/qt-test-server-cacert.pem");
|
||||
conf.setCaCertificates(testServerCert);
|
||||
QTest::newRow("set-root-cert") << conf << true;
|
||||
conf.setProtocol(QSsl::SecureProtocols);
|
||||
@ -1639,7 +1647,7 @@ void tst_QSslSocket::addDefaultCaCertificate()
|
||||
// Reset the global CA chain
|
||||
QSslSocket::setDefaultCaCertificates(QSslSocket::systemCaCertificates());
|
||||
|
||||
QList<QSslCertificate> flukeCerts = QSslCertificate::fromPath(SRCDIR "certs/qt-test-server-cacert.pem");
|
||||
QList<QSslCertificate> flukeCerts = QSslCertificate::fromPath(testDataDir + "certs/qt-test-server-cacert.pem");
|
||||
QCOMPARE(flukeCerts.size(), 1);
|
||||
QList<QSslCertificate> globalCerts = QSslSocket::defaultCaCertificates();
|
||||
QVERIFY(!globalCerts.contains(flukeCerts.first()));
|
||||
@ -1751,7 +1759,7 @@ void tst_QSslSocket::isMatchingHostname()
|
||||
{
|
||||
// with normalization: (the certificate has *.SCHÄUFELE.DE as a CN)
|
||||
// openssl req -x509 -nodes -subj "/CN=*.SCHÄUFELE.DE" -newkey rsa:512 -keyout /dev/null -out xn--schufele-2za.crt
|
||||
QList<QSslCertificate> certs = QSslCertificate::fromPath(SRCDIR "certs/xn--schufele-2za.crt");
|
||||
QList<QSslCertificate> certs = QSslCertificate::fromPath(testDataDir + "certs/xn--schufele-2za.crt");
|
||||
QVERIFY(!certs.isEmpty());
|
||||
QSslCertificate cert = certs.first();
|
||||
|
||||
@ -1807,7 +1815,7 @@ protected:
|
||||
socket->ignoreSslErrors();
|
||||
|
||||
// Only set the certificate
|
||||
QList<QSslCertificate> localCert = QSslCertificate::fromPath(SRCDIR "certs/fluke.cert");
|
||||
QList<QSslCertificate> localCert = QSslCertificate::fromPath(tst_QSslSocket::testDataDir + "certs/fluke.cert");
|
||||
QVERIFY(!localCert.isEmpty());
|
||||
QVERIFY(!localCert.first().isNull());
|
||||
socket->setLocalCertificate(localCert.first());
|
||||
@ -2045,13 +2053,14 @@ protected:
|
||||
socket = new QSslSocket(this);
|
||||
connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot()));
|
||||
|
||||
QFile file(SRCDIR "certs/fluke.key");
|
||||
QFile file(tst_QSslSocket::testDataDir + "certs/fluke.key");
|
||||
QVERIFY(file.open(QIODevice::ReadOnly));
|
||||
QSslKey key(file.readAll(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey);
|
||||
QVERIFY(!key.isNull());
|
||||
socket->setPrivateKey(key);
|
||||
|
||||
QList<QSslCertificate> localCert = QSslCertificate::fromPath(SRCDIR "certs/fluke.cert");
|
||||
QList<QSslCertificate> localCert = QSslCertificate::fromPath(tst_QSslSocket::testDataDir
|
||||
+ "certs/fluke.cert");
|
||||
QVERIFY(!localCert.isEmpty());
|
||||
QVERIFY(!localCert.first().isNull());
|
||||
socket->setLocalCertificate(localCert.first());
|
||||
@ -2227,8 +2236,8 @@ protected:
|
||||
{
|
||||
socket = new QSslSocket(this);
|
||||
|
||||
socket->setPrivateKey(SRCDIR "certs/fluke.key");
|
||||
socket->setLocalCertificate(SRCDIR "certs/fluke.cert");
|
||||
socket->setPrivateKey(tst_QSslSocket::testDataDir + "certs/fluke.key");
|
||||
socket->setLocalCertificate(tst_QSslSocket::testDataDir + "certs/fluke.cert");
|
||||
socket->setSocketDescriptor(socketDescriptor);
|
||||
socket->startServerEncryption();
|
||||
}
|
||||
@ -2346,7 +2355,7 @@ void tst_QSslSocket::resetProxy()
|
||||
// make sure the connection works, and then set a nonsense proxy, and then
|
||||
// make sure it does not work anymore
|
||||
QSslSocket socket;
|
||||
socket.addCaCertificates(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem"));
|
||||
socket.addCaCertificates(testDataDir + "certs/qt-test-server-cacert.pem");
|
||||
socket.setProxy(goodProxy);
|
||||
socket.connectToHostEncrypted(QtNetworkSettings::serverName(), 443);
|
||||
QVERIFY2(socket.waitForConnected(10000), qPrintable(socket.errorString()));
|
||||
@ -2365,7 +2374,7 @@ void tst_QSslSocket::resetProxy()
|
||||
// set the nonsense proxy and make sure the connection does not work,
|
||||
// and then set the right proxy and make sure it works
|
||||
QSslSocket socket2;
|
||||
socket2.addCaCertificates(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem"));
|
||||
socket2.addCaCertificates(testDataDir + "certs/qt-test-server-cacert.pem");
|
||||
socket2.setProxy(badProxy);
|
||||
socket2.connectToHostEncrypted(QtNetworkSettings::serverName(), 443);
|
||||
QVERIFY(! socket2.waitForConnected(10000));
|
||||
@ -2384,7 +2393,7 @@ void tst_QSslSocket::ignoreSslErrorsList_data()
|
||||
// construct the list of errors that we will get with the SSL handshake and that we will ignore
|
||||
QList<QSslError> expectedSslErrors;
|
||||
// fromPath gives us a list of certs, but it actually only contains one
|
||||
QList<QSslCertificate> certs = QSslCertificate::fromPath(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem"));
|
||||
QList<QSslCertificate> certs = QSslCertificate::fromPath(testDataDir + "certs/qt-test-server-cacert.pem");
|
||||
QSslError rightError(FLUKE_CERTIFICATE_ERROR, certs.at(0));
|
||||
QSslError wrongError(FLUKE_CERTIFICATE_ERROR);
|
||||
|
||||
@ -2563,7 +2572,7 @@ void tst_QSslSocket::blacklistedCertificates()
|
||||
if (setProxy)
|
||||
return;
|
||||
|
||||
SslServer server(SRCDIR "certs/fake-login.live.com.key", SRCDIR "certs/fake-login.live.com.pem");
|
||||
SslServer server(testDataDir + "certs/fake-login.live.com.key", testDataDir + "certs/fake-login.live.com.pem");
|
||||
QSslSocket *receiver = new QSslSocket(this);
|
||||
connect(receiver, SIGNAL(readyRead()), SLOT(exitLoop()));
|
||||
|
||||
@ -2675,7 +2684,7 @@ void tst_QSslSocket::resume_data()
|
||||
QTest::newRow("DoNotIgnoreErrors") << false << QList<QSslError>() << false;
|
||||
QTest::newRow("ignoreAllErrors") << true << QList<QSslError>() << true;
|
||||
|
||||
QList<QSslCertificate> certs = QSslCertificate::fromPath(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem"));
|
||||
QList<QSslCertificate> certs = QSslCertificate::fromPath(testDataDir + "certs/qt-test-server-cacert.pem");
|
||||
QSslError rightError(FLUKE_CERTIFICATE_ERROR, certs.at(0));
|
||||
QSslError wrongError(FLUKE_CERTIFICATE_ERROR);
|
||||
errorsList.append(wrongError);
|
||||
@ -2745,8 +2754,8 @@ class WebSocket : public QSslSocket
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit WebSocket(qintptr socketDescriptor,
|
||||
const QString &keyFile = SRCDIR "certs/fluke.key",
|
||||
const QString &certFile = SRCDIR "certs/fluke.cert");
|
||||
const QString &keyFile = tst_QSslSocket::testDataDir + "certs/fluke.key",
|
||||
const QString &certFile = tst_QSslSocket::testDataDir + "certs/fluke.cert");
|
||||
|
||||
protected slots:
|
||||
void onReadyReadFirstBytes(void);
|
||||
@ -2957,13 +2966,13 @@ void tst_QSslSocket::qtbug18498_peek2()
|
||||
QCOMPARE(a[2], 'S');
|
||||
QCOMPARE(server->readAll(), QByteArray("TLS\r\n"));
|
||||
|
||||
QFile file(SRCDIR "certs/fluke.key");
|
||||
QFile file(testDataDir + "certs/fluke.key");
|
||||
QVERIFY(file.open(QIODevice::ReadOnly));
|
||||
QSslKey key(file.readAll(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey);
|
||||
QVERIFY(!key.isNull());
|
||||
server->setPrivateKey(key);
|
||||
|
||||
QList<QSslCertificate> localCert = QSslCertificate::fromPath(SRCDIR "certs/fluke.cert");
|
||||
QList<QSslCertificate> localCert = QSslCertificate::fromPath(testDataDir + "certs/fluke.cert");
|
||||
QVERIFY(!localCert.isEmpty());
|
||||
QVERIFY(!localCert.first().isNull());
|
||||
server->setLocalCertificate(localCert.first());
|
||||
@ -3163,10 +3172,10 @@ void tst_QSslSocket::verifyClientCertificate_data()
|
||||
QTest::newRow("NoCert:VerifyPeer") << QSslSocket::VerifyPeer << noCerts << noKey << false;
|
||||
|
||||
// self-signed certificate
|
||||
QList<QSslCertificate> flukeCerts = QSslCertificate::fromPath(SRCDIR "certs/fluke.cert");
|
||||
QList<QSslCertificate> flukeCerts = QSslCertificate::fromPath(testDataDir + "certs/fluke.cert");
|
||||
QCOMPARE(flukeCerts.size(), 1);
|
||||
|
||||
QFile flukeFile(SRCDIR "certs/fluke.key");
|
||||
QFile flukeFile(testDataDir + "certs/fluke.key");
|
||||
QVERIFY(flukeFile.open(QIODevice::ReadOnly));
|
||||
QSslKey flukeKey(flukeFile.readAll(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey);
|
||||
QVERIFY(!flukeKey.isNull());
|
||||
@ -3177,10 +3186,10 @@ void tst_QSslSocket::verifyClientCertificate_data()
|
||||
QTest::newRow("SelfSignedCert:VerifyPeer") << QSslSocket::VerifyPeer << flukeCerts << flukeKey << false;
|
||||
|
||||
// valid certificate, but wrong usage (server certificate)
|
||||
QList<QSslCertificate> serverCerts = QSslCertificate::fromPath(SRCDIR "certs/bogus-server.crt");
|
||||
QList<QSslCertificate> serverCerts = QSslCertificate::fromPath(testDataDir + "certs/bogus-server.crt");
|
||||
QCOMPARE(serverCerts.size(), 1);
|
||||
|
||||
QFile serverFile(SRCDIR "certs/bogus-server.key");
|
||||
QFile serverFile(testDataDir + "certs/bogus-server.key");
|
||||
QVERIFY(serverFile.open(QIODevice::ReadOnly));
|
||||
QSslKey serverKey(serverFile.readAll(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey);
|
||||
QVERIFY(!serverKey.isNull());
|
||||
@ -3191,10 +3200,10 @@ void tst_QSslSocket::verifyClientCertificate_data()
|
||||
QTest::newRow("ValidServerCert:VerifyPeer") << QSslSocket::VerifyPeer << serverCerts << serverKey << false;
|
||||
|
||||
// valid certificate, correct usage (client certificate)
|
||||
QList<QSslCertificate> validCerts = QSslCertificate::fromPath(SRCDIR "certs/bogus-client.crt");
|
||||
QList<QSslCertificate> validCerts = QSslCertificate::fromPath(testDataDir + "certs/bogus-client.crt");
|
||||
QCOMPARE(validCerts.size(), 1);
|
||||
|
||||
QFile validFile(SRCDIR "certs/bogus-client.key");
|
||||
QFile validFile(testDataDir + "certs/bogus-client.key");
|
||||
QVERIFY(validFile.open(QIODevice::ReadOnly));
|
||||
QSslKey validKey(validFile.readAll(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey);
|
||||
QVERIFY(!validKey.isNull());
|
||||
@ -3205,7 +3214,7 @@ void tst_QSslSocket::verifyClientCertificate_data()
|
||||
QTest::newRow("ValidClientCert:VerifyPeer") << QSslSocket::VerifyPeer << validCerts << validKey << true;
|
||||
|
||||
// valid certificate, correct usage (client certificate), with chain
|
||||
validCerts += QSslCertificate::fromPath(SRCDIR "certs/bogus-ca.crt");
|
||||
validCerts += QSslCertificate::fromPath(testDataDir + "certs/bogus-ca.crt");
|
||||
QCOMPARE(validCerts.size(), 2);
|
||||
|
||||
QTest::newRow("ValidClientCert:AutoVerifyPeer") << QSslSocket::AutoVerifyPeer << validCerts << validKey << true;
|
||||
@ -3238,7 +3247,7 @@ void tst_QSslSocket::verifyClientCertificate()
|
||||
|
||||
QFETCH(QSslSocket::PeerVerifyMode, peerVerifyMode);
|
||||
SslServer server;
|
||||
server.addCaCertificates = QLatin1String(SRCDIR "certs/bogus-ca.crt");
|
||||
server.addCaCertificates = testDataDir + "certs/bogus-ca.crt";
|
||||
server.ignoreSslErrors = false;
|
||||
server.peerVerifyMode = peerVerifyMode;
|
||||
QVERIFY(server.listen());
|
||||
|
Loading…
Reference in New Issue
Block a user