File tree 2 files changed +40
-4
lines changed 2 files changed +40
-4
lines changed Original file line number Diff line number Diff line change @@ -2581,7 +2581,7 @@ ssl_psk_by_lua_block
2581
2581
This directive runs user Lua code when NGINX is about to start the SSL handshake for the downstream
2582
2582
SSL (https) connections using TLS-PSK and is meant for setting the TLS pre-shared key on a per-request basis.
2583
2583
2584
- The [ ngx.ssl] ( https://github.com/openresty /lua-resty-core/blob/master /lib/ngx/ssl.md )
2584
+ The [ ngx.ssl] ( https://github.com/vartiait /lua-resty-core/blob/ssl-psk /lib/ngx/ssl.md )
2585
2585
Lua module provided by the [ lua-resty-core] ( https://github.com/openresty/lua-resty-core/#readme )
2586
2586
library is particularly useful in this context. You can use the Lua API offered by this Lua module
2587
2587
to set the TLS pre-shared key for the current SSL connection being initiated.
@@ -2603,7 +2603,25 @@ at the same time:
2603
2603
ssl_psk_identity_hint Test_TLS-PSK_Identity_Hint;
2604
2604
2605
2605
ssl_psk_by_lua_block {
2606
- print("About to initiate a new TLS-PSK handshake!")
2606
+ local ssl = require "ngx.ssl"
2607
+
2608
+ local psk_identity, err = ssl.get_psk_identity()
2609
+ if not psk_identity then
2610
+ ngx.log(ngx.ERR, "Failed to get TLS-PSK Identity: ", err)
2611
+ return ngx.ERROR
2612
+ end
2613
+
2614
+ print("Client TLS-PSK Identity: ", psk_identity)
2615
+
2616
+ local psk_key = "psk_test_key"
2617
+
2618
+ local ok, err = ssl.set_psk_key(psk_key)
2619
+ if not ok then
2620
+ ngx.log(ngx.ERR, "Failed to set TLS-PSK key: ", err)
2621
+ return ngx.ERROR
2622
+ end
2623
+
2624
+ return ngx.OK
2607
2625
}
2608
2626
2609
2627
location / {
Original file line number Diff line number Diff line change @@ -2170,7 +2170,7 @@ This directive was first introduced in the <code>v0.10.0</code> release.
2170
2170
This directive runs user Lua code when NGINX is about to start the SSL handshake for the downstream
2171
2171
SSL (https) connections using TLS-PSK and is meant for setting the TLS pre-shared key on a per-request basis.
2172
2172
2173
- The [https://github.com/openresty /lua-resty-core/blob/master /lib/ngx/ssl.md ngx.ssl ]
2173
+ The [https://github.com/vartiait /lua-resty-core/blob/ssl-psk /lib/ngx/ssl.md ngx.ssl ]
2174
2174
Lua module provided by the [https://github.com/openresty/lua-resty-core/#readme lua-resty-core ]
2175
2175
library is particularly useful in this context. You can use the Lua API offered by this Lua module
2176
2176
to set the TLS pre-shared key for the current SSL connection being initiated.
@@ -2191,7 +2191,25 @@ at the same time:
2191
2191
ssl_psk_identity_hint Test_TLS-PSK_Identity_Hint;
2192
2192
2193
2193
ssl_psk_by_lua_block {
2194
- print("About to initiate a new TLS-PSK handshake!")
2194
+ local ssl = require "ngx.ssl"
2195
+
2196
+ local psk_identity, err = ssl.get_psk_identity()
2197
+ if not psk_identity then
2198
+ ngx.log(ngx.ERR, "Failed to get TLS-PSK Identity: ", err)
2199
+ return ngx.ERROR
2200
+ end
2201
+
2202
+ print("Client TLS-PSK Identity: ", psk_identity)
2203
+
2204
+ local psk_key = "psk_test_key"
2205
+
2206
+ local ok, err = ssl.set_psk_key(psk_key)
2207
+ if not ok then
2208
+ ngx.log(ngx.ERR, "Failed to set TLS-PSK key: ", err)
2209
+ return ngx.ERROR
2210
+ end
2211
+
2212
+ return ngx.OK
2195
2213
}
2196
2214
2197
2215
location / {
You can’t perform that action at this time.
0 commit comments