summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorTimur Pocheptsov <timur.pocheptsov@qt.io>2020-06-25 10:44:57 +0200
committerTimur Pocheptsov <timur.pocheptsov@qt.io>2020-06-29 17:08:13 +0200
commit45c0f45e04f4c8431c2744dd52d334ee2e127019 (patch)
tree89f1a8d57737bac823de0cbb67479626af67fdc6 /src/network
parenteb546469849d2bf560f41b14366832e1f8b22456 (diff)
Move QAlertLevel and QAlertType enums into the namespace QSsl
Not to pollute the global namespace with rather generic names (especially in case QT_NAMESPACE is none); also drop the (now)redundant 'Q' prefix in the names. Change-Id: I57ea7e3996cced705f7ddbdbc1e0231191b31c43 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/network')
-rw-r--r--src/network/ssl/qssl.cpp67
-rw-r--r--src/network/ssl/qssl.h44
-rw-r--r--src/network/ssl/qsslsocket.cpp68
-rw-r--r--src/network/ssl/qsslsocket.h47
-rw-r--r--src/network/ssl/qsslsocket_openssl.cpp16
5 files changed, 122 insertions, 120 deletions
diff --git a/src/network/ssl/qssl.cpp b/src/network/ssl/qssl.cpp
index 4482e8862b..ffa211630e 100644
--- a/src/network/ssl/qssl.cpp
+++ b/src/network/ssl/qssl.cpp
@@ -175,5 +175,72 @@ Q_LOGGING_CATEGORY(lcSsl, "qt.network.ssl");
backend in use.
*/
+/*!
+ \enum QSsl::AlertLevel
+ \brief Describes the level of an alert message
+ \relates QSslSocket
+ \since 6.0
+
+ \ingroup network
+ \ingroup ssl
+ \inmodule QtNetwork
+
+ This enum describes the level of an alert message that was sent
+ or received.
+
+ \value Warning Non-fatal alert message
+ \value Fatal Fatal alert message, the underlying backend will
+ handle such an alert properly and close the connection.
+ \value Unknown An alert of unknown level of severity.
+*/
+
+/*!
+ \enum QSsl::AlertType
+ \brief Enumerates possible codes that an alert message can have
+ \relates QSslSocket
+ \since 6.0
+
+ \ingroup network
+ \ingroup ssl
+ \inmodule QtNetwork
+
+ See \l{https://tools.ietf.org/html/rfc8446#page-85}{RFC 8446, section 6}
+ for the possible values and their meaning.
+
+ \value CloseNotify,
+ \value UnexpectedMessage
+ \value BadRecordMac
+ \value RecordOverflow
+ \value DecompressionFailure
+ \value HandshakeFailure
+ \value NoCertificate
+ \value BadCertificate
+ \value UnsupportedCertificate
+ \value CertificateRevoked
+ \value CertificateExpired
+ \value CertificateUnknown
+ \value IllegalParameter
+ \value UnknownCa
+ \value AccessDenied
+ \value DecodeError
+ \value DecryptError
+ \value ExportRestriction
+ \value ProtocolVersion
+ \value InsufficientSecurity
+ \value InternalError
+ \value InappropriateFallback
+ \value UserCancelled
+ \value NoRenegotiation
+ \value MissingExtension
+ \value UnsupportedExtension
+ \value CertificateUnobtainable
+ \value UnrecognizedName
+ \value BadCertificateStatusResponse
+ \value BadCertificateHashValue
+ \value UnknownPskIdentity
+ \value CertificateRequired
+ \value NoApplicationProtocol
+ \value UnknownAlertMessage
+*/
QT_END_NAMESPACE
diff --git a/src/network/ssl/qssl.h b/src/network/ssl/qssl.h
index d0b417f9ed..cb0871fff6 100644
--- a/src/network/ssl/qssl.h
+++ b/src/network/ssl/qssl.h
@@ -105,6 +105,50 @@ namespace QSsl {
SslOptionDisableServerCipherPreference = 0x80
};
Q_DECLARE_FLAGS(SslOptions, SslOption)
+
+ enum class AlertLevel {
+ Warning,
+ Fatal,
+ Unknown
+ };
+
+ enum class AlertType {
+ CloseNotify,
+ UnexpectedMessage = 10,
+ BadRecordMac = 20,
+ RecordOverflow = 22,
+ DecompressionFailure = 30, // reserved
+ HandshakeFailure = 40,
+ NoCertificate = 41, // reserved
+ BadCertificate = 42,
+ UnsupportedCertificate = 43,
+ CertificateRevoked = 44,
+ CertificateExpired = 45,
+ CertificateUnknown = 46,
+ IllegalParameter = 47,
+ UnknownCa = 48,
+ AccessDenied = 49,
+ DecodeError = 50,
+ DecryptError = 51,
+ ExportRestriction = 60, // reserved
+ ProtocolVersion = 70,
+ InsufficientSecurity = 71,
+ InternalError = 80,
+ InappropriateFallback = 86,
+ UserCancelled = 90,
+ NoRenegotiation = 100,
+ MissingExtension = 109,
+ UnsupportedExtension = 110,
+ CertificateUnobtainable = 111, // reserved
+ UnrecognizedName = 112,
+ BadCertificateStatusResponse = 113,
+ BadCertificateHashValue = 114, // reserved
+ UnknownPskIdentity = 115,
+ CertificateRequired = 116,
+ NoApplicationProtocol = 120,
+ UnknownAlertMessage = 255
+ };
+
}
Q_DECLARE_OPERATORS_FOR_FLAGS(QSsl::SslOptions)
diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp
index 234cdeea14..9af8f2a9dc 100644
--- a/src/network/ssl/qsslsocket.cpp
+++ b/src/network/ssl/qsslsocket.cpp
@@ -228,74 +228,6 @@
*/
/*!
- \enum QAlertLevel
- \brief Describes the level of an alert message
- \relates QSslSocket
- \since 6.0
-
- \ingroup network
- \ingroup ssl
- \inmodule QtNetwork
-
- This enum describes the level of an alert message that was sent
- or received.
-
- \value Warning Non-fatal alert message
- \value Fatal Fatal alert message, the underlying backend will
- handle such an alert properly and close the connection.
- \value Unknown An alert of unknown level of severity.
-*/
-
-/*!
- \enum QAlertType
- \brief Enumerates possible codes that an alert message can have
- \relates QSslSocket
- \since 6.0
-
- \ingroup network
- \ingroup ssl
- \inmodule QtNetwork
-
- See \l{https://tools.ietf.org/html/rfc8446#page-85}{RFC 8446, section 6}
- for the possible values and their meaning.
-
- \value CloseNotify,
- \value UnexpectedMessage
- \value BadRecordMac
- \value RecordOverflow
- \value DecompressionFailure
- \value HandshakeFailure
- \value NoCertificate
- \value BadCertificate
- \value UnsupportedCertificate
- \value CertificateRevoked
- \value CertificateExpired
- \value CertificateUnknown
- \value IllegalParameter
- \value UnknownCa
- \value AccessDenied
- \value DecodeError
- \value DecryptError
- \value ExportRestriction
- \value ProtocolVersion
- \value InsufficientSecurity
- \value InternalError
- \value InappropriateFallback
- \value UserCancelled
- \value NoRenegotiation
- \value MissingExtension
- \value UnsupportedExtension
- \value CertificateUnobtainable
- \value UnrecognizedName
- \value BadCertificateStatusResponse
- \value BadCertificateHashValue
- \value UnknownPskIdentity
- \value CertificateRequired
- \value NoApplicationProtocol
- \value UnknownAlertMessage
-*/
-
-/*!
\fn void QSslSocket::encrypted()
This signal is emitted when QSslSocket enters encrypted mode. After this
diff --git a/src/network/ssl/qsslsocket.h b/src/network/ssl/qsslsocket.h
index 9906db54fe..3408e36197 100644
--- a/src/network/ssl/qsslsocket.h
+++ b/src/network/ssl/qsslsocket.h
@@ -61,49 +61,6 @@ class QSslEllipticCurve;
class QSslPreSharedKeyAuthenticator;
class QOcspResponse;
-enum class QAlertLevel {
- Warning,
- Fatal,
- Unknown
-};
-
-enum class QAlertType {
- CloseNotify,
- UnexpectedMessage = 10,
- BadRecordMac = 20,
- RecordOverflow = 22,
- DecompressionFailure = 30, // reserved
- HandshakeFailure = 40,
- NoCertificate = 41, // reserved
- BadCertificate = 42,
- UnsupportedCertificate = 43,
- CertificateRevoked = 44,
- CertificateExpired = 45,
- CertificateUnknown = 46,
- IllegalParameter = 47,
- UnknownCa = 48,
- AccessDenied = 49,
- DecodeError = 50,
- DecryptError = 51,
- ExportRestriction = 60, // reserved
- ProtocolVersion = 70,
- InsufficientSecurity = 71,
- InternalError = 80,
- InappropriateFallback = 86,
- UserCancelled = 90,
- NoRenegotiation = 100,
- MissingExtension = 109,
- UnsupportedExtension = 110,
- CertificateUnobtainable = 111, // reserved
- UnrecognizedName = 112,
- BadCertificateStatusResponse = 113,
- BadCertificateHashValue = 114, // reserved
- UnknownPskIdentity = 115,
- CertificateRequired = 116,
- NoApplicationProtocol = 120,
- UnknownAlertMessage = 255
-};
-
class QSslSocketPrivate;
class Q_NETWORK_EXPORT QSslSocket : public QTcpSocket
{
@@ -225,8 +182,8 @@ Q_SIGNALS:
void encryptedBytesWritten(qint64 totalBytes);
void preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator *authenticator);
void newSessionTicketReceived();
- void alertSent(QAlertLevel level, QAlertType type, const QString &description);
- void alertReceived(QAlertLevel level, QAlertType type, const QString &description);
+ void alertSent(QSsl::AlertLevel level, QSsl::AlertType type, const QString &description);
+ void alertReceived(QSsl::AlertLevel level, QSsl::AlertType type, const QString &description);
void handshakeInterruptedOnError(const QSslError &error);
protected:
diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp
index 2f18501f83..8a9bc47fb0 100644
--- a/src/network/ssl/qsslsocket_openssl.cpp
+++ b/src/network/ssl/qsslsocket_openssl.cpp
@@ -100,21 +100,23 @@ QT_BEGIN_NAMESPACE
namespace {
-QAlertLevel tlsAlertLevel(int value)
+QSsl::AlertLevel tlsAlertLevel(int value)
{
+ using QSsl::AlertLevel;
+
if (const char *typeString = q_SSL_alert_type_string(value)) {
// Documented to return 'W' for warning, 'F' for fatal,
// 'U' for unknown.
switch (typeString[0]) {
case 'W':
- return QAlertLevel::Warning;
+ return AlertLevel::Warning;
case 'F':
- return QAlertLevel::Fatal;
+ return AlertLevel::Fatal;
default:;
}
}
- return QAlertLevel::Unknown;
+ return AlertLevel::Unknown;
}
QString tlsAlertDescription(int value)
@@ -125,13 +127,13 @@ QString tlsAlertDescription(int value)
return description;
}
-QAlertType tlsAlertType(int value)
+QSsl::AlertType tlsAlertType(int value)
{
// In case for some reason openssl gives us a value,
// which is not in our enum actually, we leave it to
// an application to handle (supposedly they have
// if or switch-statements).
- return QAlertType(value & 0xff);
+ return QSsl::AlertType(value & 0xff);
}
#ifdef Q_OS_WIN
@@ -1970,7 +1972,7 @@ void QSslSocketBackendPrivate::alertMessageSent(int value)
Q_Q(QSslSocket);
const auto level = tlsAlertLevel(value);
- if (level == QAlertLevel::Fatal && !connectionEncrypted) {
+ if (level == QSsl::AlertLevel::Fatal && !connectionEncrypted) {
// Note, this logic is handshake-time only:
pendingFatalAlert = true;
}