diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2018-02-23 09:55:50 +0100 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2018-02-26 08:45:08 +0100 |
commit | 8c0e18585f96d4cfd046598a9d40c94eabff0b33 (patch) | |
tree | 9875594d70f09e63f881a82fa71487c4fe1c3208 /doc/cha-gtls-app.texi | |
parent | 3684ce08e4dd419a3d42c66b4042d8d3fd767c35 (diff) | |
download | gnutls-8c0e18585f96d4cfd046598a9d40c94eabff0b33.tar.gz |
gnutls_ext_raw_parse: introduced function
That function can be combined with callbacks like
gnutls_handshake_set_hook_function() for applications to
be able to process messages when necessary.
Resolves #382
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Diffstat (limited to 'doc/cha-gtls-app.texi')
-rw-r--r-- | doc/cha-gtls-app.texi | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/doc/cha-gtls-app.texi b/doc/cha-gtls-app.texi index e401713814..6575120756 100644 --- a/doc/cha-gtls-app.texi +++ b/doc/cha-gtls-app.texi @@ -1583,6 +1583,20 @@ continue in the handshake process. A brief usage example is shown below. @example +static int ext_hook_func(void *ctx, unsigned tls_id, + const unsigned char *data, unsigned size) +@{ + if (tls_id == 0) @{ /* server name */ + /* figure the advertized name - the following hack + * relies on the fact that this extension only supports + * DNS names, and due to a protocol bug cannot be extended + * to support anything else. */ + if (name < 5) return 0; + name = data+5; + name_size = size-5; + @} +@} + static int handshake_hook_func(gnutls_session_t session, unsigned int htype, unsigned when, unsigned int incoming, const gnutls_datum_t *msg) @@ -1590,6 +1604,10 @@ handshake_hook_func(gnutls_session_t session, unsigned int htype, assert(htype == GNUTLS_HANDSHAKE_CLIENT_HELLO); assert(when == GNUTLS_HOOK_PRE); + ret = gnutls_ext_raw_parse(NULL, ext_hook_func, msg, + GNUTLS_EXT_RAW_FLAG_CLIENT_HELLO); + assert(ret >= 0); + gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, cred); @} |