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>
This commit is contained in:
parent
eb54646984
commit
45c0f45e04
@ -175,5 +175,72 @@ Q_LOGGING_CATEGORY(lcSsl, "qt.network.ssl");
|
|||||||
backend in use.
|
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
|
QT_END_NAMESPACE
|
||||||
|
@ -105,6 +105,50 @@ namespace QSsl {
|
|||||||
SslOptionDisableServerCipherPreference = 0x80
|
SslOptionDisableServerCipherPreference = 0x80
|
||||||
};
|
};
|
||||||
Q_DECLARE_FLAGS(SslOptions, SslOption)
|
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)
|
Q_DECLARE_OPERATORS_FOR_FLAGS(QSsl::SslOptions)
|
||||||
|
@ -227,74 +227,6 @@
|
|||||||
\sa QSslSocket::peerVerifyMode()
|
\sa QSslSocket::peerVerifyMode()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
|
||||||
\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()
|
\fn void QSslSocket::encrypted()
|
||||||
|
|
||||||
|
@ -61,49 +61,6 @@ class QSslEllipticCurve;
|
|||||||
class QSslPreSharedKeyAuthenticator;
|
class QSslPreSharedKeyAuthenticator;
|
||||||
class QOcspResponse;
|
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 QSslSocketPrivate;
|
||||||
class Q_NETWORK_EXPORT QSslSocket : public QTcpSocket
|
class Q_NETWORK_EXPORT QSslSocket : public QTcpSocket
|
||||||
{
|
{
|
||||||
@ -225,8 +182,8 @@ Q_SIGNALS:
|
|||||||
void encryptedBytesWritten(qint64 totalBytes);
|
void encryptedBytesWritten(qint64 totalBytes);
|
||||||
void preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator *authenticator);
|
void preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator *authenticator);
|
||||||
void newSessionTicketReceived();
|
void newSessionTicketReceived();
|
||||||
void alertSent(QAlertLevel level, QAlertType type, const QString &description);
|
void alertSent(QSsl::AlertLevel level, QSsl::AlertType type, const QString &description);
|
||||||
void alertReceived(QAlertLevel level, QAlertType type, const QString &description);
|
void alertReceived(QSsl::AlertLevel level, QSsl::AlertType type, const QString &description);
|
||||||
void handshakeInterruptedOnError(const QSslError &error);
|
void handshakeInterruptedOnError(const QSslError &error);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -100,21 +100,23 @@ QT_BEGIN_NAMESPACE
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
QAlertLevel tlsAlertLevel(int value)
|
QSsl::AlertLevel tlsAlertLevel(int value)
|
||||||
{
|
{
|
||||||
|
using QSsl::AlertLevel;
|
||||||
|
|
||||||
if (const char *typeString = q_SSL_alert_type_string(value)) {
|
if (const char *typeString = q_SSL_alert_type_string(value)) {
|
||||||
// Documented to return 'W' for warning, 'F' for fatal,
|
// Documented to return 'W' for warning, 'F' for fatal,
|
||||||
// 'U' for unknown.
|
// 'U' for unknown.
|
||||||
switch (typeString[0]) {
|
switch (typeString[0]) {
|
||||||
case 'W':
|
case 'W':
|
||||||
return QAlertLevel::Warning;
|
return AlertLevel::Warning;
|
||||||
case 'F':
|
case 'F':
|
||||||
return QAlertLevel::Fatal;
|
return AlertLevel::Fatal;
|
||||||
default:;
|
default:;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return QAlertLevel::Unknown;
|
return AlertLevel::Unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString tlsAlertDescription(int value)
|
QString tlsAlertDescription(int value)
|
||||||
@ -125,13 +127,13 @@ QString tlsAlertDescription(int value)
|
|||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
QAlertType tlsAlertType(int value)
|
QSsl::AlertType tlsAlertType(int value)
|
||||||
{
|
{
|
||||||
// In case for some reason openssl gives us a value,
|
// In case for some reason openssl gives us a value,
|
||||||
// which is not in our enum actually, we leave it to
|
// which is not in our enum actually, we leave it to
|
||||||
// an application to handle (supposedly they have
|
// an application to handle (supposedly they have
|
||||||
// if or switch-statements).
|
// if or switch-statements).
|
||||||
return QAlertType(value & 0xff);
|
return QSsl::AlertType(value & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
@ -1970,7 +1972,7 @@ void QSslSocketBackendPrivate::alertMessageSent(int value)
|
|||||||
Q_Q(QSslSocket);
|
Q_Q(QSslSocket);
|
||||||
|
|
||||||
const auto level = tlsAlertLevel(value);
|
const auto level = tlsAlertLevel(value);
|
||||||
if (level == QAlertLevel::Fatal && !connectionEncrypted) {
|
if (level == QSsl::AlertLevel::Fatal && !connectionEncrypted) {
|
||||||
// Note, this logic is handshake-time only:
|
// Note, this logic is handshake-time only:
|
||||||
pendingFatalAlert = true;
|
pendingFatalAlert = true;
|
||||||
}
|
}
|
||||||
|
@ -341,8 +341,6 @@ tst_QSslSocket::tst_QSslSocket()
|
|||||||
qRegisterMetaType<QSslError>("QSslError");
|
qRegisterMetaType<QSslError>("QSslError");
|
||||||
qRegisterMetaType<QAbstractSocket::SocketState>("QAbstractSocket::SocketState");
|
qRegisterMetaType<QAbstractSocket::SocketState>("QAbstractSocket::SocketState");
|
||||||
qRegisterMetaType<QAbstractSocket::SocketError>("QAbstractSocket::SocketError");
|
qRegisterMetaType<QAbstractSocket::SocketError>("QAbstractSocket::SocketError");
|
||||||
qRegisterMetaType<QAlertLevel>("QAlertLevel");
|
|
||||||
qRegisterMetaType<QAlertType>("QAlertType");
|
|
||||||
|
|
||||||
#ifndef QT_NO_OPENSSL
|
#ifndef QT_NO_OPENSSL
|
||||||
qRegisterMetaType<QSslPreSharedKeyAuthenticator *>();
|
qRegisterMetaType<QSslPreSharedKeyAuthenticator *>();
|
||||||
@ -1202,8 +1200,8 @@ public:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void socketError(QAbstractSocket::SocketError);
|
void socketError(QAbstractSocket::SocketError);
|
||||||
void gotAlert(QAlertLevel level, QAlertType type, const QString &message);
|
void gotAlert(QSsl::AlertLevel level, QSsl::AlertType type, const QString &message);
|
||||||
void alertSent(QAlertLevel level, QAlertType type, const QString &message);
|
void alertSent(QSsl::AlertLevel level, QSsl::AlertType type, const QString &message);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void incomingConnection(qintptr socketDescriptor)
|
void incomingConnection(qintptr socketDescriptor)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user