- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# qsslcertificate.h

Go to the documentation of this file.

    00001 /****************************************************************************
    00002 **
    00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    00004 ** All rights reserved.
    00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
    00006 **
    00007 ** This file is part of the QtNetwork module of the Qt Toolkit.
    00008 **
    00009 ** $QT_BEGIN_LICENSE:LGPL$
    00010 ** Commercial Usage
    00011 ** Licensees holding valid Qt Commercial licenses may use this file in
    00012 ** accordance with the Qt Commercial License Agreement provided with the
    00013 ** Software or, alternatively, in accordance with the terms contained in
    00014 ** a written agreement between you and Nokia.
    00015 **
    00016 ** GNU Lesser General Public License Usage
    00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
    00018 ** General Public License version 2.1 as published by the Free Software
    00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
    00020 ** packaging of this file.  Please review the following information to
    00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
    00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    00023 **
    00024 ** In addition, as a special exception, Nokia gives you certain additional
    00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
    00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
    00027 **
    00028 ** GNU General Public License Usage
    00029 ** Alternatively, this file may be used under the terms of the GNU
    00030 ** General Public License version 3.0 as published by the Free Software
    00031 ** Foundation and appearing in the file LICENSE.GPL included in the
    00032 ** packaging of this file.  Please review the following information to
    00033 ** ensure the GNU General Public License version 3.0 requirements will be
    00034 ** met: http://www.gnu.org/copyleft/gpl.html.
    00035 **
    00036 ** If you have questions regarding the use of this file, please contact
    00037 ** Nokia at qt-info@nokia.com.
    00038 ** $QT_END_LICENSE$
    00039 **
    00040 ****************************************************************************/
    00041
    00042
    00043 #ifndef QSSLCERTIFICATE_H
    00044 #define QSSLCERTIFICATE_H
    00045
    00046 #include <QtCore/qnamespace.h>
    00047 #include <QtCore/qbytearray.h>
    00048 #include <QtCore/qcryptographichash.h>
    00049 #include <QtCore/qregexp.h>
    00050 #include <QtCore/qsharedpointer.h>
    00051 #include <QtNetwork/qssl.h>
    00052
    00053 typedef struct x509_st X509; // ### check if this works
    00054
    00055 QT_BEGIN_HEADER
    00056
    00057 QT_BEGIN_NAMESPACE
    00058
    00059 QT_MODULE(Network)
    00060
    00061 #ifndef QT_NO_OPENSSL
    00062
    00063 class QDateTime;
    00064 class QIODevice;
    00065 class QSslKey;
    00066 class QStringList;
    00067 template <typename T, typename U> class QMultiMap;
    00068
    00069 class QSslCertificatePrivate;
    00070 class Q_NETWORK_EXPORT QSslCertificate
    00071 {
    00072 public:
    00073     enum SubjectInfo {
    00074         Organization,
    00075         CommonName,
    00076         LocalityName,
    00077         OrganizationalUnitName,
    00078         CountryName,
    00079         StateOrProvinceName
    00080     };
    00081
    00082     QSslCertificate(QIODevice *device, QSsl::EncodingFormat format = QSsl::Pem);
    00083     QSslCertificate( // ### s/encoded/data (to be consistent with signature in .cpp file) ?
    00084         const QByteArray &encoded = QByteArray(), QSsl::EncodingFormat format = QSsl::Pem);
    00085     QSslCertificate(const QSslCertificate &other);
    00086     ~QSslCertificate();
    00087     QSslCertificate &operator=(const QSslCertificate &other);
    00088     bool operator==(const QSslCertificate &other) const;
    00089     inline bool operator!=(const QSslCertificate &other) const { return !operator==(other); }
    00090
    00091     bool isNull() const;
    00092     bool isValid() const;
    00093     void clear();
    00094
    00095     // Certificate info
    00096     QByteArray version() const;
    00097     QByteArray serialNumber() const;
    00098     QByteArray digest(QCryptographicHash::Algorithm algorithm = QCryptographicHash::Md5) const;
    00099     QString issuerInfo(SubjectInfo info) const;
    00100     QString issuerInfo(const QByteArray &tag) const;
    00101     QString subjectInfo(SubjectInfo info) const;
    00102     QString subjectInfo(const QByteArray &tag) const;
    00103     QMultiMap<QSsl::AlternateNameEntryType, QString> alternateSubjectNames() const;
    00104     QDateTime effectiveDate() const;
    00105     QDateTime expiryDate() const;
    00106     QSslKey publicKey() const;
    00107
    00108     QByteArray toPem() const;
    00109     QByteArray toDer() const;
    00110
    00111     static QList<QSslCertificate> fromPath(
    00112         const QString &path, QSsl::EncodingFormat format = QSsl::Pem,
    00113         QRegExp::PatternSyntax syntax = QRegExp::FixedString);
    00114     static QList<QSslCertificate> fromDevice(
    00115         QIODevice *device, QSsl::EncodingFormat format = QSsl::Pem);
    00116     static QList<QSslCertificate> fromData(
    00117         const QByteArray &data, QSsl::EncodingFormat format = QSsl::Pem);
    00118
    00119     Qt::HANDLE handle() const;
    00120
    00121 private:
    00122     QExplicitlySharedDataPointer<QSslCertificatePrivate> d;
    00123     friend class QSslCertificatePrivate;
    00124     friend class QSslSocketBackendPrivate;
    00125 };
    00126
    00127 #ifndef QT_NO_DEBUG_STREAM
    00128 class QDebug;
    00129 Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, const QSslCertificate &certificate);
    00130 Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, QSslCertificate::SubjectInfo info);
    00131 #endif
    00132
    00133 #endif // QT_NO_OPENSSL
    00134
    00135 QT_END_NAMESPACE
    00136
    00137 QT_END_HEADER
    00138
    00139 #endif