| 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 | #ifndef QX509_GENERIC_P_H |
| 4 | #define QX509_GENERIC_P_H |
| 5 | |
| 6 | // |
| 7 | // W A R N I N G |
| 8 | // ------------- |
| 9 | // |
| 10 | // This file is not part of the Qt API. It exists purely as an |
| 11 | // implementation detail. This header file may change from version to |
| 12 | // version without notice, or even be removed. |
| 13 | // |
| 14 | // We mean it. |
| 15 | // |
| 16 | |
| 17 | #include <QtNetwork/private/qtnetworkglobal_p.h> |
| 18 | |
| 19 | #include <QtNetwork/private/qtlsbackend_p.h> |
| 20 | |
| 21 | #include "qx509_base_p.h" |
| 22 | |
| 23 | #include <QtCore/qbytearray.h> |
| 24 | #include <QtCore/qglobal.h> |
| 25 | |
| 26 | QT_BEGIN_NAMESPACE |
| 27 | |
| 28 | namespace QTlsPrivate { |
| 29 | |
| 30 | // A part of SecureTransport and Schannel plugin. |
| 31 | class X509CertificateGeneric : public X509CertificateBase |
| 32 | { |
| 33 | public: |
| 34 | bool isEqual(const X509Certificate &rhs) const override; |
| 35 | bool isSelfSigned() const override; |
| 36 | |
| 37 | QMultiMap<QSsl::AlternativeNameEntryType, QString> subjectAlternativeNames() const override; |
| 38 | QByteArray toPem() const override; |
| 39 | QByteArray toDer() const override; |
| 40 | QString toText() const override; |
| 41 | Qt::HANDLE handle() const override; |
| 42 | |
| 43 | size_t hash(size_t seed) const noexcept override; |
| 44 | |
| 45 | static QList<QSslCertificate> certificatesFromPem(const QByteArray &pem, int count); |
| 46 | static QList<QSslCertificate> certificatesFromDer(const QByteArray &der, int count); |
| 47 | |
| 48 | protected: |
| 49 | |
| 50 | bool subjectMatchesIssuer = false; |
| 51 | QSsl::KeyAlgorithm publicKeyAlgorithm = QSsl::Rsa; |
| 52 | QByteArray publicKeyDerData; |
| 53 | |
| 54 | QMultiMap<QSsl::AlternativeNameEntryType, QString> saNames; |
| 55 | QByteArray derData; |
| 56 | |
| 57 | bool parse(const QByteArray &data); |
| 58 | bool parseExtension(const QByteArray &data, X509CertificateExtension &extension); |
| 59 | }; |
| 60 | |
| 61 | } // namespace QTlsPrivate |
| 62 | |
| 63 | QT_END_NAMESPACE |
| 64 | |
| 65 | #endif // QX509_GENERIC_P_H |
| 66 |
