Changeset 561 for trunk/src/network/ssl
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/network/ssl/qssl.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtNetwork module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 50 50 \since 4.3 51 51 52 \ingroup io 52 \ingroup network 53 \ingroup ssl 53 54 \inmodule QtNetwork 54 55 */ -
trunk/src/network/ssl/qssl.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtNetwork module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** -
trunk/src/network/ssl/qsslcertificate.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtNetwork module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 47 47 48 48 \reentrant 49 \ingroup io49 \ingroup network 50 50 \ingroup ssl 51 51 \inmodule QtNetwork … … 72 72 certificate, its subject, and its issuer, by calling one of the 73 73 many accessor functions, including version(), serialNumber(), 74 issuerInfo() and subjectInfo(). You can call notValidBefore() and 75 notValidAfter() to check when the certificate was issued, and when 76 it expires. The publicKey() function returns the certificate 74 issuerInfo() and subjectInfo(). You can call effectiveDate() and 75 expiryDate() to check when the certificate starts being 76 effective and when it expires. 77 The publicKey() function returns the certificate 77 78 subject's public key as a QSslKey. You can call issuerInfo() or 78 79 subjectInfo() to get detailed information about the certificate … … 126 127 QT_BEGIN_NAMESPACE 127 128 129 // forward declaration 130 static QMap<QString, QString> _q_mapFromOnelineName(char *name); 131 128 132 /*! 129 133 Constructs a QSslCertificate by reading \a format encoded data … … 158 162 QSslCertificate::QSslCertificate(const QSslCertificate &other) : d(other.d) 159 163 { 160 d->ref.ref();161 164 } 162 165 … … 166 169 QSslCertificate::~QSslCertificate() 167 170 { 168 if (!d->ref.deref())169 delete d;170 171 } 171 172 … … 176 177 QSslCertificate &QSslCertificate::operator=(const QSslCertificate &other) 177 178 { 178 qAtomicAssign(d, other.d);179 d = other.d; 179 180 return *this; 180 181 } … … 242 243 if (isNull()) 243 244 return; 244 if (d->ref == 1)245 delete d;246 else247 d->ref.deref();248 249 245 d = new QSslCertificatePrivate; 250 246 } … … 255 251 QByteArray QSslCertificate::version() const 256 252 { 253 if (d->versionString.isEmpty() && d->x509) 254 d->versionString = 255 QByteArray::number(qlonglong(q_ASN1_INTEGER_get(d->x509->cert_info->version)) + 1); 256 257 257 return d->versionString; 258 258 } 259 259 260 260 /*! 261 Returns the certificate's serial number string .261 Returns the certificate's serial number string in decimal format. 262 262 */ 263 263 QByteArray QSslCertificate::serialNumber() const 264 264 { 265 if (d->serialNumberString.isEmpty() && d->x509) 266 d->serialNumberString = 267 QByteArray::number(qlonglong(q_ASN1_INTEGER_get(d->x509->cert_info->serialNumber))); 268 265 269 return d->serialNumberString; 266 270 } … … 268 272 /*! 269 273 Returns a cryptographic digest of this certificate. By default, 270 an dMD5 digest will be generated, but you can also specify a274 an MD5 digest will be generated, but you can also specify a 271 275 custom \a algorithm. 272 276 */ … … 301 305 QString QSslCertificate::issuerInfo(SubjectInfo info) const 302 306 { 307 if (d->issuerInfo.isEmpty() && d->x509) 308 d->issuerInfo = 309 _q_mapFromOnelineName(q_X509_NAME_oneline(q_X509_get_issuer_name(d->x509), 0, 0)); 310 303 311 return d->issuerInfo.value(_q_SubjectInfoToString(info)); 304 312 } … … 328 336 QString QSslCertificate::subjectInfo(SubjectInfo info) const 329 337 { 338 if (d->subjectInfo.isEmpty() && d->x509) 339 d->subjectInfo = 340 _q_mapFromOnelineName(q_X509_NAME_oneline(q_X509_get_subject_name(d->x509), 0, 0)); 341 330 342 return d->subjectInfo.value(_q_SubjectInfoToString(info)); 331 343 } … … 363 375 return result; 364 376 365 STACK *altNames = (STACK*)q_X509_get_ext_d2i(d->x509, NID_subject_alt_name, 0, 0);377 STACK_OF(GENERAL_NAME) *altNames = (STACK_OF(GENERAL_NAME)*)q_X509_get_ext_d2i(d->x509, NID_subject_alt_name, 0, 0); 366 378 367 379 if (altNames) { … … 378 390 379 391 const char *altNameStr = reinterpret_cast<const char *>(q_ASN1_STRING_data(genName->d.ia5)); 380 const QString altName = Q Latin1String(QByteArray(altNameStr, len));392 const QString altName = QString::fromLatin1(altNameStr, len); 381 393 if (genName->type == GEN_DNS) 382 394 result.insert(QSsl::DnsEntry, altName); … … 384 396 result.insert(QSsl::EmailEntry, altName); 385 397 } 386 q_sk_ free(altNames);398 q_sk_pop_free((STACK*)altNames, reinterpret_cast<void(*)(void*)>(q_sk_free)); 387 399 } 388 400 … … 611 623 array = array.toBase64(); 612 624 QByteArray tmp; 613 for (int i = 0; i < array.size() - 64; i += 64) {625 for (int i = 0; i <= array.size() - 64; i += 64) { 614 626 tmp += QByteArray::fromRawData(array.data() + i, 64); 615 627 tmp += "\n"; … … 662 674 if (!x509 || !QSslSocket::supportsSsl()) 663 675 return certificate; 664 665 certificate.d->issuerInfo =666 _q_mapFromOnelineName(q_X509_NAME_oneline(q_X509_get_issuer_name(x509), 0, 0));667 certificate.d->subjectInfo =668 _q_mapFromOnelineName(q_X509_NAME_oneline(q_X509_get_subject_name(x509), 0, 0));669 676 670 677 ASN1_TIME *nbef = q_X509_get_notBefore(x509); … … 687 694 688 695 if (ch == '\n') { 689 *offset ++;696 *offset += 1; 690 697 return true; 691 698 } … … 767 774 debug << "QSslCertificate(" 768 775 << certificate.version() 769 << ","<< certificate.serialNumber()770 << ","<< certificate.digest().toBase64()771 << ","<< certificate.issuerInfo(QSslCertificate::Organization)772 << ","<< certificate.subjectInfo(QSslCertificate::Organization)773 << ","<< certificate.alternateSubjectNames()776 << ',' << certificate.serialNumber() 777 << ',' << certificate.digest().toBase64() 778 << ',' << certificate.issuerInfo(QSslCertificate::Organization) 779 << ',' << certificate.subjectInfo(QSslCertificate::Organization) 780 << ',' << certificate.alternateSubjectNames() 774 781 #ifndef QT_NO_TEXTSTREAM 775 << ","<< certificate.effectiveDate()776 << ","<< certificate.expiryDate()782 << ',' << certificate.effectiveDate() 783 << ',' << certificate.expiryDate() 777 784 #endif 778 << ")";785 << ')'; 779 786 return debug; 780 787 } -
trunk/src/network/ssl/qsslcertificate.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtNetwork module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 48 48 #include <QtCore/qcryptographichash.h> 49 49 #include <QtCore/qregexp.h> 50 #include <QtCore/qsharedpointer.h> 50 51 #include <QtNetwork/qssl.h> 51 52 … … 119 120 120 121 private: 121 Q SslCertificatePrivate *d;122 QExplicitlySharedDataPointer<QSslCertificatePrivate> d; 122 123 friend class QSslCertificatePrivate; 123 124 friend class QSslSocketBackendPrivate; -
trunk/src/network/ssl/qsslcertificate_p.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtNetwork module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 72 72 { 73 73 QSslSocketPrivate::ensureInitialized(); 74 ref = 1;75 74 } 76 75 -
trunk/src/network/ssl/qsslcipher.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtNetwork module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 47 47 48 48 \reentrant 49 \ingroup io49 \ingroup network 50 50 \ingroup ssl 51 51 \inmodule QtNetwork … … 65 65 #ifndef QT_NO_DEBUG_STREAM 66 66 #include <QtCore/qdebug.h> 67 #endif 67 68 68 69 QT_BEGIN_NAMESPACE 69 #endif70 70 71 71 /*! … … 104 104 : d(new QSslCipherPrivate) 105 105 { 106 *d = *other.d;106 *d.data() = *other.d.data(); 107 107 } 108 108 … … 112 112 QSslCipher::~QSslCipher() 113 113 { 114 delete d;115 114 } 116 115 … … 121 120 QSslCipher &QSslCipher::operator=(const QSslCipher &other) 122 121 { 123 *d = *other.d;122 *d.data() = *other.d.data(); 124 123 return *this; 125 124 } … … 232 231 << ", bits=" << cipher.usedBits() 233 232 << ", proto=" << qPrintable(cipher.protocolString()) 234 << ")";233 << ')'; 235 234 return debug; 236 235 } -
trunk/src/network/ssl/qsslcipher.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtNetwork module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 45 45 46 46 #include <QtCore/qstring.h> 47 #include <QtCore/qscopedpointer.h> 47 48 #include <QtNetwork/qssl.h> 48 49 … … 79 80 80 81 private: 81 QS slCipherPrivate *d;82 QScopedPointer<QSslCipherPrivate> d; 82 83 friend class QSslSocketBackendPrivate; 83 84 }; -
trunk/src/network/ssl/qsslcipher_p.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtNetwork module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** -
trunk/src/network/ssl/qsslconfiguration.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtNetwork module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 67 67 \reentrant 68 68 \inmodule QtNetwork 69 \ingroup io69 \ingroup network 70 70 \ingroup ssl 71 71 -
trunk/src/network/ssl/qsslconfiguration.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtNetwork module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 42 42 /**************************************************************************** 43 43 ** 44 ** In addition, as a special exception, Trolltechgives permission to link44 ** In addition, as a special exception, Nokia gives permission to link 45 45 ** the code of its release of Qt with the OpenSSL project's "OpenSSL" library 46 46 ** (or modified versions of the "OpenSSL" library that use the same license -
trunk/src/network/ssl/qsslconfiguration_p.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtNetwork module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 42 42 /**************************************************************************** 43 43 ** 44 ** In addition, as a special exception, Trolltechgives permission to link44 ** In addition, as a special exception, Nokia gives permission to link 45 45 ** the code of its release of Qt with the OpenSSL project's "OpenSSL" library 46 46 ** (or modified versions of the "OpenSSL" library that use the same license -
trunk/src/network/ssl/qsslerror.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtNetwork module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 47 47 48 48 \reentrant 49 \ingroup io49 \ingroup network 50 50 \ingroup ssl 51 51 \inmodule QtNetwork … … 92 92 93 93 #include "qsslerror.h" 94 #include "qsslsocket.h" 94 95 #ifndef QT_NO_DEBUG_STREAM 95 96 #include <QtCore/qdebug.h> … … 106 107 107 108 /*! 108 Constructs a QSslError object. The two optional arguments specify the \a 109 Constructs a QSslError object with no error and default certificate. 110 111 */ 112 113 // RVCT compiler in debug build does not like about default values in const- 114 // So as an workaround we define all constructor overloads here explicitly 115 QSslError::QSslError() 116 : d(new QSslErrorPrivate) 117 { 118 d->error = QSslError::NoError; 119 d->certificate = QSslCertificate(); 120 } 121 122 /*! 123 Constructs a QSslError object. The argument specifies the \a 124 error that occurred. 125 126 */ 127 QSslError::QSslError(SslError error) 128 : d(new QSslErrorPrivate) 129 { 130 d->error = error; 131 d->certificate = QSslCertificate(); 132 } 133 134 /*! 135 Constructs a QSslError object. The two arguments specify the \a 109 136 error that occurred, and which \a certificate the error relates to. 110 137 … … 124 151 : d(new QSslErrorPrivate) 125 152 { 126 *d = *other.d;153 *d.data() = *other.d.data(); 127 154 } 128 155 … … 132 159 QSslError::~QSslError() 133 160 { 134 delete d;135 161 } 136 162 … … 142 168 QSslError &QSslError::operator=(const QSslError &other) 143 169 { 144 *d = *other.d;170 *d.data() = *other.d.data(); 145 171 return *this; 146 172 } … … 185 211 switch (d->error) { 186 212 case NoError: 187 errStr = Q Object::tr(QT_TRANSLATE_NOOP(QSslError, "No error"));213 errStr = QSslSocket::tr("No error"); 188 214 break; 189 215 case UnableToGetIssuerCertificate: 190 errStr = Q Object::tr(QT_TRANSLATE_NOOP(QSslError, "The issuer certificate could not be found"));216 errStr = QSslSocket::tr("The issuer certificate could not be found"); 191 217 break; 192 218 case UnableToDecryptCertificateSignature: 193 errStr = Q Object::tr(QT_TRANSLATE_NOOP(QSslError, "The certificate signature could not be decrypted"));219 errStr = QSslSocket::tr("The certificate signature could not be decrypted"); 194 220 break; 195 221 case UnableToDecodeIssuerPublicKey: 196 errStr = Q Object::tr(QT_TRANSLATE_NOOP(QSslError, "The public key in the certificate could not be read"));222 errStr = QSslSocket::tr("The public key in the certificate could not be read"); 197 223 break; 198 224 case CertificateSignatureFailed: 199 errStr = Q Object::tr(QT_TRANSLATE_NOOP(QSslError, "The signature of the certificate is invalid"));225 errStr = QSslSocket::tr("The signature of the certificate is invalid"); 200 226 break; 201 227 case CertificateNotYetValid: 202 errStr = Q Object::tr(QT_TRANSLATE_NOOP(QSslError, "The certificate is not yet valid"));228 errStr = QSslSocket::tr("The certificate is not yet valid"); 203 229 break; 204 230 case CertificateExpired: 205 errStr = Q Object::tr(QT_TRANSLATE_NOOP(QSslError, "The certificate has expired"));231 errStr = QSslSocket::tr("The certificate has expired"); 206 232 break; 207 233 case InvalidNotBeforeField: 208 errStr = Q Object::tr(QT_TRANSLATE_NOOP(QSslError, "The certificate's notBefore field contains an invalid time"));234 errStr = QSslSocket::tr("The certificate's notBefore field contains an invalid time"); 209 235 break; 210 236 case InvalidNotAfterField: 211 errStr = Q Object::tr(QT_TRANSLATE_NOOP(QSslError, "The certificate's notAfter field contains an invalid time"));237 errStr = QSslSocket::tr("The certificate's notAfter field contains an invalid time"); 212 238 break; 213 239 case SelfSignedCertificate: 214 errStr = Q Object::tr(QT_TRANSLATE_NOOP(QSslError, "The certificate is self-signed, and untrusted"));240 errStr = QSslSocket::tr("The certificate is self-signed, and untrusted"); 215 241 break; 216 242 case SelfSignedCertificateInChain: 217 errStr = Q Object::tr(QT_TRANSLATE_NOOP(QSslError, "The root certificate of the certificate chain is self-signed, and untrusted"));243 errStr = QSslSocket::tr("The root certificate of the certificate chain is self-signed, and untrusted"); 218 244 break; 219 245 case UnableToGetLocalIssuerCertificate: 220 errStr = Q Object::tr(QT_TRANSLATE_NOOP(QSslError, "The issuer certificate of a locally looked up certificate could not be found"));246 errStr = QSslSocket::tr("The issuer certificate of a locally looked up certificate could not be found"); 221 247 break; 222 248 case UnableToVerifyFirstCertificate: 223 errStr = Q Object::tr(QT_TRANSLATE_NOOP(QSslError, "No certificates could be verified"));249 errStr = QSslSocket::tr("No certificates could be verified"); 224 250 break; 225 251 case InvalidCaCertificate: 226 errStr = Q Object::tr(QT_TRANSLATE_NOOP(QSslError, "One of the CA certificates is invalid"));252 errStr = QSslSocket::tr("One of the CA certificates is invalid"); 227 253 break; 228 254 case PathLengthExceeded: 229 errStr = Q Object::tr(QT_TRANSLATE_NOOP(QSslError, "The basicConstraints pathlength parameter has been exceeded"));255 errStr = QSslSocket::tr("The basicConstraints path length parameter has been exceeded"); 230 256 break; 231 257 case InvalidPurpose: 232 errStr = Q Object::tr(QT_TRANSLATE_NOOP(QSslError, "The supplied certificate is unsuited for this purpose"));258 errStr = QSslSocket::tr("The supplied certificate is unsuitable for this purpose"); 233 259 break; 234 260 case CertificateUntrusted: 235 errStr = Q Object::tr(QT_TRANSLATE_NOOP(QSslError, "The root CA certificate is not trusted for this purpose"));261 errStr = QSslSocket::tr("The root CA certificate is not trusted for this purpose"); 236 262 break; 237 263 case CertificateRejected: 238 errStr = Q Object::tr(QT_TRANSLATE_NOOP(QSslError, "The root CA certificate is marked to reject the specified purpose"));264 errStr = QSslSocket::tr("The root CA certificate is marked to reject the specified purpose"); 239 265 break; 240 266 case SubjectIssuerMismatch: // hostname mismatch 241 errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, 242 "The current candidate issuer certificate was rejected because its" 243 " subject name did not match the issuer name of the current certificate")); 267 errStr = QSslSocket::tr("The current candidate issuer certificate was rejected because its" 268 " subject name did not match the issuer name of the current certificate"); 244 269 break; 245 270 case AuthorityIssuerSerialNumberMismatch: 246 errStr = Q Object::tr(QT_TRANSLATE_NOOP(QSslError,"The current candidate issuer certificate was rejected because"247 248 " authority key identifier of the current certificate"));271 errStr = QSslSocket::tr("The current candidate issuer certificate was rejected because" 272 " its issuer name and serial number was present and did not match the" 273 " authority key identifier of the current certificate"); 249 274 break; 250 275 case NoPeerCertificate: 251 errStr = Q Object::tr(QT_TRANSLATE_NOOP(QSslError, "The peer did not present any certificate"));276 errStr = QSslSocket::tr("The peer did not present any certificate"); 252 277 break; 253 278 case HostNameMismatch: 254 errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, 255 "The host name did not match any of the valid hosts" 256 " for this certificate")); 279 errStr = QSslSocket::tr("The host name did not match any of the valid hosts" 280 " for this certificate"); 257 281 break; 258 282 case NoSslSupport: 259 283 break; 260 284 default: 261 errStr = Q Object::tr(QT_TRANSLATE_NOOP(QSslError, "Unknown error"));285 errStr = QSslSocket::tr("Unknown error"); 262 286 break; 263 287 } -
trunk/src/network/ssl/qsslerror.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtNetwork module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 87 87 }; 88 88 89 QSslError(SslError error = NoError, const QSslCertificate &certificate = QSslCertificate()); 89 // RVCT compiler in debug build does not like about default values in const- 90 // So as an workaround we define all constructor overloads here explicitly 91 QSslError(); 92 QSslError(SslError error); 93 QSslError(SslError error, const QSslCertificate &certificate); 94 90 95 QSslError(const QSslError &other); 96 91 97 ~QSslError(); 92 98 QSslError &operator=(const QSslError &other); … … 100 106 101 107 private: 102 QS slErrorPrivate *d;108 QScopedPointer<QSslErrorPrivate> d; 103 109 }; 104 110 -
trunk/src/network/ssl/qsslkey.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtNetwork module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 47 47 48 48 \reentrant 49 \ingroup io49 \ingroup network 50 50 \ingroup ssl 51 51 \inmodule QtNetwork … … 272 272 QSslKey::QSslKey(const QSslKey &other) : d(other.d) 273 273 { 274 d->ref.ref();275 274 } 276 275 … … 280 279 QSslKey::~QSslKey() 281 280 { 282 if (!d->ref.deref())283 delete d;284 281 } 285 282 … … 292 289 QSslKey &QSslKey::operator=(const QSslKey &other) 293 290 { 294 qAtomicAssign(d, other.d);291 d = other.d; 295 292 return *this; 296 293 } … … 313 310 void QSslKey::clear() 314 311 { 315 if (!d->ref.deref()) { 316 delete d; 317 d = new QSslKeyPrivate; 318 } 312 d = new QSslKeyPrivate; 319 313 } 320 314 … … 461 455 << ", " << (key.algorithm() == QSsl::Rsa ? "RSA" : "DSA") 462 456 << ", " << key.length() 463 << ")";457 << ')'; 464 458 return debug; 465 459 } -
trunk/src/network/ssl/qsslkey.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtNetwork module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 46 46 #include <QtCore/qnamespace.h> 47 47 #include <QtCore/qbytearray.h> 48 #include <QtCore/qsharedpointer.h> 48 49 #include <QtNetwork/qssl.h> 49 50 … … 59 60 60 61 class QIODevice; 61 62 62 63 class QSslKeyPrivate; 63 64 class Q_NETWORK_EXPORT QSslKey … … 93 94 94 95 private: 95 Q SslKeyPrivate *d;96 QExplicitlySharedDataPointer<QSslKeyPrivate> d; 96 97 friend class QSslCertificate; 97 98 }; -
trunk/src/network/ssl/qsslkey_p.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtNetwork module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 70 70 { 71 71 clear(); 72 ref = 1;73 72 } 74 73 … … 92 91 93 92 QAtomicInt ref; 93 94 private: 95 Q_DISABLE_COPY(QSslKeyPrivate) 94 96 }; 95 97 -
trunk/src/network/ssl/qsslsocket.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtNetwork module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 50 50 51 51 \reentrant 52 \ingroup io52 \ingroup network 53 53 \ingroup ssl 54 54 \inmodule QtNetwork … … 114 114 internal buffer, and you can call write() or putChar() to write 115 115 data back to the peer. QSslSocket will automatically encrypt the 116 written data for you, and emit bytesWritten() once the data has117 been written to the peer.116 written data for you, and emit encryptedBytesWritten() once 117 the data has been written to the peer. 118 118 119 119 As a convenience, QSslSocket supports QTcpSocket's blocking … … 150 150 for use in the OpenSSL Toolkit (\l{http://www.openssl.org/}). 151 151 152 \note Be aware of the difference between the bytesWritten() signal and 153 the encryptedBytesWritten() signal. For a QTcpSocket, bytesWritten() 154 will get emitted as soon as data has been written to the TCP socket. 155 For a QSslSocket, bytesWritten() will get emitted when the data 156 is being encrypted and encryptedBytesWritten() 157 will get emitted as soon as data has been written to the TCP socket. 158 152 159 \sa QSslCertificate, QSslCipher, QSslError 153 160 */ … … 357 364 ignoreSslErrors(), either from inside a slot function connected to 358 365 the sslErrors() signal, or prior to entering encrypted mode. If 359 ignoreSslErrors is not called, the connection is dropped, signal366 ignoreSslErrors() is not called, the connection is dropped, signal 360 367 disconnected() is emitted, and QSslSocket returns to the 361 368 UnconnectedState. … … 398 405 399 406 /*! 407 \since 4.6 408 \overload 409 410 In addition to the original behaviour of connectToHostEncrypted, 411 this overloaded method enables the usage of a different hostname 412 (\a sslPeerName) for the certificate validation instead of 413 the one used for the TCP connection (\a hostName). 414 415 \sa connectToHostEncrypted() 416 */ 417 void QSslSocket::connectToHostEncrypted(const QString &hostName, quint16 port, 418 const QString &sslPeerName, OpenMode mode) 419 { 420 Q_D(QSslSocket); 421 if (d->state == ConnectedState || d->state == ConnectingState) { 422 qWarning("QSslSocket::connectToHostEncrypted() called when already connecting/connected"); 423 return; 424 } 425 426 d->init(); 427 d->autoStartHandshake = true; 428 d->initialized = true; 429 d->verificationPeerName = sslPeerName; 430 431 // Note: When connecting to localhost, some platforms (e.g., HP-UX and some BSDs) 432 // establish the connection immediately (i.e., first attempt). 433 connectToHost(hostName, port, mode); 434 } 435 436 /*! 400 437 Initializes QSslSocket with the native socket descriptor \a 401 438 socketDescriptor. Returns true if \a socketDescriptor is accepted … … 413 450 Q_D(QSslSocket); 414 451 #ifdef QSSLSOCKET_DEBUG 415 qDebug() << "QSslSocket::setSocketDescriptor(" << socketDescriptor << ","416 << state << "," << openMode << ")";452 qDebug() << "QSslSocket::setSocketDescriptor(" << socketDescriptor << ',' 453 << state << ',' << openMode << ')'; 417 454 #endif 418 455 if (!d->plainSocket) … … 432 469 433 470 /*! 471 \since 4.6 472 Sets the given \a option to the value described by \a value. 473 474 \sa socketOption() 475 */ 476 void QSslSocket::setSocketOption(QAbstractSocket::SocketOption option, const QVariant &value) 477 { 478 Q_D(QSslSocket); 479 if (d->plainSocket) 480 d->plainSocket->setSocketOption(option, value); 481 } 482 483 /*! 484 \since 4.6 485 Returns the value of the \a option option. 486 487 \sa setSocketOption() 488 */ 489 QVariant QSslSocket::socketOption(QAbstractSocket::SocketOption option) 490 { 491 Q_D(QSslSocket); 492 if (d->plainSocket) 493 return d->plainSocket->socketOption(option); 494 else 495 return QVariant(); 496 } 497 498 /*! 434 499 Returns the current mode for the socket; either UnencryptedMode, where 435 500 QSslSocket behaves identially to QTcpSocket, or one of SslClientMode or … … 451 516 452 517 An encrypted socket encrypts all data that is written by calling write() 453 or putChar() before the data is written to the network, and de scrypts all518 or putChar() before the data is written to the network, and decrypts all 454 519 incoming data as the data is received from the network, before you call 455 520 read(), readLine() or getChar(). … … 654 719 qDebug() << "QSslSocket::close()"; 655 720 #endif 721 Q_D(QSslSocket); 722 if (d->plainSocket) 723 d->plainSocket->close(); 656 724 QTcpSocket::close(); 725 726 // must be cleared, reading/writing not possible on closed socket: 727 d->readBuffer.clear(); 728 d->writeBuffer.clear(); 729 // for QTcpSocket this is already done because it uses the readBuffer/writeBuffer 730 // if the QIODevice it is based on 731 // ### FIXME QSslSocket should probably do similar instead of having 732 // its own readBuffer/writeBuffer 657 733 } 658 734 … … 1259 1335 1260 1336 /*! 1261 Returns the system default CA certificate database for your 1262 system. This database is normally found in a standard place for 1263 your system. If it is not found there, Qt will provide its own 1264 default CA certificate database. The CA certificate database 1337 This function provides a default CA certificate database 1338 shipped together with Qt. The CA certificate database 1265 1339 returned by this function is used to initialize the database 1266 1340 returned by defaultCaCertificates(). You can replace that database … … 1528 1602 Q_D(QSslSocket); 1529 1603 if (d->mode != UnencryptedMode) { 1530 qWarning("QSslSocket::start ClientEncryption: cannot start handshake on non-plain connection");1604 qWarning("QSslSocket::startServerEncryption: cannot start handshake on non-plain connection"); 1531 1605 return; 1532 1606 } … … 1563 1637 { 1564 1638 Q_D(QSslSocket); 1565 d->ignoreSslErrors = true; 1639 d->ignoreAllSslErrors = true; 1640 } 1641 1642 /*! 1643 \overload 1644 \since 4.6 1645 1646 This method tells QSslSocket to ignore only the errors given in \a 1647 errors. 1648 1649 Note that you can set the expected certificate in the SSL error: 1650 If, for instance, you want to connect to a server that uses 1651 a self-signed certificate, consider the following snippet: 1652 1653 \snippet doc/src/snippets/code/src_network_ssl_qsslsocket.cpp 6 1654 1655 Multiple calls to this function will replace the list of errors that 1656 were passed in previous calls. 1657 You can clear the list of errors you want to ignore by calling this 1658 function with an empty list. 1659 1660 \sa sslErrors() 1661 */ 1662 void QSslSocket::ignoreSslErrors(const QList<QSslError> &errors) 1663 { 1664 Q_D(QSslSocket); 1665 d->ignoreErrorsList = errors; 1566 1666 } 1567 1667 … … 1579 1679 #ifdef QSSLSOCKET_DEBUG 1580 1680 qDebug() << "QSslSocket::connectToHostImplementation(" 1581 << hostName << "," << port << "," << openMode << ")";1681 << hostName << ',' << port << ',' << openMode << ')'; 1582 1682 #endif 1583 1683 if (!d->plainSocket) { … … 1653 1753 } 1654 1754 #ifdef QSSLSOCKET_DEBUG 1655 qDebug() << "QSslSocket::readData(" << (void *)data << ","<< maxlen << ") ==" << readBytes;1755 qDebug() << "QSslSocket::readData(" << (void *)data << ',' << maxlen << ") ==" << readBytes; 1656 1756 #endif 1757 1758 // possibly trigger another transmit() to decrypt more data from the socket 1759 if (d->readBuffer.isEmpty() && d->plainSocket->bytesAvailable()) 1760 QMetaObject::invokeMethod(this, "_q_flushReadBuffer", Qt::QueuedConnection); 1761 1657 1762 return readBytes; 1658 1763 } … … 1665 1770 Q_D(QSslSocket); 1666 1771 #ifdef QSSLSOCKET_DEBUG 1667 qDebug() << "QSslSocket::writeData(" << (void *)data << "," << len << ")";1772 qDebug() << "QSslSocket::writeData(" << (void *)data << ',' << len << ')'; 1668 1773 #endif 1669 1774 if (d->mode == UnencryptedMode && !d->autoStartHandshake) … … 1683 1788 */ 1684 1789 QSslSocketPrivate::QSslSocketPrivate() 1685 : initialized(false), readyReadEmittedPointer(0), plainSocket(0) 1790 : initialized(false) 1791 , mode(QSslSocket::UnencryptedMode) 1792 , autoStartHandshake(false) 1793 , connectionEncrypted(false) 1794 , ignoreAllSslErrors(false) 1795 , readyReadEmittedPointer(0) 1796 , plainSocket(0) 1686 1797 { 1687 1798 QSslConfigurationPrivate::deepCopyDefaultConfiguration(&configuration); … … 1703 1814 autoStartHandshake = false; 1704 1815 connectionEncrypted = false; 1705 ignoreSslErrors = false; 1816 ignoreAllSslErrors = false; 1817 1818 // we don't want to clear the ignoreErrorsList, so 1819 // that it is possible setting it before connecting 1820 // ignoreErrorsList.clear(); 1706 1821 1707 1822 readBuffer.clear(); … … 1970 2085 Q_Q(QSslSocket); 1971 2086 #ifdef QSSLSOCKET_DEBUG 1972 qDebug() << "QSslSocket::_q_stateChangedSlot(" << state << ")";2087 qDebug() << "QSslSocket::_q_stateChangedSlot(" << state << ')'; 1973 2088 #endif 1974 2089 q->setSocketState(state); … … 1983 2098 Q_Q(QSslSocket); 1984 2099 #ifdef QSSLSOCKET_DEBUG 1985 qDebug() << "QSslSocket::_q_errorSlot(" << error << ")";2100 qDebug() << "QSslSocket::_q_errorSlot(" << error << ')'; 1986 2101 qDebug() << "\tstate =" << q->state(); 1987 2102 qDebug() << "\terrorString =" << q->errorString(); … … 2018 2133 Q_Q(QSslSocket); 2019 2134 #ifdef QSSLSOCKET_DEBUG 2020 qDebug() << "QSslSocket::_q_bytesWrittenSlot(" << written << ")";2135 qDebug() << "QSslSocket::_q_bytesWrittenSlot(" << written << ')'; 2021 2136 #endif 2022 2137 … … 2039 2154 } 2040 2155 2156 /*! 2157 \internal 2158 */ 2159 void QSslSocketPrivate::_q_flushReadBuffer() 2160 { 2161 // trigger a read from the plainSocket into SSL 2162 if (mode != QSslSocket::UnencryptedMode) 2163 transmit(); 2164 } 2165 2041 2166 QT_END_NAMESPACE 2042 2167 -
trunk/src/network/ssl/qsslsocket.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtNetwork module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 87 87 // Autostarting the SSL client handshake. 88 88 void connectToHostEncrypted(const QString &hostName, quint16 port, OpenMode mode = ReadWrite); 89 void connectToHostEncrypted(const QString &hostName, quint16 port, const QString &sslPeerName, OpenMode mode = ReadWrite); 89 90 bool setSocketDescriptor(int socketDescriptor, SocketState state = ConnectedState, 90 91 OpenMode openMode = ReadWrite); 92 93 // ### Qt 5: Make virtual 94 void setSocketOption(QAbstractSocket::SocketOption option, const QVariant &value); 95 QVariant socketOption(QAbstractSocket::SocketOption option); 91 96 92 97 SslMode mode() const; … … 169 174 170 175 static bool supportsSsl(); 176 void ignoreSslErrors(const QList<QSslError> &errors); 171 177 172 178 public Q_SLOTS: … … 202 208 Q_PRIVATE_SLOT(d_func(), void _q_bytesWrittenSlot(qint64)) 203 209 Q_PRIVATE_SLOT(d_func(), void _q_flushWriteBuffer()) 210 Q_PRIVATE_SLOT(d_func(), void _q_flushReadBuffer()) 204 211 friend class QSslSocketBackendPrivate; 205 212 }; -
trunk/src/network/ssl/qsslsocket_openssl.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtNetwork module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 277 277 first = false; 278 278 else 279 cipherString.append( ":");279 cipherString.append(':'); 280 280 cipherString.append(cipher.name().toLatin1()); 281 281 } … … 325 325 // Check if the certificate matches the private key. 326 326 if (!q_SSL_CTX_check_private_key(ctx)) { 327 q->setErrorString(QSslSocket::tr("Private key does not certif icatepublic key, %1").arg(SSL_ERRORSTR()));327 q->setErrorString(QSslSocket::tr("Private key does not certify public key, %1").arg(SSL_ERRORSTR())); 328 328 emit q->error(QAbstractSocket::UnknownSocketError); 329 329 return false; … … 483 483 QList<QSslCertificate> QSslSocketPrivate::systemCaCertificates() 484 484 { 485 #ifdef QQ_OS_UNIX 486 // Check known locations for the system's default bundle. ### On Windows, 487 // we should use CAPI to find the bundle, and not rely on default unix 488 // locations. 489 const char *standardLocations[] = {"/etc/ssl/certs/", 490 #if 0 491 // KDE uses KConfig for its SSL store, 492 // but it also stores the bundle at 493 // this location 494 "$HOME/.kde/share/apps/kssl/ca-bundle.crt", 495 #endif 496 0}; 497 const char **it = standardLocations; 498 QStringList nameFilter; 499 nameFilter << QLatin1String("*.pem") << QLatin1String("*.crt"); 500 while (*it) { 501 if (QDirIterator(QLatin1String(*it), nameFilter).hasNext()) 502 return certificatesFromPath(QLatin1String(*it)); 503 ++it; 504 } 505 #endif 506 507 // Qt provides a default bundle when we cannot detect the system's default 508 // bundle. 485 // Qt provides a default bundle of certificates 509 486 QFile caBundle(QLatin1String(":/trolltech/network/ssl/qt-ca-bundle.crt")); 510 487 if (caBundle.open(QIODevice::ReadOnly | QIODevice::Text)) … … 524 501 // Start connecting. This will place outgoing data in the BIO, so we 525 502 // follow up with calling transmit(). 526 testConnection();503 startHandshake(); 527 504 transmit(); 528 505 } … … 537 514 // Start connecting. This will place outgoing data in the BIO, so we 538 515 // follow up with calling transmit(). 539 testConnection();516 startHandshake(); 540 517 transmit(); 541 518 } … … 625 602 qDebug() << "QSslSocketBackendPrivate::transmit: testing encryption"; 626 603 #endif 627 if ( testConnection()) {604 if (startHandshake()) { 628 605 #ifdef QSSLSOCKET_DEBUG 629 606 qDebug() << "QSslSocketBackendPrivate::transmit: encryption established"; … … 644 621 645 622 // If the request is small and the remote host closes the transmission 646 // after sending, there's a chance that testConnection() will already623 // after sending, there's a chance that startHandshake() will already 647 624 // have triggered a shutdown. 648 625 if (!ssl) … … 744 721 } 745 722 746 bool QSslSocketBackendPrivate:: testConnection()723 bool QSslSocketBackendPrivate::startHandshake() 747 724 { 748 725 Q_Q(QSslSocket); … … 785 762 q->setSocketError(QAbstractSocket::SslHandshakeFailedError); 786 763 #ifdef QSSLSOCKET_DEBUG 787 qDebug() << "QSslSocketBackendPrivate:: testConnection: error!" << q->errorString();764 qDebug() << "QSslSocketBackendPrivate::startHandshake: error!" << q->errorString(); 788 765 #endif 789 766 emit q->error(QAbstractSocket::SslHandshakeFailedError); … … 816 793 // if we're the server, don't check CN 817 794 if (mode == QSslSocket::SslClientMode) { 818 QString peerName = q->peerName();795 QString peerName = (verificationPeerName.isEmpty () ? q->peerName() : verificationPeerName); 819 796 QString commonName = configuration.peerCertificate.subjectInfo(QSslCertificate::CommonName); 820 797 … … 863 840 sslErrors = errors; 864 841 emit q->sslErrors(errors); 865 if (doVerifyPeer && !ignoreSslErrors) { 842 843 bool doEmitSslError; 844 if (!ignoreErrorsList.empty()) { 845 // check whether the errors we got are all in the list of expected errors 846 // (applies only if the method QSslSocket::ignoreSslErrors(const QList<QSslError> &errors) 847 // was called) 848 doEmitSslError = false; 849 for (int a = 0; a < errors.count(); a++) { 850 if (!ignoreErrorsList.contains(errors.at(a))) { 851 doEmitSslError = true; 852 break; 853 } 854 } 855 } else { 856 // if QSslSocket::ignoreSslErrors(const QList<QSslError> &errors) was not called and 857 // we get an SSL error, emit a signal unless we ignored all errors (by calling 858 // QSslSocket::ignoreSslErrors() ) 859 doEmitSslError = !ignoreAllSslErrors; 860 } 861 // check whether we need to emit an SSL handshake error 862 if (doVerifyPeer && doEmitSslError) { 866 863 q->setErrorString(sslErrors.first().errorString()); 867 864 q->setSocketError(QAbstractSocket::SslHandshakeFailedError); … … 912 909 if (!ssl || !ctx) 913 910 return QSslCipher(); 911 #if OPENSSL_VERSION_NUMBER >= 0x10000000L 912 // FIXME This is fairly evil, but needed to keep source level compatibility 913 // with the OpenSSL 0.9.x implementation at maximum -- some other functions 914 // don't take a const SSL_CIPHER* when they should 915 SSL_CIPHER *sessionCipher = const_cast<SSL_CIPHER *>(q_SSL_get_current_cipher(ssl)); 916 #else 914 917 SSL_CIPHER *sessionCipher = q_SSL_get_current_cipher(ssl); 918 #endif 915 919 return sessionCipher ? QSslCipher_from_SSL_CIPHER(sessionCipher) : QSslCipher(); 916 920 } -
trunk/src/network/ssl/qsslsocket_openssl_p.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtNetwork module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 58 58 59 59 #ifdef Q_OS_WIN 60 #include < windows.h>60 #include <qt_windows.h> 61 61 #if defined(OCSP_RESPONSE) 62 62 #undef OCSP_RESPONSE … … 78 78 #include <openssl/x509v3.h> 79 79 #include <openssl/x509_vfy.h> 80 #include <openssl/dsa.h> 81 #include <openssl/rsa.h> 82 83 #if OPENSSL_VERSION_NUMBER >= 0x10000000L 84 typedef _STACK STACK; 85 #endif 80 86 81 87 QT_BEGIN_NAMESPACE … … 103 109 void startServerEncryption(); 104 110 void transmit(); 105 bool testConnection();111 bool startHandshake(); 106 112 void disconnectFromHost(); 107 113 void disconnected(); -
trunk/src/network/ssl/qsslsocket_openssl_symbols.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtNetwork module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 95 95 DEFINEFUNC3(void *, ASN1_dup, i2d_of_void *a, a, d2i_of_void *b, b, char *c, c, return 0, return) 96 96 #endif 97 DEFINEFUNC(long, ASN1_INTEGER_get, ASN1_INTEGER *a, a, return 0, return) 97 98 DEFINEFUNC(unsigned char *, ASN1_STRING_data, ASN1_STRING *a, a, return 0, return) 98 99 DEFINEFUNC(int, ASN1_STRING_length, ASN1_STRING *a, a, return 0, return) … … 143 144 DEFINEFUNC(int, RAND_status, void, DUMMYARG, return -1, return) 144 145 DEFINEFUNC(void, RSA_free, RSA *a, a, return, DUMMYARG) 146 DEFINEFUNC(int, sk_num, STACK *a, a, return -1, return) 147 DEFINEFUNC2(void, sk_pop_free, STACK *a, a, void (*b)(void*), b, return, DUMMYARG) 148 #if OPENSSL_VERSION_NUMBER >= 0x10000000L 149 DEFINEFUNC(void, sk_free, _STACK *a, a, return, DUMMYARG) 150 DEFINEFUNC2(void *, sk_value, STACK *a, a, int b, b, return 0, return) 151 #else 145 152 DEFINEFUNC(void, sk_free, STACK *a, a, return, DUMMYARG) 146 DEFINEFUNC(int, sk_num, STACK *a, a, return -1, return)147 153 DEFINEFUNC2(char *, sk_value, STACK *a, a, int b, b, return 0, return) 154 #endif 148 155 DEFINEFUNC(int, SSL_accept, SSL *a, a, return -1, return) 149 156 DEFINEFUNC(int, SSL_clear, SSL *a, a, return -1, return) … … 158 165 DEFINEFUNC4(long, SSL_CTX_ctrl, SSL_CTX *a, a, int b, b, long c, c, void *d, d, return -1, return) 159 166 DEFINEFUNC(void, SSL_CTX_free, SSL_CTX *a, a, return, DUMMYARG) 167 #if OPENSSL_VERSION_NUMBER >= 0x10000000L 168 DEFINEFUNC(SSL_CTX *, SSL_CTX_new, const SSL_METHOD *a, a, return 0, return) 169 #else 160 170 DEFINEFUNC(SSL_CTX *, SSL_CTX_new, SSL_METHOD *a, a, return 0, return) 171 #endif 161 172 DEFINEFUNC2(int, SSL_CTX_set_cipher_list, SSL_CTX *a, a, const char *b, b, return -1, return) 162 173 DEFINEFUNC(int, SSL_CTX_set_default_verify_paths, SSL_CTX *a, a, return -1, return) … … 175 186 DEFINEFUNC(STACK_OF(SSL_CIPHER) *, SSL_get_ciphers, SSL *a, a, return 0, return) 176 187 #endif 188 #if OPENSSL_VERSION_NUMBER >= 0x10000000L 189 DEFINEFUNC(const SSL_CIPHER *, SSL_get_current_cipher, SSL *a, a, return 0, return) 190 #else 177 191 DEFINEFUNC(SSL_CIPHER *, SSL_get_current_cipher, SSL *a, a, return 0, return) 192 #endif 178 193 DEFINEFUNC2(int, SSL_get_error, SSL *a, a, int b, b, return -1, return) 179 194 DEFINEFUNC(STACK_OF(X509) *, SSL_get_peer_cert_chain, SSL *a, a, return 0, return) … … 193 208 DEFINEFUNC(void, SSL_set_connect_state, SSL *a, a, return, DUMMYARG) 194 209 DEFINEFUNC(int, SSL_shutdown, SSL *a, a, return -1, return) 210 #if OPENSSL_VERSION_NUMBER >= 0x10000000L 211 DEFINEFUNC(const SSL_METHOD *, SSLv2_client_method, DUMMYARG, DUMMYARG, return 0, return) 212 DEFINEFUNC(const SSL_METHOD *, SSLv3_client_method, DUMMYARG, DUMMYARG, return 0, return) 213 DEFINEFUNC(const SSL_METHOD *, SSLv23_client_method, DUMMYARG, DUMMYARG, return 0, return) 214 DEFINEFUNC(const SSL_METHOD *, TLSv1_client_method, DUMMYARG, DUMMYARG, return 0, return) 215 DEFINEFUNC(const SSL_METHOD *, SSLv2_server_method, DUMMYARG, DUMMYARG, return 0, return) 216 DEFINEFUNC(const SSL_METHOD *, SSLv3_server_method, DUMMYARG, DUMMYARG, return 0, return) 217 DEFINEFUNC(const SSL_METHOD *, SSLv23_server_method, DUMMYARG, DUMMYARG, return 0, return) 218 DEFINEFUNC(const SSL_METHOD *, TLSv1_server_method, DUMMYARG, DUMMYARG, return 0, return) 219 #else 195 220 DEFINEFUNC(SSL_METHOD *, SSLv2_client_method, DUMMYARG, DUMMYARG, return 0, return) 196 221 DEFINEFUNC(SSL_METHOD *, SSLv3_client_method, DUMMYARG, DUMMYARG, return 0, return) … … 201 226 DEFINEFUNC(SSL_METHOD *, SSLv23_server_method, DUMMYARG, DUMMYARG, return 0, return) 202 227 DEFINEFUNC(SSL_METHOD *, TLSv1_server_method, DUMMYARG, DUMMYARG, return 0, return) 228 #endif 203 229 DEFINEFUNC3(int, SSL_write, SSL *a, a, const void *b, b, int c, c, return -1, return) 204 230 DEFINEFUNC2(int, X509_cmp, X509 *a, a, X509 *b, b, return -1, return) … … 232 258 DEFINEFUNC(void, OPENSSL_add_all_algorithms_conf, void, DUMMYARG, return, DUMMYARG) 233 259 260 #ifdef Q_OS_SYMBIAN 261 #define RESOLVEFUNC(func, ordinal, lib) \ 262 if (!(_q_##func = _q_PTR_##func(lib->resolve(#ordinal)))) \ 263 qWarning("QSslSocket: cannot resolve "#func); 264 #else 234 265 #define RESOLVEFUNC(func) \ 235 266 if (!(_q_##func = _q_PTR_##func(libs.first->resolve(#func))) \ 236 267 && !(_q_##func = _q_PTR_##func(libs.second->resolve(#func)))) \ 237 268 qWarning("QSslSocket: cannot resolve "#func); 269 #endif 238 270 239 271 #if !defined QT_LINKED_OPENSSL … … 336 368 pair.second = libeay32; 337 369 return pair; 338 370 # elif defined(Q_OS_SYMBIAN) 371 QLibrary *libssl = new QLibrary(QLatin1String("libssl")); 372 if (!libssl->load()) { 373 // Cannot find ssleay32.dll 374 delete libssl; 375 return pair; 376 } 377 378 QLibrary *libcrypto = new QLibrary(QLatin1String("libcrypto")); 379 if (!libcrypto->load()) { 380 delete libcrypto; 381 delete libssl; 382 return pair; 383 } 384 385 pair.first = libssl; 386 pair.second = libcrypto; 387 return pair; 339 388 # elif defined(Q_OS_UNIX) 340 389 QLibrary *&libssl = pair.first; … … 365 414 // paths. See the man page for dlopen(3) on your system for more information. 366 415 416 #ifdef Q_OS_OPENBSD 417 libcrypto->setLoadHints(QLibrary::ExportExternalSymbolsHint); 418 #endif 367 419 #ifdef SHLIB_VERSION_NUMBER 368 420 // first attempt: the canonical name is libssl.so.<SHLIB_VERSION_NUMBER> 369 421 libssl->setFileNameAndVersion(QLatin1String("ssl"), QLatin1String(SHLIB_VERSION_NUMBER)); 370 422 libcrypto->setFileNameAndVersion(QLatin1String("crypto"), QLatin1String(SHLIB_VERSION_NUMBER)); 371 if (lib ssl->load() && libcrypto->load()) {423 if (libcrypto->load() && libssl->load()) { 372 424 // libssl.so.<SHLIB_VERSION_NUMBER> and libcrypto.so.<SHLIB_VERSION_NUMBER> found 373 425 return pair; … … 381 433 libssl->setFileNameAndVersion(QLatin1String("ssl"), -1); 382 434 libcrypto->setFileNameAndVersion(QLatin1String("crypto"), -1); 383 if (lib ssl->load() && libcrypto->load()) {435 if (libcrypto->load() && libssl->load()) { 384 436 // libssl.so.0 and libcrypto.so.0 found 385 437 return pair; … … 396 448 libssl->setFileNameAndVersion(ssl, -1); 397 449 libcrypto->setFileNameAndVersion(crypto, -1); 398 if (lib ssl->load() && libcrypto->load()) {450 if (libcrypto->load() && libssl->load()) { 399 451 // libssl.so.0 and libcrypto.so.0 found 400 452 return pair; … … 435 487 return false; 436 488 489 #ifdef Q_OS_SYMBIAN 490 #ifdef SSLEAY_MACROS 491 RESOLVEFUNC(ASN1_dup, 125, libs.second ) 492 #endif 493 RESOLVEFUNC(ASN1_INTEGER_get, 48, libs.second ) 494 RESOLVEFUNC(ASN1_STRING_data, 71, libs.second ) 495 RESOLVEFUNC(ASN1_STRING_length, 76, libs.second ) 496 RESOLVEFUNC(BIO_ctrl, 184, libs.second ) 497 RESOLVEFUNC(BIO_free, 209, libs.second ) 498 RESOLVEFUNC(BIO_new, 222, libs.second ) 499 RESOLVEFUNC(BIO_new_mem_buf, 230, libs.second ) 500 RESOLVEFUNC(BIO_read, 244, libs.second ) 501 RESOLVEFUNC(BIO_s_mem, 251, libs.second ) 502 RESOLVEFUNC(BIO_write, 269, libs.second ) 503 RESOLVEFUNC(BN_num_bits, 387, libs.second ) 504 RESOLVEFUNC(CRYPTO_free, 469, libs.second ) 505 RESOLVEFUNC(CRYPTO_num_locks, 500, libs.second ) 506 RESOLVEFUNC(CRYPTO_set_id_callback, 513, libs.second ) 507 RESOLVEFUNC(CRYPTO_set_locking_callback, 516, libs.second ) 508 RESOLVEFUNC(DSA_free, 594, libs.second ) 509 RESOLVEFUNC(ERR_error_string, 744, libs.second ) 510 RESOLVEFUNC(ERR_get_error, 749, libs.second ) 511 RESOLVEFUNC(EVP_des_ede3_cbc, 919, libs.second ) 512 RESOLVEFUNC(EVP_PKEY_assign, 859, libs.second ) 513 RESOLVEFUNC(EVP_PKEY_free, 867, libs.second ) 514 RESOLVEFUNC(EVP_PKEY_get1_DSA, 869, libs.second ) 515 RESOLVEFUNC(EVP_PKEY_get1_RSA, 870, libs.second ) 516 RESOLVEFUNC(EVP_PKEY_new, 876, libs.second ) 517 RESOLVEFUNC(EVP_PKEY_type, 882, libs.second ) 518 RESOLVEFUNC(OBJ_nid2sn, 1036, libs.second ) 519 RESOLVEFUNC(OBJ_obj2nid, 1037, libs.second ) 520 #ifdef SSLEAY_MACROS // ### verify 521 RESOLVEFUNC(PEM_ASN1_read_bio, 1180, libs.second ) 522 #else 523 RESOLVEFUNC(PEM_read_bio_DSAPrivateKey, 1219, libs.second ) 524 RESOLVEFUNC(PEM_read_bio_RSAPrivateKey, 1228, libs.second ) 525 RESOLVEFUNC(PEM_write_bio_DSAPrivateKey, 1260, libs.second ) 526 RESOLVEFUNC(PEM_write_bio_RSAPrivateKey, 1271, libs.second ) 527 #endif 528 RESOLVEFUNC(PEM_read_bio_DSA_PUBKEY, 1220, libs.second ) 529 RESOLVEFUNC(PEM_read_bio_RSA_PUBKEY, 1230, libs.second ) 530 RESOLVEFUNC(PEM_write_bio_DSA_PUBKEY, 1261, libs.second ) 531 RESOLVEFUNC(PEM_write_bio_RSA_PUBKEY, 1273, libs.second ) 532 RESOLVEFUNC(RAND_seed, 1426, libs.second ) 533 RESOLVEFUNC(RAND_status, 1429, libs.second ) 534 RESOLVEFUNC(RSA_free, 1450, libs.second ) 535 RESOLVEFUNC(sk_free, 2571, libs.second ) 536 RESOLVEFUNC(sk_num, 2576, libs.second ) 537 RESOLVEFUNC(sk_pop_free, 2578, libs.second ) 538 RESOLVEFUNC(sk_value, 2585, libs.second ) 539 RESOLVEFUNC(SSL_CIPHER_description, 11, libs.first ) 540 RESOLVEFUNC(SSL_CTX_check_private_key, 21, libs.first ) 541 RESOLVEFUNC(SSL_CTX_ctrl, 22, libs.first ) 542 RESOLVEFUNC(SSL_CTX_free, 24, libs.first ) 543 RESOLVEFUNC(SSL_CTX_new, 35, libs.first ) 544 RESOLVEFUNC(SSL_CTX_set_cipher_list, 40, libs.first ) 545 RESOLVEFUNC(SSL_CTX_set_default_verify_paths, 44, libs.first ) 546 RESOLVEFUNC(SSL_CTX_set_verify, 56, libs.first ) 547 RESOLVEFUNC(SSL_CTX_set_verify_depth, 57, libs.first ) 548 RESOLVEFUNC(SSL_CTX_use_certificate, 64, libs.first ) 549 RESOLVEFUNC(SSL_CTX_use_certificate_file, 67, libs.first ) 550 RESOLVEFUNC(SSL_CTX_use_PrivateKey, 58, libs.first ) 551 RESOLVEFUNC(SSL_CTX_use_RSAPrivateKey, 61, libs.first ) 552 RESOLVEFUNC(SSL_CTX_use_PrivateKey_file, 60, libs.first ) 553 RESOLVEFUNC(SSL_accept, 82, libs.first ) 554 RESOLVEFUNC(SSL_clear, 92, libs.first ) 555 RESOLVEFUNC(SSL_connect, 93, libs.first ) 556 RESOLVEFUNC(SSL_free, 99, libs.first ) 557 RESOLVEFUNC(SSL_get_ciphers, 104, libs.first ) 558 RESOLVEFUNC(SSL_get_current_cipher, 106, libs.first ) 559 RESOLVEFUNC(SSL_get_error, 110, libs.first ) 560 RESOLVEFUNC(SSL_get_peer_cert_chain, 117, libs.first ) 561 RESOLVEFUNC(SSL_get_peer_certificate, 118, libs.first ) 562 RESOLVEFUNC(SSL_get_verify_result, 132, libs.first ) 563 RESOLVEFUNC(SSL_library_init, 137, libs.first ) 564 RESOLVEFUNC(SSL_load_error_strings, 139, libs.first ) 565 RESOLVEFUNC(SSL_new, 140, libs.first ) 566 RESOLVEFUNC(SSL_read, 143, libs.first ) 567 RESOLVEFUNC(SSL_set_accept_state, 148, libs.first ) 568 RESOLVEFUNC(SSL_set_bio, 149, libs.first ) 569 RESOLVEFUNC(SSL_set_connect_state, 152, libs.first ) 570 RESOLVEFUNC(SSL_shutdown, 173, libs.first ) 571 RESOLVEFUNC(SSL_write, 188, libs.first ) 572 RESOLVEFUNC(SSLv2_client_method, 192, libs.first ) 573 RESOLVEFUNC(SSLv3_client_method, 195, libs.first ) 574 RESOLVEFUNC(SSLv23_client_method, 189, libs.first ) 575 RESOLVEFUNC(TLSv1_client_method, 198, libs.first ) 576 RESOLVEFUNC(SSLv2_server_method, 194, libs.first ) 577 RESOLVEFUNC(SSLv3_server_method, 197, libs.first ) 578 RESOLVEFUNC(SSLv23_server_method, 191, libs.first ) 579 RESOLVEFUNC(TLSv1_server_method, 200, libs.first ) 580 RESOLVEFUNC(X509_NAME_oneline, 1830, libs.second ) 581 RESOLVEFUNC(X509_PUBKEY_get, 1844, libs.second ) 582 RESOLVEFUNC(X509_STORE_free, 1939, libs.second ) 583 RESOLVEFUNC(X509_STORE_new, 1942, libs.second ) 584 RESOLVEFUNC(X509_STORE_add_cert, 1936, libs.second ) 585 RESOLVEFUNC(X509_STORE_CTX_free, 1907, libs.second ) 586 RESOLVEFUNC(X509_STORE_CTX_init, 1919, libs.second ) 587 RESOLVEFUNC(X509_STORE_CTX_new, 1920, libs.second ) 588 RESOLVEFUNC(X509_STORE_CTX_set_purpose, 1931, libs.second ) 589 RESOLVEFUNC(X509_cmp, 1992, libs.second ) 590 #ifndef SSLEAY_MACROS 591 RESOLVEFUNC(X509_dup, 1997, libs.second ) 592 #endif 593 RESOLVEFUNC(X509_EXTENSION_get_object, 1785, libs.second ) 594 RESOLVEFUNC(X509_free, 2001, libs.second ) 595 RESOLVEFUNC(X509_get_ext, 2012, libs.second ) 596 RESOLVEFUNC(X509_get_ext_count, 2016, libs.second ) 597 RESOLVEFUNC(X509_get_ext_d2i, 2017, libs.second ) 598 RESOLVEFUNC(X509_get_issuer_name, 2018, libs.second ) 599 RESOLVEFUNC(X509_get_subject_name, 2022, libs.second ) 600 RESOLVEFUNC(X509_verify_cert, 2069, libs.second ) 601 RESOLVEFUNC(d2i_X509, 2309, libs.second ) 602 RESOLVEFUNC(i2d_X509, 2489, libs.second ) 603 #ifdef SSLEAY_MACROS 604 RESOLVEFUNC(i2d_DSAPrivateKey, 2395, libs.second ) 605 RESOLVEFUNC(i2d_RSAPrivateKey, 2476, libs.second ) 606 RESOLVEFUNC(d2i_DSAPrivateKey, 2220, libs.second ) 607 RESOLVEFUNC(d2i_RSAPrivateKey, 2296, libs.second ) 608 #endif 609 RESOLVEFUNC(OPENSSL_add_all_algorithms_noconf, 1153, libs.second ) 610 RESOLVEFUNC(OPENSSL_add_all_algorithms_conf, 1152, libs.second ) 611 #else // Q_OS_SYMBIAN 437 612 #ifdef SSLEAY_MACROS 438 613 RESOLVEFUNC(ASN1_dup) 439 614 #endif 615 RESOLVEFUNC(ASN1_INTEGER_get) 440 616 RESOLVEFUNC(ASN1_STRING_data) 441 617 RESOLVEFUNC(ASN1_STRING_length) … … 481 657 RESOLVEFUNC(sk_free) 482 658 RESOLVEFUNC(sk_num) 659 RESOLVEFUNC(sk_pop_free) 483 660 RESOLVEFUNC(sk_value) 484 661 RESOLVEFUNC(SSL_CIPHER_description) … … 554 731 RESOLVEFUNC(OPENSSL_add_all_algorithms_noconf) 555 732 RESOLVEFUNC(OPENSSL_add_all_algorithms_conf) 733 #endif // Q_OS_SYMBIAN 556 734 symbolsResolved = true; 557 735 delete libs.first; -
trunk/src/network/ssl/qsslsocket_openssl_symbols_p.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtNetwork module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 202 202 203 203 bool q_resolveOpenSslSymbols(); 204 long q_ASN1_INTEGER_get(ASN1_INTEGER *a); 204 205 unsigned char * q_ASN1_STRING_data(ASN1_STRING *a); 205 206 int q_ASN1_STRING_length(ASN1_STRING *a); … … 255 256 int q_RAND_status(); 256 257 void q_RSA_free(RSA *a); 258 int q_sk_num(STACK *a); 259 void q_sk_pop_free(STACK *a, void (*b)(void *)); 260 #if OPENSSL_VERSION_NUMBER >= 0x10000000L 261 void q_sk_free(_STACK *a); 262 void * q_sk_value(STACK *a, int b); 263 #else 257 264 void q_sk_free(STACK *a); 258 int q_sk_num(STACK *a);259 265 char * q_sk_value(STACK *a, int b); 266 #endif 260 267 int q_SSL_accept(SSL *a); 261 268 int q_SSL_clear(SSL *a); … … 270 277 long q_SSL_CTX_ctrl(SSL_CTX *a, int b, long c, void *d); 271 278 void q_SSL_CTX_free(SSL_CTX *a); 279 #if OPENSSL_VERSION_NUMBER >= 0x10000000L 280 SSL_CTX *q_SSL_CTX_new(const SSL_METHOD *a); 281 #else 272 282 SSL_CTX *q_SSL_CTX_new(SSL_METHOD *a); 283 #endif 273 284 int q_SSL_CTX_set_cipher_list(SSL_CTX *a, const char *b); 274 285 int q_SSL_CTX_set_default_verify_paths(SSL_CTX *a); … … 287 298 STACK_OF(SSL_CIPHER) *q_SSL_get_ciphers(SSL *a); 288 299 #endif 300 #if OPENSSL_VERSION_NUMBER >= 0x10000000L 301 const SSL_CIPHER *q_SSL_get_current_cipher(SSL *a); 302 #else 289 303 SSL_CIPHER *q_SSL_get_current_cipher(SSL *a); 304 #endif 290 305 int q_SSL_get_error(SSL *a, int b); 291 306 STACK_OF(X509) *q_SSL_get_peer_cert_chain(SSL *a); … … 305 320 void q_SSL_set_connect_state(SSL *a); 306 321 int q_SSL_shutdown(SSL *a); 322 #if OPENSSL_VERSION_NUMBER >= 0x10000000L 323 const SSL_METHOD *q_SSLv2_client_method(); 324 const SSL_METHOD *q_SSLv3_client_method(); 325 const SSL_METHOD *q_SSLv23_client_method(); 326 const SSL_METHOD *q_TLSv1_client_method(); 327 const SSL_METHOD *q_SSLv2_server_method(); 328 const SSL_METHOD *q_SSLv3_server_method(); 329 const SSL_METHOD *q_SSLv23_server_method(); 330 const SSL_METHOD *q_TLSv1_server_method(); 331 #else 307 332 SSL_METHOD *q_SSLv2_client_method(); 308 333 SSL_METHOD *q_SSLv3_client_method(); … … 313 338 SSL_METHOD *q_SSLv23_server_method(); 314 339 SSL_METHOD *q_TLSv1_server_method(); 340 #endif 315 341 int q_SSL_write(SSL *a, const void *b, int c); 316 342 int q_X509_cmp(X509 *a, X509 *b); -
trunk/src/network/ssl/qsslsocket_p.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtNetwork module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 80 80 bool autoStartHandshake; 81 81 bool connectionEncrypted; 82 bool ignoreSslErrors; 82 bool ignoreAllSslErrors; 83 QList<QSslError> ignoreErrorsList; 83 84 bool* readyReadEmittedPointer; 84 85 … … 88 89 QSslConfigurationPrivate configuration; 89 90 QList<QSslError> sslErrors; 91 92 // if set, this hostname is used for certificate validation instead of the hostname 93 // that was used for connecting to. 94 QString verificationPeerName; 90 95 91 96 static bool ensureInitialized(); … … 116 121 void _q_bytesWrittenSlot(qint64); 117 122 void _q_flushWriteBuffer(); 123 void _q_flushReadBuffer(); 118 124 119 125 // Platform specific functions -
trunk/src/network/ssl/ssl.pri
r2 r561 1 1 # OpenSSL support; compile in QSslSocket. 2 2 contains(QT_CONFIG, openssl) | contains(QT_CONFIG, openssl-linked) { 3 include($$QT_SOURCE_TREE/config.tests/unix/openssl/openssl.pri) 3 4 5 symbian { 6 INCLUDEPATH *= $$OS_LAYER_SSL_SYSTEMINCLUDE 7 } else { 8 include($$QT_SOURCE_TREE/config.tests/unix/openssl/openssl.pri) 9 } 4 10 5 11 HEADERS += ssl/qssl.h \ … … 30 36 31 37 # Add optional SSL libs 32 LIBS += $$OPENSSL_LIBS38 LIBS_PRIVATE += $$OPENSSL_LIBS 33 39 }
Note:
See TracChangeset
for help on using the changeset viewer.