summaryrefslogtreecommitdiffstats
path: root/src/plugins/tls/openssl/qx509_openssl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/tls/openssl/qx509_openssl.cpp')
-rw-r--r--src/plugins/tls/openssl/qx509_openssl.cpp67
1 files changed, 17 insertions, 50 deletions
diff --git a/src/plugins/tls/openssl/qx509_openssl.cpp b/src/plugins/tls/openssl/qx509_openssl.cpp
index b7c2e7cff4..0cd3749f88 100644
--- a/src/plugins/tls/openssl/qx509_openssl.cpp
+++ b/src/plugins/tls/openssl/qx509_openssl.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtNetwork module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qsslsocket_openssl_symbols_p.h"
#include "qtlsbackend_openssl_p.h"
@@ -48,15 +12,18 @@
#include <QtNetwork/qsslsocket.h>
#include <QtNetwork/qhostaddress.h>
-#include <QtCore/qvarlengtharray.h>
-#include <QtCore/qscopeguard.h>
-#include <QtCore/qdatetime.h>
-#include <QtCore/qiodevice.h>
#include <QtCore/qendian.h>
+#include <QtCore/qdatetime.h>
#include <QtCore/qhash.h>
+#include <QtCore/qiodevice.h>
+#include <QtCore/qscopeguard.h>
+#include <QtCore/qtimezone.h>
+#include <QtCore/qvarlengtharray.h>
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
namespace QTlsPrivate {
namespace {
@@ -111,7 +78,7 @@ QDateTime dateTimeFromASN1(const ASN1_TIME *aTime)
if (q_ASN1_TIME_to_tm(aTime, &lTime)) {
QDate resDate(lTime.tm_year + 1900, lTime.tm_mon + 1, lTime.tm_mday);
QTime resTime(lTime.tm_hour, lTime.tm_min, lTime.tm_sec);
- result = QDateTime(resDate, resTime, Qt::UTC);
+ result = QDateTime(resDate, resTime, QTimeZone::UTC);
}
return result;
@@ -305,9 +272,9 @@ QVariant x509ExtensionToValue(X509_EXTENSION *ext)
if (!basic)
return {};
QVariantMap result;
- result[QLatin1String("ca")] = basic->ca ? true : false;
+ result["ca"_L1] = basic->ca ? true : false;
if (basic->pathlen)
- result[QLatin1String("pathLenConstraint")] = (qlonglong)q_ASN1_INTEGER_get(basic->pathlen);
+ result["pathLenConstraint"_L1] = (qlonglong)q_ASN1_INTEGER_get(basic->pathlen);
q_BASIC_CONSTRAINTS_free(basic);
return result;
@@ -364,7 +331,7 @@ QVariant x509ExtensionToValue(X509_EXTENSION *ext)
if (auth_key->keyid) {
QByteArray keyid(reinterpret_cast<const char *>(auth_key->keyid->data),
auth_key->keyid->length);
- result[QLatin1String("keyid")] = keyid.toHex();
+ result["keyid"_L1] = keyid.toHex();
}
// issuer
@@ -372,7 +339,7 @@ QVariant x509ExtensionToValue(X509_EXTENSION *ext)
// serial
if (auth_key->serial)
- result[QLatin1String("serial")] = (qlonglong)q_ASN1_INTEGER_get(auth_key->serial);
+ result["serial"_L1] = (qlonglong)q_ASN1_INTEGER_get(auth_key->serial);
q_AUTHORITY_KEYID_free(auth_key);
return result;
@@ -650,7 +617,7 @@ QList<QSslError> X509CertificateOpenSSL::verify(const QList<QSslCertificate> &ca
const QString &hostName)
{
// This was previously QSslSocketPrivate::verify().
- if (certificateChain.count() <= 0)
+ if (certificateChain.size() <= 0)
return {QSslError(QSslError::UnspecifiedError)};
QList<QSslError> errors;
@@ -692,7 +659,7 @@ QList<QSslError> X509CertificateOpenSSL::verify(const QList<QSslCertificate> &ca
// Build the chain of intermediate certificates
STACK_OF(X509) *intermediates = nullptr;
- if (certificateChain.length() > 1) {
+ if (certificateChain.size() > 1) {
intermediates = (STACK_OF(X509) *) q_OPENSSL_sk_new_null();
if (!intermediates) {
@@ -744,7 +711,7 @@ QList<QSslError> X509CertificateOpenSSL::verify(const QList<QSslCertificate> &ca
// Translate errors from the error list into QSslErrors.
errors.reserve(errors.size() + lastErrors.size());
- for (const auto &error : qAsConst(lastErrors))
+ for (const auto &error : std::as_const(lastErrors))
errors << openSSLErrorToQSslError(error.code, certificateChain.value(error.depth));
return errors;