summaryrefslogtreecommitdiffstats
path: root/src/network/ssl/qsslcertificate.cpp
diff options
context:
space:
mode:
authorJason Barron <jbarron@trolltech.com>2009-06-30 09:21:56 (GMT)
committerJason Barron <jbarron@trolltech.com>2009-06-30 09:21:56 (GMT)
commit197df24edfe095a10e2bf65116796e027fea44e2 (patch)
tree4ffb08f614b550298663f90297c9e559ecb47a3c /src/network/ssl/qsslcertificate.cpp
parent1e84894225e31adf80a7a33da7f655fb5c38ea0e (diff)
parente3c1039d4d10aa383a1f681e7dd9c1129d22d8ca (diff)
downloadQt-197df24edfe095a10e2bf65116796e027fea44e2.zip
Qt-197df24edfe095a10e2bf65116796e027fea44e2.tar.gz
Qt-197df24edfe095a10e2bf65116796e027fea44e2.tar.bz2
Merge commit 'qt/master-stable' into 4.6-merged
Conflicts: .gitignore configure.exe src/corelib/concurrent/qtconcurrentthreadengine.h src/corelib/global/qnamespace.h src/gui/graphicsview/qgraphicssceneevent.h src/gui/kernel/qapplication.cpp src/gui/kernel/qapplication.h src/gui/kernel/qapplication_p.h src/gui/kernel/qapplication_qws.cpp src/gui/kernel/qwidget.h src/gui/painting/qpaintengine_raster.cpp src/gui/text/qfontdatabase.cpp src/network/access/qnetworkaccesshttpbackend.cpp tests/auto/network-settings.h tests/auto/qscriptjstestsuite/qscriptjstestsuite.pro tests/auto/qvariant/tst_qvariant.cpp
Diffstat (limited to 'src/network/ssl/qsslcertificate.cpp')
-rw-r--r--src/network/ssl/qsslcertificate.cpp29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/network/ssl/qsslcertificate.cpp b/src/network/ssl/qsslcertificate.cpp
index d9f710e..018b2c2 100644
--- a/src/network/ssl/qsslcertificate.cpp
+++ b/src/network/ssl/qsslcertificate.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
+** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -34,7 +34,7 @@
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
+** contact the sales department at http://www.qtsoftware.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -71,9 +71,10 @@
After loading a certificate, you can find information about the
certificate, its subject, and its issuer, by calling one of the
many accessor functions, including version(), serialNumber(),
- issuerInfo() and subjectInfo(). You can call notValidBefore() and
- notValidAfter() to check when the certificate was issued, and when
- it expires. The publicKey() function returns the certificate
+ issuerInfo() and subjectInfo(). You can call effectiveDate() and
+ expiryDate() to check when the certificate starts being
+ effective and when it expires.
+ The publicKey() function returns the certificate
subject's public key as a QSslKey. You can call issuerInfo() or
subjectInfo() to get detailed information about the certificate
issuer and its subject.
@@ -125,6 +126,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
@@ -293,6 +297,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));
}
@@ -320,6 +328,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));
}
@@ -603,7 +615,7 @@ QByteArray QSslCertificatePrivate::QByteArray_from_X509(X509 *x509, QSsl::Encodi
// Convert to Base64 - wrap at 64 characters.
array = array.toBase64();
QByteArray tmp;
- for (int i = 0; i < array.size() - 64; i += 64) {
+ for (int i = 0; i <= array.size() - 64; i += 64) {
tmp += QByteArray::fromRawData(array.data() + i, 64);
tmp += "\n";
}
@@ -655,11 +667,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);