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 --- src/network/ssl/qsslcertificate.cpp | 38 +++++++++++++++++++++++++++++++++++++ src/network/ssl/qsslcertificate.h | 2 ++ 2 files changed, 40 insertions(+) (limited to 'src') diff --git a/src/network/ssl/qsslcertificate.cpp b/src/network/ssl/qsslcertificate.cpp index 2e5b313d4e..9cc74c633c 100644 --- a/src/network/ssl/qsslcertificate.cpp +++ b/src/network/ssl/qsslcertificate.cpp @@ -385,6 +385,44 @@ QStringList QSslCertificate::subjectInfo(const QByteArray &tag) const return d->subjectInfo.values(tag); } +/*! + Returns a list of the tags that have values in the subject + information of this certificate. The information associated + with a given tag can be accessed using the subjectInfo() + method. Note that this list may include the OIDs for any + elements that are not known by the SSL backend. + + \sa subjectInfo() +*/ +QList QSslCertificate::subjectInfoTags() const +{ + // lazy init + if (d->subjectInfo.isEmpty() && d->x509) + d->subjectInfo = + _q_mapFromX509Name(q_X509_get_subject_name(d->x509)); + + return d->subjectInfo.uniqueKeys(); +} + +/*! + Returns a list of the tags that have values in the issuer + information of this certificate. The information associated + with a given tag can be accessed using the issuerInfo() + method. Note that this list may include the OIDs for any + elements that are not known by the SSL backend. + + \sa subjectInfo() +*/ +QList QSslCertificate::issuerInfoTags() const +{ + // lazy init + if (d->issuerInfo.isEmpty() && d->x509) + d->issuerInfo = + _q_mapFromX509Name(q_X509_get_issuer_name(d->x509)); + + return d->issuerInfo.uniqueKeys(); +} + /*! Returns the list of alternative subject names for this certificate. The alternate subject names typically contain host diff --git a/src/network/ssl/qsslcertificate.h b/src/network/ssl/qsslcertificate.h index 8abaa3f73e..b038a6ab88 100644 --- a/src/network/ssl/qsslcertificate.h +++ b/src/network/ssl/qsslcertificate.h @@ -103,6 +103,8 @@ public: QStringList issuerInfo(const QByteArray &tag) const; QStringList subjectInfo(SubjectInfo info) const; QStringList subjectInfo(const QByteArray &tag) const; + QList subjectInfoTags() const; + QList issuerInfoTags() const; QMultiMap alternateSubjectNames() const; QDateTime effectiveDate() const; QDateTime expiryDate() const; -- cgit v1.2.3