8#include <botan/tls_alert.h>
10#include <botan/tls_exceptn.h>
16 throw Decoding_Error(
"Bad size (" + std::to_string(buf.size()) +
") for TLS alert message");
21 }
else if(buf[0] == 2) {
24 throw TLS_Exception(Alert::IllegalParameter,
"Bad code for TLS alert level");
27 const uint8_t dc = buf[1];
29 m_type_code =
static_cast<Type>(dc);
33 return std::vector<uint8_t>({
static_cast<uint8_t
>(
is_fatal() ? 2 : 1),
static_cast<uint8_t
>(
type())});
38const char* alert_type_to_string(
AlertType type) {
41 return "close_notify";
43 return "unexpected_message";
45 return "bad_record_mac";
47 return "decryption_failed";
49 return "record_overflow";
51 return "decompression_failure";
53 return "handshake_failure";
55 return "no_certificate";
57 return "bad_certificate";
59 return "unsupported_certificate";
61 return "certificate_revoked";
63 return "certificate_expired";
65 return "certificate_unknown";
67 return "illegal_parameter";
71 return "access_denied";
73 return "decode_error";
75 return "decrypt_error";
77 return "export_restriction";
79 return "protocol_version";
81 return "insufficient_security";
83 return "internal_error";
85 return "inappropriate_fallback";
87 return "user_canceled";
89 return "no_renegotiation";
91 return "missing_extension";
93 return "unsupported_extension";
95 return "certificate_unobtainable";
97 return "unrecognized_name";
99 return "bad_certificate_status_response";
101 return "bad_certificate_hash_value";
103 return "unknown_psk_identity";
105 return "certificate_required";
107 return "no_application_protocol";
119 if(
const char* known_alert = alert_type_to_string(
type())) {
120 return std::string(known_alert);
123 return "unrecognized_alert_" + std::to_string(
static_cast<size_t>(
type()));
Decoding_Error(std::string_view name)
std::vector< uint8_t > serialize() const
std::string type_string() const
TLS_Exception(Alert::Type type, std::string_view err_msg="Unknown error")
@ BadCertificateHashValue
@ BadCertificateStatusResponse
@ CertificateUnobtainable
std::vector< T, secure_allocator< T > > secure_vector