.name = "Cookie",
.tls_id = 44,
.gid = GNUTLS_EXTENSION_COOKIE,
- .validity = GNUTLS_EXT_FLAG_CLIENT_HELLO|GNUTLS_EXT_FLAG_HRR,
+ .validity = GNUTLS_EXT_FLAG_CLIENT_HELLO|GNUTLS_EXT_FLAG_HRR|GNUTLS_EXT_FLAG_IGNORE_CLIENT_REQUEST,
.parse_type = GNUTLS_EXT_MANDATORY, /* force parsing prior to EXT_TLS extensions */
.recv_func = cookie_recv_params,
}
if (session->security_parameters.entity == GNUTLS_CLIENT) {
- if (!_gnutls_hello_ext_is_present(session, ext->gid)) {
+ if (!(ext->validity & GNUTLS_EXT_FLAG_IGNORE_CLIENT_REQUEST) &&
+ !_gnutls_hello_ext_is_present(session, ext->gid)) {
_gnutls_debug_log("EXT[%p]: Received unexpected extension '%s/%d'\n", session,
ext->name, (int)tls_id);
return gnutls_assert_val(GNUTLS_E_RECEIVED_ILLEGAL_EXTENSION);
ret = _gnutls_hello_ext_is_present(session, p->gid);
if (session->security_parameters.entity == GNUTLS_SERVER) {
- if (ret == 0) /* not advertised */
+ /* if client didn't advertise and the override flag is not present */
+ if (!(p->validity & GNUTLS_EXT_FLAG_IGNORE_CLIENT_REQUEST) && ret == 0)
return 0;
} else {
if (ret != 0) /* already sent */
* @GNUTLS_EXT_FLAG_TLS13_SERVER_HELLO: This extension can be present in a TLS1.3 server hello
* @GNUTLS_EXT_FLAG_EE: This extension can be present in encrypted extensions message
* @GNUTLS_EXT_FLAG_HRR: This extension can be present in hello retry request message
+ * @GNUTLS_EXT_FLAG_IGNORE_CLIENT_REQUEST: When flag is present, this extension will be send even if the server didn't advertise it. An extension of this type is the Cookie TLS1.3 extension.
*
* Enumeration of different TLS extension registration flags.
*/
GNUTLS_EXT_FLAG_TLS12_SERVER_HELLO = (1<<2),
GNUTLS_EXT_FLAG_TLS13_SERVER_HELLO = (1<<3),
GNUTLS_EXT_FLAG_EE = (1<<4), /* ENCRYPTED */
- GNUTLS_EXT_FLAG_HRR = (1<<5)
+ GNUTLS_EXT_FLAG_HRR = (1<<5),
+ GNUTLS_EXT_FLAG_IGNORE_CLIENT_REQUEST = (1<<6)
} gnutls_ext_flags_t;
/* Register a custom tls extension