diff options
author | Markus Goetz <Markus.Goetz@nokia.com> | 2009-06-15 15:08:34 (GMT) |
---|---|---|
committer | Markus Goetz <Markus.Goetz@nokia.com> | 2009-06-15 15:14:54 (GMT) |
commit | 7f374e0d94230c6742b9ef8bf422f7849e0fc013 (patch) | |
tree | ebfc0f76ddde5d771e5ce188f1ce7904690c8be8 /tests | |
parent | dfe63cc0056a6592a4fb4e5c725c4ea0ed10ba20 (diff) | |
download | Qt-7f374e0d94230c6742b9ef8bf422f7849e0fc013.zip Qt-7f374e0d94230c6742b9ef8bf422f7849e0fc013.tar.gz Qt-7f374e0d94230c6742b9ef8bf422f7849e0fc013.tar.bz2 |
Fix wrong comparator in QSslCertificatePrivate::QByteArray_from_X509
Because less-than instead of less-or-equal-than was used, the last
line of a PEM encoding was not built when the raw length was multiple
of 64.
Task-number: 256066
Reviewed-by: mariusSO
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qsslcertificate/tst_qsslcertificate.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp index 6f50fc4..46b8686 100644 --- a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp +++ b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp @@ -99,6 +99,7 @@ private slots: void fromPath_data(); void fromPath(); void certInfo(); + void task256066toPem(); // ### add tests for certificate bundles (multiple certificates concatenated into a single // structure); both PEM and DER formatted #endif @@ -689,6 +690,43 @@ void tst_QSslCertificate::certInfo() QCOMPARE(cert, QSslCertificate(QByteArray::fromHex(der), QSsl::Der)); } +void tst_QSslCertificate::task256066toPem() +{ + // a certificate whose PEM encoding's length is a multiple of 64 + const char *mycert = "-----BEGIN CERTIFICATE-----\n" \ + "MIIEGjCCAwKgAwIBAgIESikYSjANBgkqhkiG9w0BAQUFADBbMQswCQYDVQQGEwJF\n" \ + "RTEiMCAGA1UEChMZQVMgU2VydGlmaXRzZWVya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QUFAAOCAQEABRyRuUm9zt8V27WuNeXtCDmU\n" \ + "MGzA6g4QXNAd2nxFzT3k+kNzzQTOcgRdmjiEPuK49On+GWnBr/5MSBNhbCJVPWr/\n" \ + "yym1UYTBisaqhRt/N/kwZqd0bHeLJk+ZxSePXRyqkp9H8KPWqz7H+O/FxRS4ffxo\n" \ + "Q9Clem+e0bcjNlL5xXiRGycBeZq8cKj+0+A/UuattznQlvHdlCEsSeu1fPOORqFV\n" \ + "fZur4HC31lQD7xVvETLiL83CtOQC78+29XPD6Zlrrc5OF2yibSVParY19b8Zh6yu\n" \ + "p1dNvN8pBgXGrsyxRonwHooV2ghGNmGILkpdvlQfnxeCUg4erfHjDdSY9vmT7w==\n" \ + "-----END CERTIFICATE-----\n"; + + QByteArray pem1(mycert); + QSslCertificate cert1(pem1); + QVERIFY(!cert1.isNull()); + QByteArray pem2(cert1.toPem()); + QSslCertificate cert2(pem2); + QVERIFY(!cert2.isNull()); + QCOMPARE(pem1, pem2); +} + #endif // QT_NO_OPENSSL QTEST_MAIN(tst_QSslCertificate) |