1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QX509CERTIFICATE_BASE_P_H
5#define QX509CERTIFICATE_BASE_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtNetwork/private/qtnetworkglobal_p.h>
19
20#include <QtNetwork/private/qtlsbackend_p.h>
21
22#include <QtNetwork/qssl.h>
23
24#include <QtCore/qbytearray.h>
25#include <QtCore/qstring.h>
26#include <QtCore/qglobal.h>
27#include <QtCore/qlist.h>
28
29QT_BEGIN_NAMESPACE
30
31namespace QTlsPrivate {
32
33class X509CertificateBase : public X509Certificate
34{
35public:
36 bool isNull() const override;
37 QByteArray version() const override;
38 QByteArray serialNumber() const override;
39 QStringList issuerInfo(QSslCertificate::SubjectInfo info) const override;
40 QStringList issuerInfo(const QByteArray &attribute) const override;
41 QStringList subjectInfo(QSslCertificate::SubjectInfo info) const override;
42 QStringList subjectInfo(const QByteArray &attribute) const override;
43 QList<QByteArray> subjectInfoAttributes() const override;
44 QList<QByteArray> issuerInfoAttributes() const override;
45 QDateTime effectiveDate() const override;
46 QDateTime expiryDate() const override;
47
48 qsizetype numberOfExtensions() const override;
49 QString oidForExtension(qsizetype index) const override;
50 QString nameForExtension(qsizetype index) const override;
51 QVariant valueForExtension(qsizetype index) const override;
52 bool isExtensionCritical(qsizetype index) const override;
53 bool isExtensionSupported(qsizetype index) const override;
54
55 static QByteArray subjectInfoToString(QSslCertificate::SubjectInfo info);
56 static bool matchLineFeed(const QByteArray &pem, int *offset);
57
58protected:
59 bool validIndex(qsizetype index) const
60 {
61 return index >= 0 && index < extensions.size();
62 }
63
64 bool null = true;
65 QByteArray versionString;
66 QByteArray serialNumberString;
67
68 QMultiMap<QByteArray, QString> issuerInfoEntries;
69 QMultiMap<QByteArray, QString> subjectInfoEntries;
70 QDateTime notValidAfter;
71 QDateTime notValidBefore;
72
73 struct X509CertificateExtension
74 {
75 QString oid;
76 QString name;
77 QVariant value;
78 bool critical = false;
79 bool supported = false;
80 };
81
82 QList<X509CertificateExtension> extensions;
83};
84
85} // namespace QTlsPrivate
86
87QT_END_NAMESPACE
88
89#endif // QX509CERTIFICATE_BASE_P_H
90

source code of qtbase/src/plugins/tls/shared/qx509_base_p.h