GNUTLS_ALPN_MANDATORY is enforced in server mode only

Description of problem:

gnutls_alpn_set_protocols is documented to accept GNUTLS_ALPN_MANDATORY to mean "Require ALPN negotiation", but that flag is only checked when running in server mode, not in client mode.

Version of gnutls used:

3.7.9

Distributor of gnutls (e.g., Ubuntu, Fedora, RHEL)

Debian

How reproducible:

Always

Steps to Reproduce:

  1. Patch gnutls/src/cli.c to pass GNUTLS_ALPN_MANDATORY in the call to gnutls_alpn_set_protocols

  2. Run the modified gnutls-cli: gnutls-cli --port 6666 --alpn=h2 127.1 against a gnutls-serv without any alpn flags specified

Actual results:

Connection succeeds

Expected results:

*** Fatal error: No common application protocol could be negotiated.

Edited by Robert Pluim