source: trunk/src/network/ssl/qsslcertificate.h@ 64

Last change on this file since 64 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 4.7 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information ([email protected])
5**
6** This file is part of the QtNetwork module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial Usage
10** Licensees holding valid Qt Commercial licenses may use this file in
11** accordance with the Qt Commercial License Agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Nokia.
14**
15** GNU Lesser General Public License Usage
16** Alternatively, this file may be used under the terms of the GNU Lesser
17** General Public License version 2.1 as published by the Free Software
18** Foundation and appearing in the file LICENSE.LGPL included in the
19** packaging of this file. Please review the following information to
20** ensure the GNU Lesser General Public License version 2.1 requirements
21** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22**
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.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you are unsure which license is appropriate for your use, please
37** contact the sales department at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42
43#ifndef QSSLCERTIFICATE_H
44#define QSSLCERTIFICATE_H
45
46#include <QtCore/qnamespace.h>
47#include <QtCore/qbytearray.h>
48#include <QtCore/qcryptographichash.h>
49#include <QtCore/qregexp.h>
50#include <QtNetwork/qssl.h>
51
52typedef struct x509_st X509; // ### check if this works
53
54QT_BEGIN_HEADER
55
56QT_BEGIN_NAMESPACE
57
58QT_MODULE(Network)
59
60#ifndef QT_NO_OPENSSL
61
62class QDateTime;
63class QIODevice;
64class QSslKey;
65class QStringList;
66template <typename T, typename U> class QMultiMap;
67
68class QSslCertificatePrivate;
69class Q_NETWORK_EXPORT QSslCertificate
70{
71public:
72 enum SubjectInfo {
73 Organization,
74 CommonName,
75 LocalityName,
76 OrganizationalUnitName,
77 CountryName,
78 StateOrProvinceName
79 };
80
81 QSslCertificate(QIODevice *device, QSsl::EncodingFormat format = QSsl::Pem);
82 QSslCertificate( // ### s/encoded/data (to be consistent with signature in .cpp file) ?
83 const QByteArray &encoded = QByteArray(), QSsl::EncodingFormat format = QSsl::Pem);
84 QSslCertificate(const QSslCertificate &other);
85 ~QSslCertificate();
86 QSslCertificate &operator=(const QSslCertificate &other);
87 bool operator==(const QSslCertificate &other) const;
88 inline bool operator!=(const QSslCertificate &other) const { return !operator==(other); }
89
90 bool isNull() const;
91 bool isValid() const;
92 void clear();
93
94 // Certificate info
95 QByteArray version() const;
96 QByteArray serialNumber() const;
97 QByteArray digest(QCryptographicHash::Algorithm algorithm = QCryptographicHash::Md5) const;
98 QString issuerInfo(SubjectInfo info) const;
99 QString issuerInfo(const QByteArray &tag) const;
100 QString subjectInfo(SubjectInfo info) const;
101 QString subjectInfo(const QByteArray &tag) const;
102 QMultiMap<QSsl::AlternateNameEntryType, QString> alternateSubjectNames() const;
103 QDateTime effectiveDate() const;
104 QDateTime expiryDate() const;
105 QSslKey publicKey() const;
106
107 QByteArray toPem() const;
108 QByteArray toDer() const;
109
110 static QList<QSslCertificate> fromPath(
111 const QString &path, QSsl::EncodingFormat format = QSsl::Pem,
112 QRegExp::PatternSyntax syntax = QRegExp::FixedString);
113 static QList<QSslCertificate> fromDevice(
114 QIODevice *device, QSsl::EncodingFormat format = QSsl::Pem);
115 static QList<QSslCertificate> fromData(
116 const QByteArray &data, QSsl::EncodingFormat format = QSsl::Pem);
117
118 Qt::HANDLE handle() const;
119
120private:
121 QSslCertificatePrivate *d;
122 friend class QSslCertificatePrivate;
123 friend class QSslSocketBackendPrivate;
124};
125
126#ifndef QT_NO_DEBUG_STREAM
127class QDebug;
128Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, const QSslCertificate &certificate);
129Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, QSslCertificate::SubjectInfo info);
130#endif
131
132#endif // QT_NO_OPENSSL
133
134QT_END_NAMESPACE
135
136QT_END_HEADER
137
138#endif
Note: See TracBrowser for help on using the repository browser.