From 852d4b03f612748fb16f592dda884e9634b468cf Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Mon, 11 Jul 2011 16:15:14 +0200 Subject: SSL: Add methods to access the tags of the subject and issuer of a cert Add methods that return a list of the tags in use in a certificate issuer or subject. This means that unknown elements of these fields can be accessed. Change-Id: I588989e34f541b1d31cc9e97f5a85d1624ece1b1 Merge-request: 18 Reviewed-by: Peter Hartmann Reviewed-on: http://codereview.qt.nokia.com/1451 --- tests/auto/qsslcertificate/tst_qsslcertificate.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tests/auto/qsslcertificate/tst_qsslcertificate.cpp') diff --git a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp index e95af1e97c..c04f315060 100644 --- a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp +++ b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp @@ -115,6 +115,7 @@ private slots: void blacklistedCertificates(); void toText(); void multipleCommonNames(); + void subjectAndIssuerTags(); // ### add tests for certificate bundles (multiple certificates concatenated into a single // structure); both PEM and DER formatted @@ -883,6 +884,23 @@ void tst_QSslCertificate::multipleCommonNames() QVERIFY(commonNames.contains(QString("www2.example.com"))); } +void tst_QSslCertificate::subjectAndIssuerTags() +{ + QList certList = + QSslCertificate::fromPath(SRCDIR "more-certificates/test-cn-with-drink-cert.pem"); + QVERIFY2(certList.count() > 0, "Please run this test from the source directory"); + + QList tags = certList[0].subjectInfoTags(); + QVERIFY(tags.contains(QByteArray("favouriteDrink"))); + tags.clear(); + + certList = QSslCertificate::fromPath(SRCDIR "more-certificates/natwest-banking.pem"); + QVERIFY2(certList.count() > 0, "Please run this test from the source directory"); + + tags = certList[0].subjectInfoTags(); + QVERIFY(tags.contains(QByteArray("1.3.6.1.4.1.311.60.2.1.3"))); +} + #endif // QT_NO_OPENSSL QTEST_MAIN(tst_QSslCertificate) -- cgit v1.2.3