From 68447f036f5975ad1dc1f0d5e01005c1038b92ee Mon Sep 17 00:00:00 2001 From: Zhi Guan Date: Wed, 31 Jan 2024 21:37:53 +0800 Subject: [PATCH] Update alert in tls.c --- include/gmssl/tls.h | 1 + src/tls.c | 27 ++++++++++++++++++--------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/include/gmssl/tls.h b/include/gmssl/tls.h index d02ad094..4c694d07 100644 --- a/include/gmssl/tls.h +++ b/include/gmssl/tls.h @@ -309,6 +309,7 @@ typedef enum { typedef enum { + TLS_alert_level_undefined = 0, TLS_alert_level_warning = 1, TLS_alert_level_fatal = 2, } TLS_ALERT_LEVEL; diff --git a/src/tls.c b/src/tls.c index d85e260a..d6a709ac 100644 --- a/src/tls.c +++ b/src/tls.c @@ -1,5 +1,5 @@ /* - * Copyright 2014-2022 The GmSSL Project. All Rights Reserved. + * Copyright 2014-2024 The GmSSL Project. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the License); you may * not use this file except in compliance with the License. @@ -1641,17 +1641,26 @@ int tls_send_alert(TLS_CONNECT *conn, int alert) int tls_alert_level(int alert) { switch (alert) { - case TLS_alert_bad_certificate: - case TLS_alert_unsupported_certificate: - case TLS_alert_certificate_revoked: - case TLS_alert_certificate_expired: - case TLS_alert_certificate_unknown: - return 0; + case TLS_alert_unexpected_message: + case TLS_alert_bad_record_mac: + case TLS_alert_record_overflow: + case TLS_alert_decompression_failure: + case TLS_alert_handshake_failure: + case TLS_alert_illegal_parameter: + case TLS_alert_unknown_ca: + case TLS_alert_access_denied: + case TLS_alert_decode_error: + case TLS_alert_decrypt_error: + case TLS_alert_protocol_version: + case TLS_alert_insufficient_security: + case TLS_alert_internal_error: + case TLS_alert_unsupported_extension: + return TLS_alert_level_fatal; case TLS_alert_user_canceled: case TLS_alert_no_renegotiation: - return TLS_alert_level_warning; + return TLS_alert_level_warning; } - return TLS_alert_level_fatal; + return TLS_alert_level_undefined; } int tls_send_warning(TLS_CONNECT *conn, int alert)