Skip to content

Commit 08555bd

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 d99ca94 commit 08555bd

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

0 commit comments

Comments
 (0)