Skip to content

Commit 8193d5e

Browse files
doc: add doc for get_client_hello_ext_present().
1 parent fcef69d commit 8193d5e

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

lib/ngx/ssl/clienthello.md

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Table of Contents
1313
* [Methods](#methods)
1414
* [get_client_hello_server_name](#get_client_hello_server_name)
1515
* [get_supported_versions](#get_supported_versions)
16+
* [get_client_hello_ext_present](#get_client_hello_ext_present)
1617
* [get_client_hello_ext](#get_client_hello_ext)
1718
* [set_protocols](#set_protocols)
1819
* [Community](#community)
@@ -125,8 +126,48 @@ So this function can only be called in the context of [ssl_client_hello_by_lua*]
125126

126127
[Back to TOC](#table-of-contents)
127128

129+
get_client_hello_ext_present
130+
----------------------------
131+
**syntax:** *ext, err = ssl_clt.get_client_hello_ext_present()*
132+
133+
**context:** *ssl_client_hello_by_lua**
134+
135+
Returns a Lua table contains the extension types on success.
136+
137+
In case of errors, it returns `nil` and a string describing the error.
138+
139+
Note that the ext is gotten from the raw extensions of the client hello message associated with the current downstream SSL connection.
140+
141+
So this function can only be called in the context of [ssl_client_hello_by_lua*](https://github.com/openresty/lua-nginx-module/#ssl_client_hello_by_lua_block).
142+
143+
Example:
144+
145+
```nginx
146+
# nginx.conf
147+
server {
148+
listen 443 ssl;
149+
server_name test.com;
150+
ssl_client_hello_by_lua_block {
151+
local ssl_clt = require "ngx.ssl.clienthello"
152+
local exts = ssl_clt.get_client_hello_ext_present()
153+
if not exts then
154+
ngx.log(ngx.ERR, "failed to get_client_hello_ext_present()")
155+
ngx.exit(ngx.ERROR)
156+
end
157+
158+
for i, ext in ipairs(exts) do
159+
ngx.log(ngx.INFO, "extension ", ext)
160+
end
161+
}
162+
ssl_certificate test.crt;
163+
ssl_certificate_key test.key;
164+
}
165+
```
166+
167+
[Back to TOC](#table-of-contents)
168+
128169
get_client_hello_ext
129-
----------------------
170+
--------------------
130171
**syntax:** *ext, err = ssl_clt.get_client_hello_ext(ext_type)*
131172

132173
**context:** *ssl_client_hello_by_lua**

0 commit comments

Comments
 (0)