Revert "Adapt the QSsl* tests to use the resource system"
This reverts commit e1600c1a73
.
The commit missed the fact that TESTDATA exists. Which supports
wildcards and then can automatically pick up new files when added (as
long as they match a wildcard) and then you don't need to maintain a
giant qrc file.
Change-Id: Ie31fadb5ef6e8dfe6105f4f9764292f78cffb512
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
parent
a79d9da8e0
commit
a5c58d503d
@ -6,7 +6,4 @@ QT = core network testlib
|
||||
|
||||
TARGET = tst_qsslcertificate
|
||||
|
||||
RESOURCES += \
|
||||
qsslcertificate.qrc
|
||||
|
||||
TESTDATA += certificates/* more-certificates/* verify-certs/* pkcs12/*
|
||||
|
@ -1,79 +0,0 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>certificates/ca-cert.pem</file>
|
||||
<file>certificates/ca-cert.pem.digest-md5</file>
|
||||
<file>certificates/ca-cert.pem.digest-sha1</file>
|
||||
<file>certificates/cert-ss-san-utf8.pem</file>
|
||||
<file>certificates/cert-ss-san-utf8.pem.san</file>
|
||||
<file>certificates/cert-ss-san.pem</file>
|
||||
<file>certificates/cert-ss-san.pem.san</file>
|
||||
<file>certificates/cert-ss.der</file>
|
||||
<file>certificates/cert-ss.der.pubkey</file>
|
||||
<file>certificates/cert-ss.pem</file>
|
||||
<file>certificates/cert-ss.pem.digest-md5</file>
|
||||
<file>certificates/cert-ss.pem.digest-sha1</file>
|
||||
<file>certificates/cert-ss.pem.pubkey</file>
|
||||
<file>certificates/cert.der</file>
|
||||
<file>certificates/cert.der.pubkey</file>
|
||||
<file>certificates/cert.pem</file>
|
||||
<file>certificates/cert.pem.digest-md5</file>
|
||||
<file>certificates/cert.pem.digest-sha1</file>
|
||||
<file>certificates/cert.pem.pubkey</file>
|
||||
<file>certificates/dsa-cert-ss.der.pubkey</file>
|
||||
<file>certificates/dsa-cert-ss.pem</file>
|
||||
<file>certificates/dsa-cert-ss.pem.digest-md5</file>
|
||||
<file>certificates/dsa-cert-ss.pem.digest-sha1</file>
|
||||
<file>certificates/dsa-cert-ss.pem.pubkey</file>
|
||||
<file>certificates/ec-cert-ss.der.pubkey</file>
|
||||
<file>certificates/ec-cert-ss.pem</file>
|
||||
<file>certificates/ec-cert-ss.pem.digest-md5</file>
|
||||
<file>certificates/ec-cert-ss.pem.digest-sha1</file>
|
||||
<file>certificates/ec-cert-ss.pem.pubkey</file>
|
||||
<file>certificates/gencertificates.sh</file>
|
||||
<file>certificates/san.cnf</file>
|
||||
<file>more-certificates/badguy-nul-cn.crt</file>
|
||||
<file>more-certificates/badguy-nul-san.crt</file>
|
||||
<file>more-certificates/blacklisted-anssi-tresor.pem</file>
|
||||
<file>more-certificates/blacklisted-google.com-diginotar.pem</file>
|
||||
<file>more-certificates/blacklisted-nic-india-2007.pem</file>
|
||||
<file>more-certificates/blacklisted-nic-india-2011.pem</file>
|
||||
<file>more-certificates/blacklisted-nic-india-2014.pem</file>
|
||||
<file>more-certificates/blacklisted-turktrust-e-islem.kktcmerkezbankasi.org.pem</file>
|
||||
<file>more-certificates/blacklisted-turktrust-ego.gov.tr.pem</file>
|
||||
<file>more-certificates/blacklisted1.pem</file>
|
||||
<file>more-certificates/blacklisted2.pem</file>
|
||||
<file>more-certificates/blacklisted3.pem</file>
|
||||
<file>more-certificates/blacklisted4.pem</file>
|
||||
<file>more-certificates/blacklisted5.pem</file>
|
||||
<file>more-certificates/blacklisted6.pem</file>
|
||||
<file>more-certificates/blacklisted7.pem</file>
|
||||
<file>more-certificates/blacklisted8.pem</file>
|
||||
<file>more-certificates/blacklisted9.pem</file>
|
||||
<file>more-certificates/cert-large-expiration-date.pem</file>
|
||||
<file>more-certificates/cert-large-expiration-date.txt.0.9.8</file>
|
||||
<file>more-certificates/cert-large-expiration-date.txt.1.0.0</file>
|
||||
<file>more-certificates/cert-large-expiration-date.txt.1.0.1</file>
|
||||
<file>more-certificates/cert-large-expiration-date.txt.1.0.1c</file>
|
||||
<file>more-certificates/cert-large-serial-number.pem</file>
|
||||
<file>more-certificates/malformed-just-begin-no-newline.pem</file>
|
||||
<file>more-certificates/malformed-just-begin.pem</file>
|
||||
<file>more-certificates/natwest-banking.pem</file>
|
||||
<file>more-certificates/no-ending-newline.pem</file>
|
||||
<file>more-certificates/test-cn-two-cns-cert.pem</file>
|
||||
<file>more-certificates/test-cn-with-drink-cert.pem</file>
|
||||
<file>more-certificates/trailing-whitespace.pem</file>
|
||||
<file>pkcs12/inter.crt</file>
|
||||
<file>pkcs12/leaf-nokey.p12</file>
|
||||
<file>pkcs12/leaf.crt</file>
|
||||
<file>pkcs12/leaf.key</file>
|
||||
<file>pkcs12/leaf.p12</file>
|
||||
<file>pkcs12/README</file>
|
||||
<file>verify-certs/cacert.pem</file>
|
||||
<file>verify-certs/README</file>
|
||||
<file>verify-certs/test-addons-mozilla-org-cert.pem</file>
|
||||
<file>verify-certs/test-intermediate-ca-cert.pem</file>
|
||||
<file>verify-certs/test-intermediate-is-ca-cert.pem</file>
|
||||
<file>verify-certs/test-intermediate-not-ca-cert.pem</file>
|
||||
<file>verify-certs/test-ocsp-good-cert.pem</file>
|
||||
</qresource>
|
||||
</RCC>
|
@ -57,8 +57,11 @@ 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:
|
||||
@ -108,11 +111,23 @@ private slots:
|
||||
// ### add tests for certificate bundles (multiple certificates concatenated into a single
|
||||
// structure); both PEM and DER formatted
|
||||
#endif
|
||||
private:
|
||||
QString testDataDir;
|
||||
};
|
||||
|
||||
void tst_QSslCertificate::initTestCase()
|
||||
{
|
||||
QDir dir(":/certificates");
|
||||
testDataDir = QFileInfo(QFINDTESTDATA("certificates")).absolutePath();
|
||||
if (testDataDir.isEmpty())
|
||||
testDataDir = QCoreApplication::applicationDirPath();
|
||||
|
||||
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)$"));
|
||||
QRegExp rxSan(QLatin1String("^(.+\\.(?:pem|der))\\.san$"));
|
||||
@ -136,6 +151,13 @@ void tst_QSslCertificate::initTestCase()
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QSslCertificate::cleanupTestCase()
|
||||
{
|
||||
if (!oldCurrentDir.isEmpty()) {
|
||||
QDir::setCurrent(oldCurrentDir);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
|
||||
void tst_QSslCertificate::hash()
|
||||
@ -210,7 +232,7 @@ void tst_QSslCertificate::constructor_device()
|
||||
if (!QSslSocket::supportsSsl())
|
||||
return;
|
||||
|
||||
QFile f(":/verify-certs/test-ocsp-good-cert.pem");
|
||||
QFile f(testDataDir + "/verify-certs/test-ocsp-good-cert.pem");
|
||||
bool ok = f.open(QIODevice::ReadOnly);
|
||||
QVERIFY(ok);
|
||||
|
||||
@ -219,7 +241,7 @@ void tst_QSslCertificate::constructor_device()
|
||||
f.close();
|
||||
|
||||
// Check opening a DER as a PEM fails
|
||||
QFile f2(":/certificates/cert.der");
|
||||
QFile f2(testDataDir + "/certificates/cert.der");
|
||||
ok = f2.open(QIODevice::ReadOnly);
|
||||
QVERIFY(ok);
|
||||
|
||||
@ -228,7 +250,7 @@ void tst_QSslCertificate::constructor_device()
|
||||
f2.close();
|
||||
|
||||
// Check opening a DER as a DER works
|
||||
QFile f3(":/certificates/cert.der");
|
||||
QFile f3(testDataDir + "/certificates/cert.der");
|
||||
ok = f3.open(QIODevice::ReadOnly);
|
||||
QVERIFY(ok);
|
||||
|
||||
@ -237,7 +259,7 @@ void tst_QSslCertificate::constructor_device()
|
||||
f3.close();
|
||||
|
||||
// Check opening a PEM as a DER fails
|
||||
QFile f4(":/verify-certs/test-ocsp-good-cert.pem");
|
||||
QFile f4(testDataDir + "/verify-certs/test-ocsp-good-cert.pem");
|
||||
ok = f4.open(QIODevice::ReadOnly);
|
||||
QVERIFY(ok);
|
||||
|
||||
@ -423,7 +445,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("certificates/cert-ss-san-utf8.pem", QSsl::Pem,
|
||||
QRegExp::FixedString).first();
|
||||
QVERIFY(!cert.isNull());
|
||||
|
||||
@ -546,60 +568,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") << 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;
|
||||
#ifdef Q_OS_LINUX
|
||||
QTest::newRow("absolute path wildcard pem") << (":/certificates/*.pem") << int(QRegExp::Wildcard) << true << 7;
|
||||
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") << 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;
|
||||
}
|
||||
|
||||
void tst_QSslCertificate::fromPath()
|
||||
@ -700,7 +722,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("certificates/cert.pem", QSsl::Pem,
|
||||
QRegExp::FixedString).first();
|
||||
QVERIFY(!cert.isNull());
|
||||
|
||||
@ -757,7 +779,7 @@ void tst_QSslCertificate::certInfo()
|
||||
|
||||
void tst_QSslCertificate::certInfoQByteArray()
|
||||
{
|
||||
QSslCertificate cert = QSslCertificate::fromPath(":/certificates/cert.pem", QSsl::Pem,
|
||||
QSslCertificate cert = QSslCertificate::fromPath("certificates/cert.pem", QSsl::Pem,
|
||||
QRegExp::FixedString).first();
|
||||
QVERIFY(!cert.isNull());
|
||||
|
||||
@ -810,7 +832,7 @@ void tst_QSslCertificate::nulInCN()
|
||||
QSKIP("Generic QSslCertificatePrivate fails this test");
|
||||
#endif
|
||||
QList<QSslCertificate> certList =
|
||||
QSslCertificate::fromPath(":/more-certificates/badguy-nul-cn.crt");
|
||||
QSslCertificate::fromPath(testDataDir + "/more-certificates/badguy-nul-cn.crt");
|
||||
QCOMPARE(certList.size(), 1);
|
||||
|
||||
const QSslCertificate &cert = certList.at(0);
|
||||
@ -829,7 +851,7 @@ void tst_QSslCertificate::nulInSan()
|
||||
QSKIP("Generic QSslCertificatePrivate fails this test");
|
||||
#endif
|
||||
QList<QSslCertificate> certList =
|
||||
QSslCertificate::fromPath(":/more-certificates/badguy-nul-san.crt");
|
||||
QSslCertificate::fromPath(testDataDir + "/more-certificates/badguy-nul-san.crt");
|
||||
QCOMPARE(certList.size(), 1);
|
||||
|
||||
const QSslCertificate &cert = certList.at(0);
|
||||
@ -849,7 +871,7 @@ void tst_QSslCertificate::nulInSan()
|
||||
void tst_QSslCertificate::largeSerialNumber()
|
||||
{
|
||||
QList<QSslCertificate> certList =
|
||||
QSslCertificate::fromPath(":/more-certificates/cert-large-serial-number.pem");
|
||||
QSslCertificate::fromPath(testDataDir + "/more-certificates/cert-large-serial-number.pem");
|
||||
|
||||
QCOMPARE(certList.size(), 1);
|
||||
|
||||
@ -861,7 +883,7 @@ void tst_QSslCertificate::largeSerialNumber()
|
||||
void tst_QSslCertificate::largeExpirationDate() // QTBUG-12489
|
||||
{
|
||||
QList<QSslCertificate> certList =
|
||||
QSslCertificate::fromPath(":/more-certificates/cert-large-expiration-date.pem");
|
||||
QSslCertificate::fromPath(testDataDir + "/more-certificates/cert-large-expiration-date.pem");
|
||||
|
||||
QCOMPARE(certList.size(), 1);
|
||||
|
||||
@ -874,8 +896,8 @@ void tst_QSslCertificate::largeExpirationDate() // QTBUG-12489
|
||||
|
||||
void tst_QSslCertificate::blacklistedCertificates()
|
||||
{
|
||||
QList<QSslCertificate> blacklistedCerts = QSslCertificate::fromPath(":/more-certificates/blacklisted*.pem", QSsl::Pem, QRegExp::Wildcard);
|
||||
QVERIFY(blacklistedCerts.count() > 0);
|
||||
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");
|
||||
for (int a = 0; a < blacklistedCerts.count(); a++) {
|
||||
QVERIFY(blacklistedCerts.at(a).isBlacklisted());
|
||||
}
|
||||
@ -883,34 +905,34 @@ void tst_QSslCertificate::blacklistedCertificates()
|
||||
|
||||
void tst_QSslCertificate::selfsignedCertificates()
|
||||
{
|
||||
QVERIFY(QSslCertificate::fromPath(":/certificates/cert-ss.pem").first().isSelfSigned());
|
||||
QVERIFY(!QSslCertificate::fromPath(":/certificates/cert.pem").first().isSelfSigned());
|
||||
QVERIFY(QSslCertificate::fromPath(testDataDir + "/certificates/cert-ss.pem").first().isSelfSigned());
|
||||
QVERIFY(!QSslCertificate::fromPath(testDataDir + "/certificates/cert.pem").first().isSelfSigned());
|
||||
QVERIFY(!QSslCertificate().isSelfSigned());
|
||||
}
|
||||
|
||||
void tst_QSslCertificate::toText()
|
||||
{
|
||||
QList<QSslCertificate> certList =
|
||||
QSslCertificate::fromPath(":/more-certificates/cert-large-expiration-date.pem");
|
||||
QSslCertificate::fromPath(testDataDir + "/more-certificates/cert-large-expiration-date.pem");
|
||||
|
||||
QCOMPARE(certList.size(), 1);
|
||||
const QSslCertificate &cert = certList.at(0);
|
||||
|
||||
// Openssl's cert dump method changed slightly between 0.9.8, 1.0.0 and 1.01 versions, so we want it to match any output
|
||||
|
||||
QFile f098(":/more-certificates/cert-large-expiration-date.txt.0.9.8");
|
||||
QFile f098(testDataDir + "/more-certificates/cert-large-expiration-date.txt.0.9.8");
|
||||
QVERIFY(f098.open(QIODevice::ReadOnly | QFile::Text));
|
||||
QByteArray txt098 = f098.readAll();
|
||||
|
||||
QFile f100(":/more-certificates/cert-large-expiration-date.txt.1.0.0");
|
||||
QFile f100(testDataDir + "/more-certificates/cert-large-expiration-date.txt.1.0.0");
|
||||
QVERIFY(f100.open(QIODevice::ReadOnly | QFile::Text));
|
||||
QByteArray txt100 = f100.readAll();
|
||||
|
||||
QFile f101(":/more-certificates/cert-large-expiration-date.txt.1.0.1");
|
||||
QFile f101(testDataDir + "/more-certificates/cert-large-expiration-date.txt.1.0.1");
|
||||
QVERIFY(f101.open(QIODevice::ReadOnly | QFile::Text));
|
||||
QByteArray txt101 = f101.readAll();
|
||||
|
||||
QFile f101c(":/more-certificates/cert-large-expiration-date.txt.1.0.1c");
|
||||
QFile f101c(testDataDir + "/more-certificates/cert-large-expiration-date.txt.1.0.1c");
|
||||
QVERIFY(f101c.open(QIODevice::ReadOnly | QFile::Text));
|
||||
QByteArray txt101c = f101c.readAll();
|
||||
|
||||
@ -928,8 +950,8 @@ void tst_QSslCertificate::toText()
|
||||
void tst_QSslCertificate::multipleCommonNames()
|
||||
{
|
||||
QList<QSslCertificate> certList =
|
||||
QSslCertificate::fromPath(":/more-certificates/test-cn-two-cns-cert.pem");
|
||||
QVERIFY(certList.count() > 0);
|
||||
QSslCertificate::fromPath(testDataDir + "/more-certificates/test-cn-two-cns-cert.pem");
|
||||
QVERIFY2(certList.count() > 0, "Please run this test from the source directory");
|
||||
|
||||
QStringList commonNames = certList[0].subjectInfo(QSslCertificate::CommonName);
|
||||
QVERIFY(commonNames.contains(QString("www.example.com")));
|
||||
@ -939,15 +961,15 @@ void tst_QSslCertificate::multipleCommonNames()
|
||||
void tst_QSslCertificate::subjectAndIssuerAttributes()
|
||||
{
|
||||
QList<QSslCertificate> certList =
|
||||
QSslCertificate::fromPath(":/more-certificates/test-cn-with-drink-cert.pem");
|
||||
QVERIFY(certList.count() > 0);
|
||||
QSslCertificate::fromPath(testDataDir + "/more-certificates/test-cn-with-drink-cert.pem");
|
||||
QVERIFY2(certList.count() > 0, "Please run this test from the source directory");
|
||||
|
||||
QList<QByteArray> attributes = certList[0].subjectInfoAttributes();
|
||||
QVERIFY(attributes.contains(QByteArray("favouriteDrink")));
|
||||
attributes.clear();
|
||||
|
||||
certList = QSslCertificate::fromPath(":/more-certificates/natwest-banking.pem");
|
||||
QVERIFY(certList.count() > 0);
|
||||
certList = QSslCertificate::fromPath(testDataDir + "/more-certificates/natwest-banking.pem");
|
||||
QVERIFY2(certList.count() > 0, "Please run this test from the source directory");
|
||||
|
||||
attributes = certList[0].subjectInfoAttributes();
|
||||
QVERIFY(attributes.contains(QByteArray("1.3.6.1.4.1.311.60.2.1.3")));
|
||||
@ -977,17 +999,17 @@ void tst_QSslCertificate::verify()
|
||||
errors.clear();
|
||||
|
||||
// Verify a valid cert signed by a CA
|
||||
QList<QSslCertificate> caCerts = QSslCertificate::fromPath(":/verify-certs/cacert.pem");
|
||||
QList<QSslCertificate> caCerts = QSslCertificate::fromPath(testDataDir + "/verify-certs/cacert.pem");
|
||||
QSslSocket::addDefaultCaCertificate(caCerts.first());
|
||||
|
||||
toVerify = QSslCertificate::fromPath(":/verify-certs/test-ocsp-good-cert.pem");
|
||||
toVerify = QSslCertificate::fromPath(testDataDir + "/verify-certs/test-ocsp-good-cert.pem");
|
||||
|
||||
errors = QSslCertificate::verify(toVerify);
|
||||
VERIFY_VERBOSE(errors.count() == 0);
|
||||
errors.clear();
|
||||
|
||||
// Test a blacklisted certificate
|
||||
toVerify = QSslCertificate::fromPath(":/verify-certs/test-addons-mozilla-org-cert.pem");
|
||||
toVerify = QSslCertificate::fromPath(testDataDir + "/verify-certs/test-addons-mozilla-org-cert.pem");
|
||||
errors = QSslCertificate::verify(toVerify);
|
||||
bool foundBlack = false;
|
||||
foreach (const QSslError &error, errors) {
|
||||
@ -1000,7 +1022,7 @@ void tst_QSslCertificate::verify()
|
||||
errors.clear();
|
||||
|
||||
// This one is expired and untrusted
|
||||
toVerify = QSslCertificate::fromPath(":/more-certificates/cert-large-serial-number.pem");
|
||||
toVerify = QSslCertificate::fromPath(testDataDir + "/more-certificates/cert-large-serial-number.pem");
|
||||
errors = QSslCertificate::verify(toVerify);
|
||||
VERIFY_VERBOSE(errors.contains(QSslError(QSslError::SelfSignedCertificate, toVerify[0])));
|
||||
VERIFY_VERBOSE(errors.contains(QSslError(QSslError::CertificateExpired, toVerify[0])));
|
||||
@ -1008,15 +1030,15 @@ void tst_QSslCertificate::verify()
|
||||
toVerify.clear();
|
||||
|
||||
// This one is signed by a valid cert, but the signer is not a valid CA
|
||||
toVerify << QSslCertificate::fromPath(":/verify-certs/test-intermediate-not-ca-cert.pem").first();
|
||||
toVerify << QSslCertificate::fromPath(":/verify-certs/test-ocsp-good-cert.pem").first();
|
||||
toVerify << QSslCertificate::fromPath(testDataDir + "/verify-certs/test-intermediate-not-ca-cert.pem").first();
|
||||
toVerify << QSslCertificate::fromPath(testDataDir + "/verify-certs/test-ocsp-good-cert.pem").first();
|
||||
errors = QSslCertificate::verify(toVerify);
|
||||
VERIFY_VERBOSE(errors.contains(QSslError(QSslError::InvalidCaCertificate, toVerify[1])));
|
||||
toVerify.clear();
|
||||
|
||||
// This one is signed by a valid cert, and the signer is a valid CA
|
||||
toVerify << QSslCertificate::fromPath(":/verify-certs/test-intermediate-is-ca-cert.pem").first();
|
||||
toVerify << QSslCertificate::fromPath(":/verify-certs/test-intermediate-ca-cert.pem").first();
|
||||
toVerify << QSslCertificate::fromPath(testDataDir + "/verify-certs/test-intermediate-is-ca-cert.pem").first();
|
||||
toVerify << QSslCertificate::fromPath(testDataDir + "/verify-certs/test-intermediate-ca-cert.pem").first();
|
||||
errors = QSslCertificate::verify(toVerify);
|
||||
VERIFY_VERBOSE(errors.count() == 0);
|
||||
|
||||
@ -1046,8 +1068,8 @@ QString tst_QSslCertificate::toString(const QList<QSslError>& errors)
|
||||
void tst_QSslCertificate::extensions()
|
||||
{
|
||||
QList<QSslCertificate> certList =
|
||||
QSslCertificate::fromPath(":/more-certificates/natwest-banking.pem");
|
||||
QVERIFY(certList.count() > 0);
|
||||
QSslCertificate::fromPath(testDataDir + "/more-certificates/natwest-banking.pem");
|
||||
QVERIFY2(certList.count() > 0, "Please run this test from the source directory");
|
||||
|
||||
QSslCertificate cert = certList[0];
|
||||
QList<QSslCertificateExtension> extensions = cert.extensions();
|
||||
@ -1144,8 +1166,8 @@ void tst_QSslCertificate::extensions()
|
||||
void tst_QSslCertificate::extensionsCritical()
|
||||
{
|
||||
QList<QSslCertificate> certList =
|
||||
QSslCertificate::fromPath(":/verify-certs/test-addons-mozilla-org-cert.pem");
|
||||
QVERIFY(certList.count() > 0);
|
||||
QSslCertificate::fromPath(testDataDir + "/verify-certs/test-addons-mozilla-org-cert.pem");
|
||||
QVERIFY2(certList.count() > 0, "Please run this test from the source directory");
|
||||
|
||||
QSslCertificate cert = certList[0];
|
||||
QList<QSslCertificateExtension> extensions = cert.extensions();
|
||||
@ -1227,7 +1249,7 @@ void tst_QSslCertificate::threadSafeConstMethods()
|
||||
if (!QSslSocket::supportsSsl())
|
||||
return;
|
||||
|
||||
QByteArray encoded = readFile(":/certificates/cert.pem");
|
||||
QByteArray encoded = readFile(testDataDir + "/certificates/cert.pem");
|
||||
QSslCertificate certificate(encoded);
|
||||
QVERIFY(!certificate.isNull());
|
||||
|
||||
@ -1265,12 +1287,12 @@ void tst_QSslCertificate::version_data()
|
||||
QTest::newRow("null certificate") << QSslCertificate() << QByteArray();
|
||||
|
||||
QList<QSslCertificate> certs;
|
||||
certs << QSslCertificate::fromPath(":/verify-certs/test-ocsp-good-cert.pem");
|
||||
certs << QSslCertificate::fromPath(testDataDir + "/verify-certs/test-ocsp-good-cert.pem");
|
||||
|
||||
QTest::newRow("v3 certificate") << certs.first() << QByteArrayLiteral("3");
|
||||
|
||||
certs.clear();
|
||||
certs << QSslCertificate::fromPath(":/certificates/cert.pem");
|
||||
certs << QSslCertificate::fromPath(testDataDir + "/certificates/cert.pem");
|
||||
QTest::newRow("v1 certificate") << certs.first() << QByteArrayLiteral("1");
|
||||
}
|
||||
|
||||
@ -1292,7 +1314,7 @@ void tst_QSslCertificate::pkcs12()
|
||||
return;
|
||||
}
|
||||
|
||||
QFile f(QLatin1String(":/pkcs12/leaf.p12"));
|
||||
QFile f(testDataDir + QLatin1String("/pkcs12/leaf.p12"));
|
||||
bool ok = f.open(QIODevice::ReadOnly);
|
||||
QVERIFY(ok);
|
||||
|
||||
@ -1307,12 +1329,12 @@ void tst_QSslCertificate::pkcs12()
|
||||
QVERIFY(ok);
|
||||
f.close();
|
||||
|
||||
QList<QSslCertificate> leafCert = QSslCertificate::fromPath(QLatin1String(":/pkcs12/leaf.crt"));
|
||||
QList<QSslCertificate> leafCert = QSslCertificate::fromPath(testDataDir + QLatin1String("/pkcs12/leaf.crt"));
|
||||
QVERIFY(!leafCert.isEmpty());
|
||||
|
||||
QCOMPARE(cert, leafCert.first());
|
||||
|
||||
QFile f2(QLatin1String(":/pkcs12/leaf.key"));
|
||||
QFile f2(testDataDir + QLatin1String("/pkcs12/leaf.key"));
|
||||
ok = f2.open(QIODevice::ReadOnly);
|
||||
QVERIFY(ok);
|
||||
|
||||
@ -1322,7 +1344,7 @@ void tst_QSslCertificate::pkcs12()
|
||||
QVERIFY(!leafKey.isNull());
|
||||
QCOMPARE(key, leafKey);
|
||||
|
||||
QList<QSslCertificate> caCert = QSslCertificate::fromPath(QLatin1String(":/pkcs12/inter.crt"));
|
||||
QList<QSslCertificate> caCert = QSslCertificate::fromPath(testDataDir + QLatin1String("/pkcs12/inter.crt"));
|
||||
QVERIFY(!caCert.isEmpty());
|
||||
|
||||
QVERIFY(!caCerts.isEmpty());
|
||||
@ -1330,7 +1352,7 @@ void tst_QSslCertificate::pkcs12()
|
||||
QCOMPARE(caCerts, caCert);
|
||||
|
||||
// QTBUG-62335 - Fail (found no private key) but don't crash:
|
||||
QFile nocert(QLatin1String(":/pkcs12/leaf-nokey.p12"));
|
||||
QFile nocert(testDataDir + QLatin1String("/pkcs12/leaf-nokey.p12"));
|
||||
ok = nocert.open(QIODevice::ReadOnly);
|
||||
QVERIFY(ok);
|
||||
QTest::ignoreMessage(QtWarningMsg, "Unable to convert private key");
|
||||
|
@ -9,7 +9,4 @@ qtConfig(private_tests) {
|
||||
|
||||
TARGET = tst_qsslkey
|
||||
|
||||
RESOURCES += \
|
||||
qsslkey.qrc
|
||||
|
||||
TESTDATA += keys/* rsa-without-passphrase.pem rsa-with-passphrase.pem
|
||||
|
@ -1,65 +0,0 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>rsa-without-passphrase.pem</file>
|
||||
<file>rsa-with-passphrase-3des.pem</file>
|
||||
<file>rsa-with-passphrase-des.pem</file>
|
||||
<file>rsa-with-passphrase-rc2.pem</file>
|
||||
<file>keys/dsa-pri-1024.der</file>
|
||||
<file>keys/dsa-pri-1024.pem</file>
|
||||
<file>keys/dsa-pri-512.der</file>
|
||||
<file>keys/dsa-pri-512.pem</file>
|
||||
<file>keys/dsa-pri-576.der</file>
|
||||
<file>keys/dsa-pri-576.pem</file>
|
||||
<file>keys/dsa-pri-960.der</file>
|
||||
<file>keys/dsa-pri-960.pem</file>
|
||||
<file>keys/dsa-pub-1024.der</file>
|
||||
<file>keys/dsa-pub-1024.pem</file>
|
||||
<file>keys/dsa-pub-512.der</file>
|
||||
<file>keys/dsa-pub-512.pem</file>
|
||||
<file>keys/dsa-pub-576.der</file>
|
||||
<file>keys/dsa-pub-576.pem</file>
|
||||
<file>keys/dsa-pub-960.der</file>
|
||||
<file>keys/dsa-pub-960.pem</file>
|
||||
<file>keys/ec-pri-224-secp224r1.der</file>
|
||||
<file>keys/ec-pri-224-secp224r1.pem</file>
|
||||
<file>keys/ec-pri-256-prime256v1.der</file>
|
||||
<file>keys/ec-pri-256-prime256v1.pem</file>
|
||||
<file>keys/ec-pri-384-secp384r1.der</file>
|
||||
<file>keys/ec-pri-384-secp384r1.pem</file>
|
||||
<file>keys/ec-pub-224-secp224r1.der</file>
|
||||
<file>keys/ec-pub-224-secp224r1.pem</file>
|
||||
<file>keys/ec-pub-256-prime256v1.der</file>
|
||||
<file>keys/ec-pub-256-prime256v1.pem</file>
|
||||
<file>keys/ec-pub-384-secp384r1.der</file>
|
||||
<file>keys/ec-pub-384-secp384r1.pem</file>
|
||||
<file>keys/genkeys.sh</file>
|
||||
<file>keys/rsa-pri-1023.der</file>
|
||||
<file>keys/rsa-pri-1023.pem</file>
|
||||
<file>keys/rsa-pri-1024.der</file>
|
||||
<file>keys/rsa-pri-1024.pem</file>
|
||||
<file>keys/rsa-pri-2048.der</file>
|
||||
<file>keys/rsa-pri-2048.pem</file>
|
||||
<file>keys/rsa-pri-40.der</file>
|
||||
<file>keys/rsa-pri-40.pem</file>
|
||||
<file>keys/rsa-pri-511.der</file>
|
||||
<file>keys/rsa-pri-511.pem</file>
|
||||
<file>keys/rsa-pri-512.der</file>
|
||||
<file>keys/rsa-pri-512.pem</file>
|
||||
<file>keys/rsa-pri-999.der</file>
|
||||
<file>keys/rsa-pri-999.pem</file>
|
||||
<file>keys/rsa-pub-1023.der</file>
|
||||
<file>keys/rsa-pub-1023.pem</file>
|
||||
<file>keys/rsa-pub-1024.der</file>
|
||||
<file>keys/rsa-pub-1024.pem</file>
|
||||
<file>keys/rsa-pub-2048.der</file>
|
||||
<file>keys/rsa-pub-2048.pem</file>
|
||||
<file>keys/rsa-pub-40.der</file>
|
||||
<file>keys/rsa-pub-40.pem</file>
|
||||
<file>keys/rsa-pub-511.der</file>
|
||||
<file>keys/rsa-pub-511.pem</file>
|
||||
<file>keys/rsa-pub-512.der</file>
|
||||
<file>keys/rsa-pub-512.pem</file>
|
||||
<file>keys/rsa-pub-999.der</file>
|
||||
<file>keys/rsa-pub-999.pem</file>
|
||||
</qresource>
|
||||
</RCC>
|
@ -97,11 +97,17 @@ private slots:
|
||||
#endif
|
||||
|
||||
#endif
|
||||
private:
|
||||
QString testDataDir;
|
||||
};
|
||||
|
||||
void tst_QSslKey::initTestCase()
|
||||
{
|
||||
QDir dir(":/keys");
|
||||
testDataDir = QFileInfo(QFINDTESTDATA("rsa-without-passphrase.pem")).absolutePath();
|
||||
if (testDataDir.isEmpty())
|
||||
testDataDir = QCoreApplication::applicationDirPath();
|
||||
|
||||
QDir dir(testDataDir + "/keys");
|
||||
QFileInfoList fileInfoList = dir.entryInfoList(QDir::Files | QDir::Readable);
|
||||
QRegExp rx(QLatin1String("^(rsa|dsa|ec)-(pub|pri)-(\\d+)-?\\w*\\.(pem|der)$"));
|
||||
foreach (QFileInfo fileInfo, fileInfoList) {
|
||||
@ -386,9 +392,9 @@ void tst_QSslKey::passphraseChecks_data()
|
||||
{
|
||||
QTest::addColumn<QString>("fileName");
|
||||
|
||||
QTest::newRow("DES") << QString(":/rsa-with-passphrase-des.pem");
|
||||
QTest::newRow("3DES") << QString(":/rsa-with-passphrase-3des.pem");
|
||||
QTest::newRow("RC2") << QString(":/rsa-with-passphrase-rc2.pem");
|
||||
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");
|
||||
}
|
||||
|
||||
void tst_QSslKey::passphraseChecks()
|
||||
@ -434,7 +440,7 @@ void tst_QSslKey::passphraseChecks()
|
||||
void tst_QSslKey::noPassphraseChecks()
|
||||
{
|
||||
// be sure and check a key without passphrase too
|
||||
QString fileName(":/rsa-without-passphrase.pem");
|
||||
QString fileName(testDataDir + "/rsa-without-passphrase.pem");
|
||||
QFile keyFile(fileName);
|
||||
{
|
||||
if (!keyFile.isOpen())
|
||||
|
@ -14,9 +14,6 @@ win32 {
|
||||
}
|
||||
}
|
||||
|
||||
RESOURCES += \
|
||||
qsslsocket.qrc
|
||||
|
||||
DEFINES += SRCDIR=\\\"$$PWD/\\\"
|
||||
|
||||
requires(qtConfig(private_tests))
|
||||
|
@ -1,21 +0,0 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>certs/aspiriniks.ca.crt</file>
|
||||
<file>certs/bogus-ca.crt</file>
|
||||
<file>certs/bogus-ca.key</file>
|
||||
<file>certs/bogus-client.crt</file>
|
||||
<file>certs/bogus-client.key</file>
|
||||
<file>certs/bogus-server.crt</file>
|
||||
<file>certs/bogus-server.key</file>
|
||||
<file>certs/ca.crt</file>
|
||||
<file>certs/fake-login.live.com.key</file>
|
||||
<file>certs/fake-login.live.com.pem</file>
|
||||
<file>certs/fluke.cert</file>
|
||||
<file>certs/fluke.key</file>
|
||||
<file>certs/inter.crt</file>
|
||||
<file>certs/leaf.crt</file>
|
||||
<file>certs/leaf.key</file>
|
||||
<file>certs/qt-test-server-cacert.pem</file>
|
||||
<file>certs/xn--schufele-2za.crt</file>
|
||||
</qresource>
|
||||
</RCC>
|
@ -705,7 +705,7 @@ void tst_QSslSocket::connectToHostEncrypted()
|
||||
|
||||
QSslSocketPtr socket = newSocket();
|
||||
this->socket = socket.data();
|
||||
QVERIFY(socket->addCaCertificates(QLatin1String(":/certs/qt-test-server-cacert.pem")));
|
||||
QVERIFY(socket->addCaCertificates(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem")));
|
||||
#ifdef QSSLSOCKET_CERTUNTRUSTED_WORKAROUND
|
||||
connect(socket.data(), SIGNAL(sslErrors(QList<QSslError>)),
|
||||
this, SLOT(untrustedWorkaroundSlot(QList<QSslError>)));
|
||||
@ -739,7 +739,7 @@ void tst_QSslSocket::connectToHostEncryptedWithVerificationPeerName()
|
||||
QSslSocketPtr socket = newSocket();
|
||||
this->socket = socket.data();
|
||||
|
||||
socket->addCaCertificates(QLatin1String(":/certs/qt-test-server-cacert.pem"));
|
||||
socket->addCaCertificates(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem"));
|
||||
#ifdef QSSLSOCKET_CERTUNTRUSTED_WORKAROUND
|
||||
connect(socket.data(), SIGNAL(sslErrors(QList<QSslError>)),
|
||||
this, SLOT(untrustedWorkaroundSlot(QList<QSslError>)));
|
||||
@ -803,10 +803,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(":/certs/qt-test-server-cacert.pem");
|
||||
QList<QSslCertificate> localCert = QSslCertificate::fromPath(SRCDIR "certs/qt-test-server-cacert.pem");
|
||||
socket->setCaCertificates(localCert);
|
||||
socket->setLocalCertificate(QLatin1String(":/certs/fluke.cert"));
|
||||
socket->setPrivateKey(QLatin1String(":/certs/fluke.key"));
|
||||
socket->setLocalCertificate(QLatin1String(SRCDIR "certs/fluke.cert"));
|
||||
socket->setPrivateKey(QLatin1String(SRCDIR "certs/fluke.key"));
|
||||
|
||||
socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443);
|
||||
QFETCH_GLOBAL(bool, setProxy);
|
||||
@ -832,7 +832,7 @@ void tst_QSslSocket::peerCertificateChain()
|
||||
QSslSocketPtr socket = newSocket();
|
||||
this->socket = socket.data();
|
||||
|
||||
QList<QSslCertificate> caCertificates = QSslCertificate::fromPath(QLatin1String(":/certs/qt-test-server-cacert.pem"));
|
||||
QList<QSslCertificate> caCertificates = QSslCertificate::fromPath(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem"));
|
||||
QCOMPARE(caCertificates.count(), 1);
|
||||
socket->addCaCertificates(caCertificates);
|
||||
#ifdef QSSLSOCKET_CERTUNTRUSTED_WORKAROUND
|
||||
@ -895,7 +895,7 @@ void tst_QSslSocket::privateKeyOpaque()
|
||||
if (!QSslSocket::supportsSsl())
|
||||
return;
|
||||
|
||||
QFile file(":/certs/fluke.key");
|
||||
QFile file(SRCDIR "certs/fluke.key");
|
||||
QVERIFY(file.open(QIODevice::ReadOnly));
|
||||
QSslKey key(file.readAll(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey);
|
||||
QVERIFY(!key.isNull());
|
||||
@ -908,9 +908,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(":/certs/qt-test-server-cacert.pem");
|
||||
QList<QSslCertificate> localCert = QSslCertificate::fromPath(SRCDIR "certs/qt-test-server-cacert.pem");
|
||||
socket->setCaCertificates(localCert);
|
||||
socket->setLocalCertificate(QLatin1String(":/certs/fluke.cert"));
|
||||
socket->setLocalCertificate(QLatin1String(SRCDIR "certs/fluke.cert"));
|
||||
socket->setPrivateKey(QSslKey(reinterpret_cast<Qt::HANDLE>(pkey)));
|
||||
|
||||
socket->setPeerVerifyMode(QSslSocket::QueryPeer);
|
||||
@ -928,7 +928,7 @@ void tst_QSslSocket::protocol()
|
||||
|
||||
QSslSocketPtr socket = newSocket();
|
||||
this->socket = socket.data();
|
||||
QList<QSslCertificate> certs = QSslCertificate::fromPath(":/certs/qt-test-server-cacert.pem");
|
||||
QList<QSslCertificate> certs = QSslCertificate::fromPath(SRCDIR "certs/qt-test-server-cacert.pem");
|
||||
|
||||
socket->setCaCertificates(certs);
|
||||
#ifdef QSSLSOCKET_CERTUNTRUSTED_WORKAROUND
|
||||
@ -1075,8 +1075,8 @@ class SslServer : public QTcpServer
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SslServer(const QString &keyFile = ":/certs/fluke.key",
|
||||
const QString &certFile = ":/certs/fluke.cert",
|
||||
SslServer(const QString &keyFile = SRCDIR "certs/fluke.key",
|
||||
const QString &certFile = SRCDIR "certs/fluke.cert",
|
||||
const QString &interFile = QString())
|
||||
: socket(0),
|
||||
config(QSslConfiguration::defaultConfiguration()),
|
||||
@ -1428,7 +1428,7 @@ void tst_QSslSocket::setCaCertificates()
|
||||
|
||||
QSslSocket socket;
|
||||
QCOMPARE(socket.caCertificates(), QSslSocket::defaultCaCertificates());
|
||||
socket.setCaCertificates(QSslCertificate::fromPath(":/certs/qt-test-server-cacert.pem"));
|
||||
socket.setCaCertificates(QSslCertificate::fromPath(SRCDIR "certs/qt-test-server-cacert.pem"));
|
||||
QCOMPARE(socket.caCertificates().size(), 1);
|
||||
socket.setCaCertificates(socket.defaultCaCertificates());
|
||||
QCOMPARE(socket.caCertificates(), QSslSocket::defaultCaCertificates());
|
||||
@ -1444,7 +1444,7 @@ void tst_QSslSocket::localCertificateChain()
|
||||
return;
|
||||
|
||||
QSslSocket socket;
|
||||
socket.setLocalCertificate(QLatin1String(":/certs/fluke.cert"));
|
||||
socket.setLocalCertificate(QLatin1String(SRCDIR "certs/fluke.cert"));
|
||||
|
||||
QSslConfiguration conf = socket.sslConfiguration();
|
||||
QList<QSslCertificate> chain = conf.localCertificateChain();
|
||||
@ -1465,9 +1465,9 @@ void tst_QSslSocket::setLocalCertificateChain()
|
||||
if (setProxy)
|
||||
return;
|
||||
|
||||
SslServer server(QLatin1String(":/certs/leaf.key"),
|
||||
QLatin1String(":/certs/leaf.crt"),
|
||||
QLatin1String(":/certs/inter.crt"));
|
||||
SslServer server(QLatin1String(SRCDIR "certs/leaf.key"),
|
||||
QLatin1String(SRCDIR "certs/leaf.crt"),
|
||||
QLatin1String(SRCDIR "certs/inter.crt"));
|
||||
|
||||
QVERIFY(server.listen());
|
||||
|
||||
@ -1536,7 +1536,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(":/certs/qt-test-server-cacert.pem");
|
||||
QList<QSslCertificate> testServerCert = QSslCertificate::fromPath(SRCDIR "certs/qt-test-server-cacert.pem");
|
||||
conf.setCaCertificates(testServerCert);
|
||||
QTest::newRow("set-root-cert") << conf << true;
|
||||
conf.setProtocol(QSsl::SecureProtocols);
|
||||
@ -1639,7 +1639,7 @@ void tst_QSslSocket::addDefaultCaCertificate()
|
||||
// Reset the global CA chain
|
||||
QSslSocket::setDefaultCaCertificates(QSslSocket::systemCaCertificates());
|
||||
|
||||
QList<QSslCertificate> flukeCerts = QSslCertificate::fromPath(":/certs/qt-test-server-cacert.pem");
|
||||
QList<QSslCertificate> flukeCerts = QSslCertificate::fromPath(SRCDIR "certs/qt-test-server-cacert.pem");
|
||||
QCOMPARE(flukeCerts.size(), 1);
|
||||
QList<QSslCertificate> globalCerts = QSslSocket::defaultCaCertificates();
|
||||
QVERIFY(!globalCerts.contains(flukeCerts.first()));
|
||||
@ -1751,7 +1751,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(":/certs/xn--schufele-2za.crt");
|
||||
QList<QSslCertificate> certs = QSslCertificate::fromPath(SRCDIR "certs/xn--schufele-2za.crt");
|
||||
QVERIFY(!certs.isEmpty());
|
||||
QSslCertificate cert = certs.first();
|
||||
|
||||
@ -1807,7 +1807,7 @@ protected:
|
||||
socket->ignoreSslErrors();
|
||||
|
||||
// Only set the certificate
|
||||
QList<QSslCertificate> localCert = QSslCertificate::fromPath(":/certs/fluke.cert");
|
||||
QList<QSslCertificate> localCert = QSslCertificate::fromPath(SRCDIR "certs/fluke.cert");
|
||||
QVERIFY(!localCert.isEmpty());
|
||||
QVERIFY(!localCert.first().isNull());
|
||||
socket->setLocalCertificate(localCert.first());
|
||||
@ -2045,13 +2045,13 @@ protected:
|
||||
socket = new QSslSocket(this);
|
||||
connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot()));
|
||||
|
||||
QFile file(":/certs/fluke.key");
|
||||
QFile file(SRCDIR "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(":/certs/fluke.cert");
|
||||
QList<QSslCertificate> localCert = QSslCertificate::fromPath(SRCDIR "certs/fluke.cert");
|
||||
QVERIFY(!localCert.isEmpty());
|
||||
QVERIFY(!localCert.first().isNull());
|
||||
socket->setLocalCertificate(localCert.first());
|
||||
@ -2227,8 +2227,8 @@ protected:
|
||||
{
|
||||
socket = new QSslSocket(this);
|
||||
|
||||
socket->setPrivateKey(":/certs/fluke.key");
|
||||
socket->setLocalCertificate(":/certs/fluke.cert");
|
||||
socket->setPrivateKey(SRCDIR "certs/fluke.key");
|
||||
socket->setLocalCertificate(SRCDIR "certs/fluke.cert");
|
||||
socket->setSocketDescriptor(socketDescriptor);
|
||||
socket->startServerEncryption();
|
||||
}
|
||||
@ -2346,7 +2346,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(":/certs/qt-test-server-cacert.pem"));
|
||||
socket.addCaCertificates(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem"));
|
||||
socket.setProxy(goodProxy);
|
||||
socket.connectToHostEncrypted(QtNetworkSettings::serverName(), 443);
|
||||
QVERIFY2(socket.waitForConnected(10000), qPrintable(socket.errorString()));
|
||||
@ -2365,7 +2365,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(":/certs/qt-test-server-cacert.pem"));
|
||||
socket2.addCaCertificates(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem"));
|
||||
socket2.setProxy(badProxy);
|
||||
socket2.connectToHostEncrypted(QtNetworkSettings::serverName(), 443);
|
||||
QVERIFY(! socket2.waitForConnected(10000));
|
||||
@ -2384,7 +2384,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(":/certs/qt-test-server-cacert.pem"));
|
||||
QList<QSslCertificate> certs = QSslCertificate::fromPath(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem"));
|
||||
QSslError rightError(FLUKE_CERTIFICATE_ERROR, certs.at(0));
|
||||
QSslError wrongError(FLUKE_CERTIFICATE_ERROR);
|
||||
|
||||
@ -2563,7 +2563,7 @@ void tst_QSslSocket::blacklistedCertificates()
|
||||
if (setProxy)
|
||||
return;
|
||||
|
||||
SslServer server(":/certs/fake-login.live.com.key", ":/certs/fake-login.live.com.pem");
|
||||
SslServer server(SRCDIR "certs/fake-login.live.com.key", SRCDIR "certs/fake-login.live.com.pem");
|
||||
QSslSocket *receiver = new QSslSocket(this);
|
||||
connect(receiver, SIGNAL(readyRead()), SLOT(exitLoop()));
|
||||
|
||||
@ -2675,7 +2675,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(":/certs/qt-test-server-cacert.pem"));
|
||||
QList<QSslCertificate> certs = QSslCertificate::fromPath(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem"));
|
||||
QSslError rightError(FLUKE_CERTIFICATE_ERROR, certs.at(0));
|
||||
QSslError wrongError(FLUKE_CERTIFICATE_ERROR);
|
||||
errorsList.append(wrongError);
|
||||
@ -2745,8 +2745,8 @@ class WebSocket : public QSslSocket
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit WebSocket(qintptr socketDescriptor,
|
||||
const QString &keyFile = ":/certs/fluke.key",
|
||||
const QString &certFile = ":/certs/fluke.cert");
|
||||
const QString &keyFile = SRCDIR "certs/fluke.key",
|
||||
const QString &certFile = SRCDIR "certs/fluke.cert");
|
||||
|
||||
protected slots:
|
||||
void onReadyReadFirstBytes(void);
|
||||
@ -2957,13 +2957,13 @@ void tst_QSslSocket::qtbug18498_peek2()
|
||||
QCOMPARE(a[2], 'S');
|
||||
QCOMPARE(server->readAll(), QByteArray("TLS\r\n"));
|
||||
|
||||
QFile file(":/certs/fluke.key");
|
||||
QFile file(SRCDIR "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(":/certs/fluke.cert");
|
||||
QList<QSslCertificate> localCert = QSslCertificate::fromPath(SRCDIR "certs/fluke.cert");
|
||||
QVERIFY(!localCert.isEmpty());
|
||||
QVERIFY(!localCert.first().isNull());
|
||||
server->setLocalCertificate(localCert.first());
|
||||
@ -3163,10 +3163,10 @@ void tst_QSslSocket::verifyClientCertificate_data()
|
||||
QTest::newRow("NoCert:VerifyPeer") << QSslSocket::VerifyPeer << noCerts << noKey << false;
|
||||
|
||||
// self-signed certificate
|
||||
QList<QSslCertificate> flukeCerts = QSslCertificate::fromPath(":/certs/fluke.cert");
|
||||
QList<QSslCertificate> flukeCerts = QSslCertificate::fromPath(SRCDIR "certs/fluke.cert");
|
||||
QCOMPARE(flukeCerts.size(), 1);
|
||||
|
||||
QFile flukeFile(":/certs/fluke.key");
|
||||
QFile flukeFile(SRCDIR "certs/fluke.key");
|
||||
QVERIFY(flukeFile.open(QIODevice::ReadOnly));
|
||||
QSslKey flukeKey(flukeFile.readAll(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey);
|
||||
QVERIFY(!flukeKey.isNull());
|
||||
@ -3177,10 +3177,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(":/certs/bogus-server.crt");
|
||||
QList<QSslCertificate> serverCerts = QSslCertificate::fromPath(SRCDIR "certs/bogus-server.crt");
|
||||
QCOMPARE(serverCerts.size(), 1);
|
||||
|
||||
QFile serverFile(":/certs/bogus-server.key");
|
||||
QFile serverFile(SRCDIR "certs/bogus-server.key");
|
||||
QVERIFY(serverFile.open(QIODevice::ReadOnly));
|
||||
QSslKey serverKey(serverFile.readAll(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey);
|
||||
QVERIFY(!serverKey.isNull());
|
||||
@ -3191,10 +3191,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(":/certs/bogus-client.crt");
|
||||
QList<QSslCertificate> validCerts = QSslCertificate::fromPath(SRCDIR "certs/bogus-client.crt");
|
||||
QCOMPARE(validCerts.size(), 1);
|
||||
|
||||
QFile validFile(":/certs/bogus-client.key");
|
||||
QFile validFile(SRCDIR "certs/bogus-client.key");
|
||||
QVERIFY(validFile.open(QIODevice::ReadOnly));
|
||||
QSslKey validKey(validFile.readAll(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey);
|
||||
QVERIFY(!validKey.isNull());
|
||||
@ -3205,7 +3205,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(":/certs/bogus-ca.crt");
|
||||
validCerts += QSslCertificate::fromPath(SRCDIR "certs/bogus-ca.crt");
|
||||
QCOMPARE(validCerts.size(), 2);
|
||||
|
||||
QTest::newRow("ValidClientCert:AutoVerifyPeer") << QSslSocket::AutoVerifyPeer << validCerts << validKey << true;
|
||||
@ -3238,7 +3238,7 @@ void tst_QSslSocket::verifyClientCertificate()
|
||||
|
||||
QFETCH(QSslSocket::PeerVerifyMode, peerVerifyMode);
|
||||
SslServer server;
|
||||
server.addCaCertificates = QLatin1String(":/certs/bogus-ca.crt");
|
||||
server.addCaCertificates = QLatin1String(SRCDIR "certs/bogus-ca.crt");
|
||||
server.ignoreSslErrors = false;
|
||||
server.peerVerifyMode = peerVerifyMode;
|
||||
QVERIFY(server.listen());
|
||||
|
Loading…
Reference in New Issue
Block a user