Changeset 561 for trunk/src/network/ssl


Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/network/ssl/qssl.cpp

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the QtNetwork module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
     
    5050    \since 4.3
    5151
    52     \ingroup io
     52    \ingroup network
     53    \ingroup ssl
    5354    \inmodule QtNetwork
    5455*/
  • trunk/src/network/ssl/qssl.h

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the QtNetwork module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/network/ssl/qsslcertificate.cpp

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the QtNetwork module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
     
    4747
    4848    \reentrant
    49     \ingroup io
     49    \ingroup network
    5050    \ingroup ssl
    5151    \inmodule QtNetwork
     
    7272    certificate, its subject, and its issuer, by calling one of the
    7373    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
    7778    subject's public key as a QSslKey. You can call issuerInfo() or
    7879    subjectInfo() to get detailed information about the certificate
     
    126127QT_BEGIN_NAMESPACE
    127128
     129// forward declaration
     130static QMap<QString, QString> _q_mapFromOnelineName(char *name);
     131
    128132/*!
    129133    Constructs a QSslCertificate by reading \a format encoded data
     
    158162QSslCertificate::QSslCertificate(const QSslCertificate &other) : d(other.d)
    159163{
    160     d->ref.ref();
    161164}
    162165
     
    166169QSslCertificate::~QSslCertificate()
    167170{
    168     if (!d->ref.deref())
    169         delete d;
    170171}
    171172
     
    176177QSslCertificate &QSslCertificate::operator=(const QSslCertificate &other)
    177178{
    178     qAtomicAssign(d, other.d);
     179    d = other.d;
    179180    return *this;
    180181}
     
    242243    if (isNull())
    243244        return;
    244     if (d->ref == 1)
    245         delete d;
    246     else
    247         d->ref.deref();
    248 
    249245    d = new QSslCertificatePrivate;
    250246}
     
    255251QByteArray QSslCertificate::version() const
    256252{
     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
    257257    return d->versionString;
    258258}
    259259
    260260/*!
    261     Returns the certificate's serial number string.
     261    Returns the certificate's serial number string in decimal format.
    262262*/
    263263QByteArray QSslCertificate::serialNumber() const
    264264{
     265    if (d->serialNumberString.isEmpty() && d->x509)
     266        d->serialNumberString =
     267            QByteArray::number(qlonglong(q_ASN1_INTEGER_get(d->x509->cert_info->serialNumber)));
     268
    265269    return d->serialNumberString;
    266270}
     
    268272/*!
    269273    Returns a cryptographic digest of this certificate. By default,
    270     and MD5 digest will be generated, but you can also specify a
     274    an MD5 digest will be generated, but you can also specify a
    271275    custom \a algorithm.
    272276*/
     
    301305QString QSslCertificate::issuerInfo(SubjectInfo info) const
    302306{
     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
    303311    return d->issuerInfo.value(_q_SubjectInfoToString(info));
    304312}
     
    328336QString QSslCertificate::subjectInfo(SubjectInfo info) const
    329337{
     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
    330342    return d->subjectInfo.value(_q_SubjectInfoToString(info));
    331343}
     
    363375        return result;
    364376
    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);
    366378
    367379    if (altNames) {
     
    378390
    379391            const char *altNameStr = reinterpret_cast<const char *>(q_ASN1_STRING_data(genName->d.ia5));
    380             const QString altName = QLatin1String(QByteArray(altNameStr, len));
     392            const QString altName = QString::fromLatin1(altNameStr, len);
    381393            if (genName->type == GEN_DNS)
    382394                result.insert(QSsl::DnsEntry, altName);
     
    384396                result.insert(QSsl::EmailEntry, altName);
    385397        }
    386         q_sk_free(altNames);
     398        q_sk_pop_free((STACK*)altNames, reinterpret_cast<void(*)(void*)>(q_sk_free));
    387399    }
    388400
     
    611623    array = array.toBase64();
    612624    QByteArray tmp;
    613     for (int i = 0; i < array.size() - 64; i += 64) {
     625    for (int i = 0; i <= array.size() - 64; i += 64) {
    614626        tmp += QByteArray::fromRawData(array.data() + i, 64);
    615627        tmp += "\n";
     
    662674    if (!x509 || !QSslSocket::supportsSsl())
    663675        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));
    669676
    670677    ASN1_TIME *nbef = q_X509_get_notBefore(x509);
     
    687694
    688695    if (ch == '\n') {
    689         *offset++;
     696        *offset += 1;
    690697        return true;
    691698    }
     
    767774    debug << "QSslCertificate("
    768775          << 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()
    774781#ifndef QT_NO_TEXTSTREAM
    775           << "," << certificate.effectiveDate()
    776           << "," << certificate.expiryDate()
     782          << ',' << certificate.effectiveDate()
     783          << ',' << certificate.expiryDate()
    777784#endif
    778           << ")";
     785          << ')';
    779786    return debug;
    780787}
  • trunk/src/network/ssl/qsslcertificate.h

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the QtNetwork module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
     
    4848#include <QtCore/qcryptographichash.h>
    4949#include <QtCore/qregexp.h>
     50#include <QtCore/qsharedpointer.h>
    5051#include <QtNetwork/qssl.h>
    5152
     
    119120
    120121private:
    121     QSslCertificatePrivate *d;
     122    QExplicitlySharedDataPointer<QSslCertificatePrivate> d;
    122123    friend class QSslCertificatePrivate;
    123124    friend class QSslSocketBackendPrivate;
  • trunk/src/network/ssl/qsslcertificate_p.h

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the QtNetwork module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
     
    7272    {
    7373        QSslSocketPrivate::ensureInitialized();
    74         ref = 1;
    7574    }
    7675
  • trunk/src/network/ssl/qsslcipher.cpp

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the QtNetwork module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
     
    4747
    4848    \reentrant
    49     \ingroup io
     49    \ingroup network
    5050    \ingroup ssl
    5151    \inmodule QtNetwork
     
    6565#ifndef QT_NO_DEBUG_STREAM
    6666#include <QtCore/qdebug.h>
     67#endif
    6768
    6869QT_BEGIN_NAMESPACE
    69 #endif
    7070
    7171/*!
     
    104104    : d(new QSslCipherPrivate)
    105105{
    106     *d = *other.d;
     106    *d.data() = *other.d.data();
    107107}
    108108
     
    112112QSslCipher::~QSslCipher()
    113113{
    114     delete d;
    115114}
    116115
     
    121120QSslCipher &QSslCipher::operator=(const QSslCipher &other)
    122121{
    123     *d = *other.d;
     122    *d.data() = *other.d.data();
    124123    return *this;
    125124}
     
    232231          << ", bits=" << cipher.usedBits()
    233232          << ", proto=" << qPrintable(cipher.protocolString())
    234           << ")";
     233          << ')';
    235234    return debug;
    236235}
  • trunk/src/network/ssl/qsslcipher.h

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the QtNetwork module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
     
    4545
    4646#include <QtCore/qstring.h>
     47#include <QtCore/qscopedpointer.h>
    4748#include <QtNetwork/qssl.h>
    4849
     
    7980
    8081private:
    81     QSslCipherPrivate *d;
     82    QScopedPointer<QSslCipherPrivate> d;
    8283    friend class QSslSocketBackendPrivate;
    8384};
  • trunk/src/network/ssl/qsslcipher_p.h

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the QtNetwork module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/network/ssl/qsslconfiguration.cpp

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the QtNetwork module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
     
    6767    \reentrant
    6868    \inmodule QtNetwork
    69     \ingroup io
     69    \ingroup network
    7070    \ingroup ssl
    7171
  • trunk/src/network/ssl/qsslconfiguration.h

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the QtNetwork module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
     
    4242/****************************************************************************
    4343**
    44 ** In addition, as a special exception, Trolltech gives permission to link
     44** In addition, as a special exception, Nokia gives permission to link
    4545** the code of its release of Qt with the OpenSSL project's "OpenSSL" library
    4646** (or modified versions of the "OpenSSL" library that use the same license
  • trunk/src/network/ssl/qsslconfiguration_p.h

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the QtNetwork module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
     
    4242/****************************************************************************
    4343**
    44 ** In addition, as a special exception, Trolltech gives permission to link
     44** In addition, as a special exception, Nokia gives permission to link
    4545** the code of its release of Qt with the OpenSSL project's "OpenSSL" library
    4646** (or modified versions of the "OpenSSL" library that use the same license
  • trunk/src/network/ssl/qsslerror.cpp

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the QtNetwork module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
     
    4747
    4848    \reentrant
    49     \ingroup io
     49    \ingroup network
    5050    \ingroup ssl
    5151    \inmodule QtNetwork
     
    9292
    9393#include "qsslerror.h"
     94#include "qsslsocket.h"
    9495#ifndef QT_NO_DEBUG_STREAM
    9596#include <QtCore/qdebug.h>
     
    106107
    107108/*!
    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
     115QSslError::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*/
     127QSslError::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
    109136    error that occurred, and which \a certificate the error relates to.
    110137
     
    124151    : d(new QSslErrorPrivate)
    125152{
    126     *d = *other.d;
     153    *d.data() = *other.d.data();
    127154}
    128155
     
    132159QSslError::~QSslError()
    133160{
    134     delete d;
    135161}
    136162
     
    142168QSslError &QSslError::operator=(const QSslError &other)
    143169{
    144     *d = *other.d;
     170    *d.data() = *other.d.data();
    145171    return *this;
    146172}
     
    185211    switch (d->error) {
    186212    case NoError:
    187         errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "No error"));
     213        errStr = QSslSocket::tr("No error");
    188214        break;
    189215    case UnableToGetIssuerCertificate:
    190         errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The issuer certificate could not be found"));
     216        errStr = QSslSocket::tr("The issuer certificate could not be found");
    191217        break;
    192218    case UnableToDecryptCertificateSignature:
    193         errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The certificate signature could not be decrypted"));
     219        errStr = QSslSocket::tr("The certificate signature could not be decrypted");
    194220        break;
    195221    case UnableToDecodeIssuerPublicKey:
    196         errStr = QObject::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");
    197223        break;
    198224    case CertificateSignatureFailed:
    199         errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The signature of the certificate is invalid"));
     225        errStr = QSslSocket::tr("The signature of the certificate is invalid");
    200226        break;
    201227    case CertificateNotYetValid:
    202         errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The certificate is not yet valid"));
     228        errStr = QSslSocket::tr("The certificate is not yet valid");
    203229        break;
    204230    case CertificateExpired:
    205         errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The certificate has expired"));
     231        errStr = QSslSocket::tr("The certificate has expired");
    206232        break;
    207233    case InvalidNotBeforeField:
    208         errStr = QObject::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");
    209235        break;
    210236    case InvalidNotAfterField:
    211         errStr = QObject::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");
    212238        break;
    213239    case SelfSignedCertificate:
    214         errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The certificate is self-signed, and untrusted"));
     240        errStr = QSslSocket::tr("The certificate is self-signed, and untrusted");
    215241        break;
    216242    case SelfSignedCertificateInChain:
    217         errStr = QObject::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");
    218244        break;
    219245    case UnableToGetLocalIssuerCertificate:
    220         errStr = QObject::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");
    221247        break;
    222248    case UnableToVerifyFirstCertificate:
    223         errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "No certificates could be verified"));
     249        errStr = QSslSocket::tr("No certificates could be verified");
    224250        break;
    225251    case InvalidCaCertificate:
    226         errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "One of the CA certificates is invalid"));
     252        errStr = QSslSocket::tr("One of the CA certificates is invalid");
    227253        break;
    228254    case PathLengthExceeded:
    229         errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The basicConstraints pathlength parameter has been exceeded"));
     255        errStr = QSslSocket::tr("The basicConstraints path length parameter has been exceeded");
    230256        break;
    231257    case InvalidPurpose:
    232         errStr = QObject::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");
    233259        break;
    234260    case CertificateUntrusted:
    235         errStr = QObject::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");
    236262        break;
    237263    case CertificateRejected:
    238         errStr = QObject::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");
    239265        break;
    240266    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");
    244269        break;
    245270    case AuthorityIssuerSerialNumberMismatch:
    246         errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The current candidate issuer certificate was rejected because"
    247                                                " its issuer name and serial number was present and did not match the"
    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");
    249274        break;
    250275    case NoPeerCertificate:
    251         errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The peer did not present any certificate"));
     276        errStr = QSslSocket::tr("The peer did not present any certificate");
    252277        break;
    253278    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");
    257281        break;
    258282    case NoSslSupport:
    259283        break;
    260284    default:
    261         errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "Unknown error"));
     285        errStr = QSslSocket::tr("Unknown error");
    262286        break;
    263287    }
  • trunk/src/network/ssl/qsslerror.h

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the QtNetwork module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
     
    8787    };
    8888
    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
    9095    QSslError(const QSslError &other);
     96
    9197    ~QSslError();
    9298    QSslError &operator=(const QSslError &other);
     
    100106   
    101107private:
    102     QSslErrorPrivate *d;
     108    QScopedPointer<QSslErrorPrivate> d;
    103109};
    104110
  • trunk/src/network/ssl/qsslkey.cpp

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the QtNetwork module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
     
    4747
    4848    \reentrant
    49     \ingroup io
     49    \ingroup network
    5050    \ingroup ssl
    5151    \inmodule QtNetwork
     
    272272QSslKey::QSslKey(const QSslKey &other) : d(other.d)
    273273{
    274     d->ref.ref();
    275274}
    276275
     
    280279QSslKey::~QSslKey()
    281280{
    282     if (!d->ref.deref())
    283         delete d;
    284281}
    285282
     
    292289QSslKey &QSslKey::operator=(const QSslKey &other)
    293290{
    294     qAtomicAssign(d, other.d);
     291    d = other.d;
    295292    return *this;
    296293}
     
    313310void QSslKey::clear()
    314311{
    315     if (!d->ref.deref()) {
    316         delete d;
    317         d = new QSslKeyPrivate;
    318     }
     312    d = new QSslKeyPrivate;
    319313}
    320314
     
    461455          << ", " << (key.algorithm() == QSsl::Rsa ? "RSA" : "DSA")
    462456          << ", " << key.length()
    463           << ")";
     457          << ')';
    464458    return debug;
    465459}
  • trunk/src/network/ssl/qsslkey.h

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the QtNetwork module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
     
    4646#include <QtCore/qnamespace.h>
    4747#include <QtCore/qbytearray.h>
     48#include <QtCore/qsharedpointer.h>
    4849#include <QtNetwork/qssl.h>
    4950
     
    5960
    6061class QIODevice;
    61    
     62
    6263class QSslKeyPrivate;
    6364class Q_NETWORK_EXPORT QSslKey
     
    9394
    9495private:
    95     QSslKeyPrivate *d;
     96    QExplicitlySharedDataPointer<QSslKeyPrivate> d;
    9697    friend class QSslCertificate;
    9798};
  • trunk/src/network/ssl/qsslkey_p.h

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the QtNetwork module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
     
    7070    {
    7171        clear();
    72         ref = 1;
    7372    }
    7473
     
    9291
    9392    QAtomicInt ref;
     93
     94private:
     95    Q_DISABLE_COPY(QSslKeyPrivate)
    9496};
    9597
  • trunk/src/network/ssl/qsslsocket.cpp

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the QtNetwork module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
     
    5050
    5151    \reentrant
    52     \ingroup io
     52    \ingroup network
    5353    \ingroup ssl
    5454    \inmodule QtNetwork
     
    114114    internal buffer, and you can call write() or putChar() to write
    115115    data back to the peer. QSslSocket will automatically encrypt the
    116     written data for you, and emit bytesWritten() once the data has
    117     been written to the peer.
     116    written data for you, and emit encryptedBytesWritten() once
     117    the data has been written to the peer.
    118118
    119119    As a convenience, QSslSocket supports QTcpSocket's blocking
     
    150150    for use in the OpenSSL Toolkit (\l{http://www.openssl.org/}).
    151151
     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
    152159    \sa QSslCertificate, QSslCipher, QSslError
    153160*/
     
    357364    ignoreSslErrors(), either from inside a slot function connected to
    358365    the sslErrors() signal, or prior to entering encrypted mode. If
    359     ignoreSslErrors is not called, the connection is dropped, signal
     366    ignoreSslErrors() is not called, the connection is dropped, signal
    360367    disconnected() is emitted, and QSslSocket returns to the
    361368    UnconnectedState.
     
    398405
    399406/*!
     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*/
     417void 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/*!
    400437    Initializes QSslSocket with the native socket descriptor \a
    401438    socketDescriptor. Returns true if \a socketDescriptor is accepted
     
    413450    Q_D(QSslSocket);
    414451#ifdef QSSLSOCKET_DEBUG
    415     qDebug() << "QSslSocket::setSocketDescriptor(" << socketDescriptor << ","
    416              << state << "," << openMode << ")";
     452    qDebug() << "QSslSocket::setSocketDescriptor(" << socketDescriptor << ','
     453             << state << ',' << openMode << ')';
    417454#endif
    418455    if (!d->plainSocket)
     
    432469
    433470/*!
     471    \since 4.6
     472    Sets the given \a option to the value described by \a value.
     473
     474    \sa socketOption()
     475*/
     476void 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*/
     489QVariant 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/*!
    434499    Returns the current mode for the socket; either UnencryptedMode, where
    435500    QSslSocket behaves identially to QTcpSocket, or one of SslClientMode or
     
    451516
    452517    An encrypted socket encrypts all data that is written by calling write()
    453     or putChar() before the data is written to the network, and descrypts all
     518    or putChar() before the data is written to the network, and decrypts all
    454519    incoming data as the data is received from the network, before you call
    455520    read(), readLine() or getChar().
     
    654719    qDebug() << "QSslSocket::close()";
    655720#endif
     721    Q_D(QSslSocket);
     722    if (d->plainSocket)
     723        d->plainSocket->close();
    656724    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
    657733}
    658734
     
    12591335
    12601336/*!
    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
    12651339    returned by this function is used to initialize the database
    12661340    returned by defaultCaCertificates(). You can replace that database
     
    15281602    Q_D(QSslSocket);
    15291603    if (d->mode != UnencryptedMode) {
    1530         qWarning("QSslSocket::startClientEncryption: cannot start handshake on non-plain connection");
     1604        qWarning("QSslSocket::startServerEncryption: cannot start handshake on non-plain connection");
    15311605        return;
    15321606    }
     
    15631637{
    15641638    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*/
     1662void QSslSocket::ignoreSslErrors(const QList<QSslError> &errors)
     1663{
     1664    Q_D(QSslSocket);
     1665    d->ignoreErrorsList = errors;
    15661666}
    15671667
     
    15791679#ifdef QSSLSOCKET_DEBUG
    15801680    qDebug() << "QSslSocket::connectToHostImplementation("
    1581              << hostName << "," << port << "," << openMode << ")";
     1681             << hostName << ',' << port << ',' << openMode << ')';
    15821682#endif
    15831683    if (!d->plainSocket) {
     
    16531753    }
    16541754#ifdef QSSLSOCKET_DEBUG
    1655     qDebug() << "QSslSocket::readData(" << (void *)data << "," << maxlen << ") ==" << readBytes;
     1755    qDebug() << "QSslSocket::readData(" << (void *)data << ',' << maxlen << ") ==" << readBytes;
    16561756#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
    16571762    return readBytes;
    16581763}
     
    16651770    Q_D(QSslSocket);
    16661771#ifdef QSSLSOCKET_DEBUG
    1667     qDebug() << "QSslSocket::writeData(" << (void *)data << "," << len << ")";
     1772    qDebug() << "QSslSocket::writeData(" << (void *)data << ',' << len << ')';
    16681773#endif
    16691774    if (d->mode == UnencryptedMode && !d->autoStartHandshake)
     
    16831788*/
    16841789QSslSocketPrivate::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)
    16861797{
    16871798    QSslConfigurationPrivate::deepCopyDefaultConfiguration(&configuration);
     
    17031814    autoStartHandshake = false;
    17041815    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();
    17061821
    17071822    readBuffer.clear();
     
    19702085    Q_Q(QSslSocket);
    19712086#ifdef QSSLSOCKET_DEBUG
    1972     qDebug() << "QSslSocket::_q_stateChangedSlot(" << state << ")";
     2087    qDebug() << "QSslSocket::_q_stateChangedSlot(" << state << ')';
    19732088#endif
    19742089    q->setSocketState(state);
     
    19832098    Q_Q(QSslSocket);
    19842099#ifdef QSSLSOCKET_DEBUG
    1985     qDebug() << "QSslSocket::_q_errorSlot(" << error << ")";
     2100    qDebug() << "QSslSocket::_q_errorSlot(" << error << ')';
    19862101    qDebug() << "\tstate =" << q->state();
    19872102    qDebug() << "\terrorString =" << q->errorString();
     
    20182133    Q_Q(QSslSocket);
    20192134#ifdef QSSLSOCKET_DEBUG
    2020     qDebug() << "QSslSocket::_q_bytesWrittenSlot(" << written << ")";
     2135    qDebug() << "QSslSocket::_q_bytesWrittenSlot(" << written << ')';
    20212136#endif
    20222137
     
    20392154}
    20402155
     2156/*!
     2157    \internal
     2158*/
     2159void QSslSocketPrivate::_q_flushReadBuffer()
     2160{
     2161    // trigger a read from the plainSocket into SSL
     2162    if (mode != QSslSocket::UnencryptedMode)
     2163        transmit();
     2164}
     2165
    20412166QT_END_NAMESPACE
    20422167
  • trunk/src/network/ssl/qsslsocket.h

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the QtNetwork module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
     
    8787    // Autostarting the SSL client handshake.
    8888    void connectToHostEncrypted(const QString &hostName, quint16 port, OpenMode mode = ReadWrite);
     89    void connectToHostEncrypted(const QString &hostName, quint16 port, const QString &sslPeerName, OpenMode mode = ReadWrite);
    8990    bool setSocketDescriptor(int socketDescriptor, SocketState state = ConnectedState,
    9091                             OpenMode openMode = ReadWrite);
     92
     93    // ### Qt 5: Make virtual
     94    void setSocketOption(QAbstractSocket::SocketOption option, const QVariant &value);
     95    QVariant socketOption(QAbstractSocket::SocketOption option);
    9196
    9297    SslMode mode() const;
     
    169174
    170175    static bool supportsSsl();
     176    void ignoreSslErrors(const QList<QSslError> &errors);
    171177
    172178public Q_SLOTS:
     
    202208    Q_PRIVATE_SLOT(d_func(), void _q_bytesWrittenSlot(qint64))
    203209    Q_PRIVATE_SLOT(d_func(), void _q_flushWriteBuffer())
     210    Q_PRIVATE_SLOT(d_func(), void _q_flushReadBuffer())
    204211    friend class QSslSocketBackendPrivate;
    205212};
  • trunk/src/network/ssl/qsslsocket_openssl.cpp

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the QtNetwork module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
     
    277277            first = false;
    278278        else
    279             cipherString.append(":");
     279            cipherString.append(':');
    280280        cipherString.append(cipher.name().toLatin1());
    281281    }
     
    325325        // Check if the certificate matches the private key.
    326326        if (!q_SSL_CTX_check_private_key(ctx)) {
    327             q->setErrorString(QSslSocket::tr("Private key does not certificate public key, %1").arg(SSL_ERRORSTR()));
     327            q->setErrorString(QSslSocket::tr("Private key does not certify public key, %1").arg(SSL_ERRORSTR()));
    328328            emit q->error(QAbstractSocket::UnknownSocketError);
    329329            return false;
     
    483483QList<QSslCertificate> QSslSocketPrivate::systemCaCertificates()
    484484{
    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
    509486    QFile caBundle(QLatin1String(":/trolltech/network/ssl/qt-ca-bundle.crt"));
    510487    if (caBundle.open(QIODevice::ReadOnly | QIODevice::Text))
     
    524501    // Start connecting. This will place outgoing data in the BIO, so we
    525502    // follow up with calling transmit().
    526     testConnection();
     503    startHandshake();
    527504    transmit();
    528505}
     
    537514    // Start connecting. This will place outgoing data in the BIO, so we
    538515    // follow up with calling transmit().
    539     testConnection();
     516    startHandshake();
    540517    transmit();
    541518}
     
    625602            qDebug() << "QSslSocketBackendPrivate::transmit: testing encryption";
    626603#endif
    627             if (testConnection()) {
     604            if (startHandshake()) {
    628605#ifdef QSSLSOCKET_DEBUG
    629606                qDebug() << "QSslSocketBackendPrivate::transmit: encryption established";
     
    644621
    645622        // If the request is small and the remote host closes the transmission
    646         // after sending, there's a chance that testConnection() will already
     623        // after sending, there's a chance that startHandshake() will already
    647624        // have triggered a shutdown.
    648625        if (!ssl)
     
    744721}
    745722
    746 bool QSslSocketBackendPrivate::testConnection()
     723bool QSslSocketBackendPrivate::startHandshake()
    747724{
    748725    Q_Q(QSslSocket);
     
    785762            q->setSocketError(QAbstractSocket::SslHandshakeFailedError);
    786763#ifdef QSSLSOCKET_DEBUG
    787             qDebug() << "QSslSocketBackendPrivate::testConnection: error!" << q->errorString();
     764            qDebug() << "QSslSocketBackendPrivate::startHandshake: error!" << q->errorString();
    788765#endif
    789766            emit q->error(QAbstractSocket::SslHandshakeFailedError);
     
    816793        // if we're the server, don't check CN
    817794        if (mode == QSslSocket::SslClientMode) {
    818             QString peerName = q->peerName();
     795            QString peerName = (verificationPeerName.isEmpty () ? q->peerName() : verificationPeerName);
    819796            QString commonName = configuration.peerCertificate.subjectInfo(QSslCertificate::CommonName);
    820797
     
    863840        sslErrors = errors;
    864841        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) {
    866863            q->setErrorString(sslErrors.first().errorString());
    867864            q->setSocketError(QAbstractSocket::SslHandshakeFailedError);
     
    912909    if (!ssl || !ctx)
    913910        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
    914917    SSL_CIPHER *sessionCipher = q_SSL_get_current_cipher(ssl);
     918#endif
    915919    return sessionCipher ? QSslCipher_from_SSL_CIPHER(sessionCipher) : QSslCipher();
    916920}
  • trunk/src/network/ssl/qsslsocket_openssl_p.h

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the QtNetwork module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
     
    5858
    5959#ifdef Q_OS_WIN
    60 #include <windows.h>
     60#include <qt_windows.h>
    6161#if defined(OCSP_RESPONSE)
    6262#undef OCSP_RESPONSE
     
    7878#include <openssl/x509v3.h>
    7979#include <openssl/x509_vfy.h>
     80#include <openssl/dsa.h>
     81#include <openssl/rsa.h>
     82
     83#if OPENSSL_VERSION_NUMBER >= 0x10000000L
     84typedef _STACK STACK;
     85#endif
    8086
    8187QT_BEGIN_NAMESPACE
     
    103109    void startServerEncryption();
    104110    void transmit();
    105     bool testConnection();
     111    bool startHandshake();
    106112    void disconnectFromHost();
    107113    void disconnected();
  • trunk/src/network/ssl/qsslsocket_openssl_symbols.cpp

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the QtNetwork module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
     
    9595DEFINEFUNC3(void *, ASN1_dup, i2d_of_void *a, a, d2i_of_void *b, b, char *c, c, return 0, return)
    9696#endif
     97DEFINEFUNC(long, ASN1_INTEGER_get, ASN1_INTEGER *a, a, return 0, return)
    9798DEFINEFUNC(unsigned char *, ASN1_STRING_data, ASN1_STRING *a, a, return 0, return)
    9899DEFINEFUNC(int, ASN1_STRING_length, ASN1_STRING *a, a, return 0, return)
     
    143144DEFINEFUNC(int, RAND_status, void, DUMMYARG, return -1, return)
    144145DEFINEFUNC(void, RSA_free, RSA *a, a, return, DUMMYARG)
     146DEFINEFUNC(int, sk_num, STACK *a, a, return -1, return)
     147DEFINEFUNC2(void, sk_pop_free, STACK *a, a, void (*b)(void*), b, return, DUMMYARG)
     148#if OPENSSL_VERSION_NUMBER >= 0x10000000L
     149DEFINEFUNC(void, sk_free, _STACK *a, a, return, DUMMYARG)
     150DEFINEFUNC2(void *, sk_value, STACK *a, a, int b, b, return 0, return)
     151#else
    145152DEFINEFUNC(void, sk_free, STACK *a, a, return, DUMMYARG)
    146 DEFINEFUNC(int, sk_num, STACK *a, a, return -1, return)
    147153DEFINEFUNC2(char *, sk_value, STACK *a, a, int b, b, return 0, return)
     154#endif
    148155DEFINEFUNC(int, SSL_accept, SSL *a, a, return -1, return)
    149156DEFINEFUNC(int, SSL_clear, SSL *a, a, return -1, return)
     
    158165DEFINEFUNC4(long, SSL_CTX_ctrl, SSL_CTX *a, a, int b, b, long c, c, void *d, d, return -1, return)
    159166DEFINEFUNC(void, SSL_CTX_free, SSL_CTX *a, a, return, DUMMYARG)
     167#if OPENSSL_VERSION_NUMBER >= 0x10000000L
     168DEFINEFUNC(SSL_CTX *, SSL_CTX_new, const SSL_METHOD *a, a, return 0, return)
     169#else
    160170DEFINEFUNC(SSL_CTX *, SSL_CTX_new, SSL_METHOD *a, a, return 0, return)
     171#endif
    161172DEFINEFUNC2(int, SSL_CTX_set_cipher_list, SSL_CTX *a, a, const char *b, b, return -1, return)
    162173DEFINEFUNC(int, SSL_CTX_set_default_verify_paths, SSL_CTX *a, a, return -1, return)
     
    175186DEFINEFUNC(STACK_OF(SSL_CIPHER) *, SSL_get_ciphers, SSL *a, a, return 0, return)
    176187#endif
     188#if OPENSSL_VERSION_NUMBER >= 0x10000000L
     189DEFINEFUNC(const SSL_CIPHER *, SSL_get_current_cipher, SSL *a, a, return 0, return)
     190#else
    177191DEFINEFUNC(SSL_CIPHER *, SSL_get_current_cipher, SSL *a, a, return 0, return)
     192#endif
    178193DEFINEFUNC2(int, SSL_get_error, SSL *a, a, int b, b, return -1, return)
    179194DEFINEFUNC(STACK_OF(X509) *, SSL_get_peer_cert_chain, SSL *a, a, return 0, return)
     
    193208DEFINEFUNC(void, SSL_set_connect_state, SSL *a, a, return, DUMMYARG)
    194209DEFINEFUNC(int, SSL_shutdown, SSL *a, a, return -1, return)
     210#if OPENSSL_VERSION_NUMBER >= 0x10000000L
     211DEFINEFUNC(const SSL_METHOD *, SSLv2_client_method, DUMMYARG, DUMMYARG, return 0, return)
     212DEFINEFUNC(const SSL_METHOD *, SSLv3_client_method, DUMMYARG, DUMMYARG, return 0, return)
     213DEFINEFUNC(const SSL_METHOD *, SSLv23_client_method, DUMMYARG, DUMMYARG, return 0, return)
     214DEFINEFUNC(const SSL_METHOD *, TLSv1_client_method, DUMMYARG, DUMMYARG, return 0, return)
     215DEFINEFUNC(const SSL_METHOD *, SSLv2_server_method, DUMMYARG, DUMMYARG, return 0, return)
     216DEFINEFUNC(const SSL_METHOD *, SSLv3_server_method, DUMMYARG, DUMMYARG, return 0, return)
     217DEFINEFUNC(const SSL_METHOD *, SSLv23_server_method, DUMMYARG, DUMMYARG, return 0, return)
     218DEFINEFUNC(const SSL_METHOD *, TLSv1_server_method, DUMMYARG, DUMMYARG, return 0, return)
     219#else
    195220DEFINEFUNC(SSL_METHOD *, SSLv2_client_method, DUMMYARG, DUMMYARG, return 0, return)
    196221DEFINEFUNC(SSL_METHOD *, SSLv3_client_method, DUMMYARG, DUMMYARG, return 0, return)
     
    201226DEFINEFUNC(SSL_METHOD *, SSLv23_server_method, DUMMYARG, DUMMYARG, return 0, return)
    202227DEFINEFUNC(SSL_METHOD *, TLSv1_server_method, DUMMYARG, DUMMYARG, return 0, return)
     228#endif
    203229DEFINEFUNC3(int, SSL_write, SSL *a, a, const void *b, b, int c, c, return -1, return)
    204230DEFINEFUNC2(int, X509_cmp, X509 *a, a, X509 *b, b, return -1, return)
     
    232258DEFINEFUNC(void, OPENSSL_add_all_algorithms_conf, void, DUMMYARG, return, DUMMYARG)
    233259
     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
    234265#define RESOLVEFUNC(func) \
    235266    if (!(_q_##func = _q_PTR_##func(libs.first->resolve(#func)))     \
    236267        && !(_q_##func = _q_PTR_##func(libs.second->resolve(#func)))) \
    237268        qWarning("QSslSocket: cannot resolve "#func);
     269#endif
    238270
    239271#if !defined QT_LINKED_OPENSSL
     
    336368    pair.second = libeay32;
    337369    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;
    339388# elif defined(Q_OS_UNIX)
    340389    QLibrary *&libssl = pair.first;
     
    365414    // paths. See the man page for dlopen(3) on your system for more information.
    366415
     416#ifdef Q_OS_OPENBSD
     417    libcrypto->setLoadHints(QLibrary::ExportExternalSymbolsHint);
     418#endif
    367419#ifdef SHLIB_VERSION_NUMBER
    368420    // first attempt: the canonical name is libssl.so.<SHLIB_VERSION_NUMBER>
    369421    libssl->setFileNameAndVersion(QLatin1String("ssl"), QLatin1String(SHLIB_VERSION_NUMBER));
    370422    libcrypto->setFileNameAndVersion(QLatin1String("crypto"), QLatin1String(SHLIB_VERSION_NUMBER));
    371     if (libssl->load() && libcrypto->load()) {
     423    if (libcrypto->load() && libssl->load()) {
    372424        // libssl.so.<SHLIB_VERSION_NUMBER> and libcrypto.so.<SHLIB_VERSION_NUMBER> found
    373425        return pair;
     
    381433    libssl->setFileNameAndVersion(QLatin1String("ssl"), -1);
    382434    libcrypto->setFileNameAndVersion(QLatin1String("crypto"), -1);
    383     if (libssl->load() && libcrypto->load()) {
     435    if (libcrypto->load() && libssl->load()) {
    384436        // libssl.so.0 and libcrypto.so.0 found
    385437        return pair;
     
    396448        libssl->setFileNameAndVersion(ssl, -1);
    397449        libcrypto->setFileNameAndVersion(crypto, -1);
    398         if (libssl->load() && libcrypto->load()) {
     450        if (libcrypto->load() && libssl->load()) {
    399451            // libssl.so.0 and libcrypto.so.0 found
    400452            return pair;
     
    435487        return false;
    436488
     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
    437612#ifdef SSLEAY_MACROS
    438613    RESOLVEFUNC(ASN1_dup)
    439614#endif
     615    RESOLVEFUNC(ASN1_INTEGER_get)
    440616    RESOLVEFUNC(ASN1_STRING_data)
    441617    RESOLVEFUNC(ASN1_STRING_length)
     
    481657    RESOLVEFUNC(sk_free)
    482658    RESOLVEFUNC(sk_num)
     659    RESOLVEFUNC(sk_pop_free)
    483660    RESOLVEFUNC(sk_value)
    484661    RESOLVEFUNC(SSL_CIPHER_description)
     
    554731    RESOLVEFUNC(OPENSSL_add_all_algorithms_noconf)
    555732    RESOLVEFUNC(OPENSSL_add_all_algorithms_conf)
     733#endif // Q_OS_SYMBIAN
    556734    symbolsResolved = true;
    557735    delete libs.first;
  • trunk/src/network/ssl/qsslsocket_openssl_symbols_p.h

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the QtNetwork module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
     
    202202
    203203bool q_resolveOpenSslSymbols();
     204long q_ASN1_INTEGER_get(ASN1_INTEGER *a);
    204205unsigned char * q_ASN1_STRING_data(ASN1_STRING *a);
    205206int q_ASN1_STRING_length(ASN1_STRING *a);
     
    255256int q_RAND_status();
    256257void q_RSA_free(RSA *a);
     258int q_sk_num(STACK *a);
     259void q_sk_pop_free(STACK *a, void (*b)(void *));
     260#if OPENSSL_VERSION_NUMBER >= 0x10000000L
     261void q_sk_free(_STACK *a);
     262void * q_sk_value(STACK *a, int b);
     263#else
    257264void q_sk_free(STACK *a);
    258 int q_sk_num(STACK *a);
    259265char * q_sk_value(STACK *a, int b);
     266#endif
    260267int q_SSL_accept(SSL *a);
    261268int q_SSL_clear(SSL *a);
     
    270277long q_SSL_CTX_ctrl(SSL_CTX *a, int b, long c, void *d);
    271278void q_SSL_CTX_free(SSL_CTX *a);
     279#if OPENSSL_VERSION_NUMBER >= 0x10000000L
     280SSL_CTX *q_SSL_CTX_new(const SSL_METHOD *a);
     281#else
    272282SSL_CTX *q_SSL_CTX_new(SSL_METHOD *a);
     283#endif
    273284int q_SSL_CTX_set_cipher_list(SSL_CTX *a, const char *b);
    274285int q_SSL_CTX_set_default_verify_paths(SSL_CTX *a);
     
    287298STACK_OF(SSL_CIPHER) *q_SSL_get_ciphers(SSL *a);
    288299#endif
     300#if OPENSSL_VERSION_NUMBER >= 0x10000000L
     301const SSL_CIPHER *q_SSL_get_current_cipher(SSL *a);
     302#else
    289303SSL_CIPHER *q_SSL_get_current_cipher(SSL *a);
     304#endif
    290305int q_SSL_get_error(SSL *a, int b);
    291306STACK_OF(X509) *q_SSL_get_peer_cert_chain(SSL *a);
     
    305320void q_SSL_set_connect_state(SSL *a);
    306321int q_SSL_shutdown(SSL *a);
     322#if OPENSSL_VERSION_NUMBER >= 0x10000000L
     323const SSL_METHOD *q_SSLv2_client_method();
     324const SSL_METHOD *q_SSLv3_client_method();
     325const SSL_METHOD *q_SSLv23_client_method();
     326const SSL_METHOD *q_TLSv1_client_method();
     327const SSL_METHOD *q_SSLv2_server_method();
     328const SSL_METHOD *q_SSLv3_server_method();
     329const SSL_METHOD *q_SSLv23_server_method();
     330const SSL_METHOD *q_TLSv1_server_method();
     331#else
    307332SSL_METHOD *q_SSLv2_client_method();
    308333SSL_METHOD *q_SSLv3_client_method();
     
    313338SSL_METHOD *q_SSLv23_server_method();
    314339SSL_METHOD *q_TLSv1_server_method();
     340#endif
    315341int q_SSL_write(SSL *a, const void *b, int c);
    316342int q_X509_cmp(X509 *a, X509 *b);
  • trunk/src/network/ssl/qsslsocket_p.h

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the QtNetwork module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
     
    8080    bool autoStartHandshake;
    8181    bool connectionEncrypted;
    82     bool ignoreSslErrors;
     82    bool ignoreAllSslErrors;
     83    QList<QSslError> ignoreErrorsList;
    8384    bool* readyReadEmittedPointer;
    8485
     
    8889    QSslConfigurationPrivate configuration;
    8990    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;
    9095
    9196    static bool ensureInitialized();
     
    116121    void _q_bytesWrittenSlot(qint64);
    117122    void _q_flushWriteBuffer();
     123    void _q_flushReadBuffer();
    118124
    119125    // Platform specific functions
  • trunk/src/network/ssl/ssl.pri

    r2 r561  
    11# OpenSSL support; compile in QSslSocket.
    22contains(QT_CONFIG, openssl) | contains(QT_CONFIG, openssl-linked) {
    3     include($$QT_SOURCE_TREE/config.tests/unix/openssl/openssl.pri)
     3
     4
     5symbian {
     6        INCLUDEPATH *= $$OS_LAYER_SSL_SYSTEMINCLUDE
     7} else {
     8        include($$QT_SOURCE_TREE/config.tests/unix/openssl/openssl.pri)
     9}
    410
    511    HEADERS += ssl/qssl.h \
     
    3036
    3137    # Add optional SSL libs
    32     LIBS += $$OPENSSL_LIBS
     38    LIBS_PRIVATE += $$OPENSSL_LIBS
    3339}
Note: See TracChangeset for help on using the changeset viewer.