Skip to content

Commit 40d27e2

Browse files
author
Tuure Vartiainen
committed
doc: documented ssl_psk_by_lua_block, ssl_psk_by_lua_file, ssl_psk_identity_hint, lua_ssl_psk_identity and lua_ssl_psk_key directives.
1 parent a7c3985 commit 40d27e2

File tree

1 file changed

+116
-0
lines changed

1 file changed

+116
-0
lines changed

doc/HttpLuaModule.wiki

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2156,6 +2156,98 @@ When a relative path like <code>foo/bar.lua</code> is given, they will be turned
21562156
21572157
This directive was first introduced in the <code>v0.10.0</code> release.
21582158
2159+
== ssl_psk_by_lua_block ==
2160+
2161+
'''syntax:''' ''ssl_psk_by_lua_block { lua-script }''
2162+
2163+
'''context:''' ''server''
2164+
2165+
'''phase:''' ''right-before-SSL-handshake''
2166+
2167+
This directive runs user Lua code when NGINX is about to start the SSL handshake for the downstream
2168+
SSL (https) connections using TLS-PSK and is meant for setting the TLS pre-shared key on a per-request basis.
2169+
2170+
The [https://github.com/openresty/lua-resty-core/blob/master/lib/ngx/ssl.md ngx.ssl]
2171+
Lua module provided by the [https://github.com/openresty/lua-resty-core/#readme lua-resty-core]
2172+
library is particularly useful in this context. You can use the Lua API offered by this Lua module
2173+
to set the TLS pre-shared key for the current SSL connection being initiated.
2174+
2175+
This Lua handler does not run at all, however, when NGINX/OpenSSL successfully resumes
2176+
the SSL session via SSL session IDs or TLS session tickets for the current SSL connection. In
2177+
other words, this Lua handler only runs when NGINX has to initiate a full SSL handshake.
2178+
2179+
Below is a trivial example using the
2180+
[https://github.com/openresty/lua-resty-core/blob/master/lib/ngx/ssl.md ngx.ssl] module
2181+
at the same time:
2182+
2183+
<geshi lang="nginx">
2184+
server {
2185+
listen 443 ssl;
2186+
server_name test.com;
2187+
2188+
ssl_psk_identity_hint Test_TLS-PSK_Identity_Hint;
2189+
2190+
ssl_psk_by_lua_block {
2191+
print("About to initiate a new TLS-PSK handshake!")
2192+
}
2193+
2194+
location / {
2195+
root html;
2196+
}
2197+
}
2198+
</geshi>
2199+
2200+
See more complicated examples in the [https://github.com/openresty/lua-resty-core/blob/master/lib/ngx/ssl.md ngx.ssl]
2201+
Lua module's official documentation.
2202+
2203+
Uncaught Lua exceptions in the user Lua code immediately abort the current SSL session, so does the
2204+
[[#ngx.exit|ngx.exit]] call with an error code like <code>ngx.ERROR</code>.
2205+
2206+
This Lua code execution context *does not* support yielding, so Lua APIs that may yield
2207+
(like cosockets, sleeping, and "light threads")
2208+
are disabled in this context.
2209+
2210+
Note, however, you still need to configure the [http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_certificate ssl_certificate] and
2211+
[http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_certificate_key ssl_certificate_key]
2212+
directives even though you will not use this static certificate and private key at all. This is
2213+
because the NGINX core requires their appearance otherwise you are seeing the following error
2214+
while starting NGINX:
2215+
2216+
<geshi>
2217+
nginx: [emerg] no ssl configured for the server
2218+
</geshi>
2219+
2220+
Furthermore, one needs at least OpenSSL 1.0.0 for this directive to work.
2221+
2222+
This directive was first introduced in the <code>v0.XX.YY</code> release.
2223+
2224+
== ssl_psk_by_lua_file ==
2225+
2226+
'''syntax:''' ''ssl_psk_by_lua_file <path-to-lua-script-file>''
2227+
2228+
'''context:''' ''server''
2229+
2230+
'''phase:''' ''right-before-SSL-handshake''
2231+
2232+
Equivalent to [[#ssl_psk_by_lua_block|ssl_psk_by_lua_block]], except that the file specified by <code><path-to-lua-script-file></code> contains the Lua code, or, as from the <code>v0.5.0rc32</code> release, the [[#Lua/LuaJIT bytecode support|Lua/LuaJIT bytecode]] to be executed.
2233+
2234+
When a relative path like <code>foo/bar.lua</code> is given, they will be turned into the absolute path relative to the <code>server prefix</code> path determined by the <code>-p PATH</code> command-line option while starting the Nginx server.
2235+
2236+
This directive was first introduced in the <code>v0.XX.YY</code> release.
2237+
2238+
== ssl_psk_identity_hint ==
2239+
2240+
'''syntax:''' ''ssl_psk_identity_hint <tls_psk_identity_hint>''
2241+
2242+
'''default:''' ''no''
2243+
2244+
'''context:''' ''http, server''
2245+
2246+
Specifies the TLS-PSK identity hint string which NGINX will send to a client during
2247+
the SSL handshake for the downstream SSL (https) connections.
2248+
2249+
This directive was first introduced in the <code>v0.XX.YY</code> release.
2250+
21592251
== ssl_session_fetch_by_lua_block ==
21602252
21612253
'''syntax:''' ''ssl_session_fetch_by_lua_block { lua-script }''
@@ -2495,6 +2587,30 @@ This directive was first introduced in the <code>v0.9.11</code> release.
24952587
24962588
See also [[#lua_ssl_trusted_certificate|lua_ssl_trusted_certificate]].
24972589
2590+
== lua_ssl_psk_identity ==
2591+
2592+
'''syntax:''' ''lua_ssl_psk_identity <tls_psk_identity>''
2593+
2594+
'''default:''' ''no''
2595+
2596+
'''context:''' ''http, server, location''
2597+
2598+
Specifies the TLS-PSK identity string which NGINX will send to a SSL/TLS server in the [[#tcpsock:sslhandshake|tcpsock:sslhandshake]] method.
2599+
2600+
This directive was first introduced in the <code>v0.XX.YY</code> release.
2601+
2602+
== lua_ssl_psk_key ==
2603+
2604+
'''syntax:''' ''lua_ssl_psk_key <tls_psk_key>''
2605+
2606+
'''default:''' ''no''
2607+
2608+
'''context:''' ''http, server, location''
2609+
2610+
Specifies the TLS-PSK key string which NGINX will try use with a SSL/TLS server in the [[#tcpsock:sslhandshake|tcpsock:sslhandshake]] method.
2611+
2612+
This directive was first introduced in the <code>v0.XX.YY</code> release.
2613+
24982614
== lua_http10_buffering ==
24992615
25002616
'''syntax:''' ''lua_http10_buffering on|off''

0 commit comments

Comments
 (0)