From 4a07519877b4b3aad45d1a727487d9e87630973b Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Mon, 11 Feb 2013 17:14:25 +0000 Subject: Store the local certificate in a QList. Instead of storing a single QSslCertificate for a the local cert, store a list of them. This will allow us to handle server sockets that use a certificate that is not issued directly from the CA root in future. Change-Id: I9a36b9a99daa9c0bdd17f61b4ce1a7da746f2e96 Reviewed-by: Peter Hartmann --- src/network/ssl/qsslconfiguration.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'src/network/ssl/qsslconfiguration.cpp') diff --git a/src/network/ssl/qsslconfiguration.cpp b/src/network/ssl/qsslconfiguration.cpp index 145cd7be5d..3d466b85ca 100644 --- a/src/network/ssl/qsslconfiguration.cpp +++ b/src/network/ssl/qsslconfiguration.cpp @@ -173,7 +173,7 @@ bool QSslConfiguration::operator==(const QSslConfiguration &other) const return true; return d->peerCertificate == other.d->peerCertificate && d->peerCertificateChain == other.d->peerCertificateChain && - d->localCertificate == other.d->localCertificate && + d->localCertificateChain == other.d->localCertificateChain && d->privateKey == other.d->privateKey && d->sessionCipher == other.d->sessionCipher && d->ciphers == other.d->ciphers && @@ -212,7 +212,7 @@ bool QSslConfiguration::isNull() const d->allowRootCertOnDemandLoading == true && d->caCertificates.count() == 0 && d->ciphers.count() == 0 && - d->localCertificate.isNull() && + d->localCertificateChain.isEmpty() && d->privateKey.isNull() && d->peerCertificate.isNull() && d->peerCertificateChain.count() == 0 && @@ -312,6 +312,18 @@ void QSslConfiguration::setPeerVerifyDepth(int depth) d->peerVerifyDepth = depth; } +/*! + Returns the certificate chain to be presented to the peer during + the SSL handshake process. + + \sa localCertificate() + \since 5.1 +*/ +QList QSslConfiguration::localCertificateChain() const +{ + return d->localCertificateChain; +} + /*! Returns the certificate to be presented to the peer during the SSL handshake process. @@ -320,7 +332,9 @@ void QSslConfiguration::setPeerVerifyDepth(int depth) */ QSslCertificate QSslConfiguration::localCertificate() const { - return d->localCertificate; + if (d->localCertificateChain.isEmpty()) + return QSslCertificate(); + return d->localCertificateChain[0]; } /*! @@ -341,7 +355,8 @@ QSslCertificate QSslConfiguration::localCertificate() const */ void QSslConfiguration::setLocalCertificate(const QSslCertificate &certificate) { - d->localCertificate = certificate; + d->localCertificateChain = QList(); + d->localCertificateChain += certificate; } /*! -- cgit v1.2.3