summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarkus Goetz <Markus.Goetz@nokia.com>2009-06-16 11:09:25 (GMT)
committerMarkus Goetz <Markus.Goetz@nokia.com>2009-06-16 13:04:39 (GMT)
commit237a3e690f290fd8ef8ef2a51459caa7fdc7bef1 (patch)
treeb656671bc7e7444b4f8fabb2b793f65960487c90 /src
parenta8681ccaf3d77b62bbc61541911d50aabc37408e (diff)
downloadQt-237a3e690f290fd8ef8ef2a51459caa7fdc7bef1.zip
Qt-237a3e690f290fd8ef8ef2a51459caa7fdc7bef1.tar.gz
Qt-237a3e690f290fd8ef8ef2a51459caa7fdc7bef1.tar.bz2
QSslCertificate: lazy loading of some data
Reviewed-by: Andreas Aardal Hanssen
Diffstat (limited to 'src')
-rw-r--r--src/network/ssl/qsslcertificate.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/network/ssl/qsslcertificate.cpp b/src/network/ssl/qsslcertificate.cpp
index 1403b26..ef48cf2 100644
--- a/src/network/ssl/qsslcertificate.cpp
+++ b/src/network/ssl/qsslcertificate.cpp
@@ -125,6 +125,9 @@
QT_BEGIN_NAMESPACE
+// forward declaration
+static QMap<QString, QString> _q_mapFromOnelineName(char *name);
+
/*!
Constructs a QSslCertificate by reading \a format encoded data
from \a device and using the first certificate found. You can
@@ -300,6 +303,10 @@ static QString _q_SubjectInfoToString(QSslCertificate::SubjectInfo info)
*/
QString QSslCertificate::issuerInfo(SubjectInfo info) const
{
+ if (d->issuerInfo.isEmpty() && d->x509)
+ d->issuerInfo =
+ _q_mapFromOnelineName(q_X509_NAME_oneline(q_X509_get_issuer_name(d->x509), 0, 0));
+
return d->issuerInfo.value(_q_SubjectInfoToString(info));
}
@@ -327,6 +334,10 @@ QString QSslCertificate::issuerInfo(const QByteArray &tag) const
*/
QString QSslCertificate::subjectInfo(SubjectInfo info) const
{
+ if (d->subjectInfo.isEmpty() && d->x509)
+ d->subjectInfo =
+ _q_mapFromOnelineName(q_X509_NAME_oneline(q_X509_get_subject_name(d->x509), 0, 0));
+
return d->subjectInfo.value(_q_SubjectInfoToString(info));
}
@@ -662,11 +673,6 @@ QSslCertificate QSslCertificatePrivate::QSslCertificate_from_X509(X509 *x509)
if (!x509 || !QSslSocket::supportsSsl())
return certificate;
- certificate.d->issuerInfo =
- _q_mapFromOnelineName(q_X509_NAME_oneline(q_X509_get_issuer_name(x509), 0, 0));
- certificate.d->subjectInfo =
- _q_mapFromOnelineName(q_X509_NAME_oneline(q_X509_get_subject_name(x509), 0, 0));
-
ASN1_TIME *nbef = q_X509_get_notBefore(x509);
ASN1_TIME *naft = q_X509_get_notAfter(x509);
certificate.d->notValidBefore = q_getTimeFromASN1(nbef);