From ed103c0507f5e0ee8d31a00fff6044961abfa214 Mon Sep 17 00:00:00 2001 From: Tuure Vartiainen Date: Mon, 9 Oct 2017 17:43:33 +0300 Subject: [PATCH] tests: Changed ssl_psk_by_lua* with ssl_certificate_by_lua*. doc: Changed ssl_psk_by_lua* with ssl_certificate_by_lua*. --- lib/ngx/ssl.md | 4 ++-- t/ssl-psk.t | 20 ++++++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/ngx/ssl.md b/lib/ngx/ssl.md index 39e10e707..a0573f6d8 100644 --- a/lib/ngx/ssl.md +++ b/lib/ngx/ssl.md @@ -402,7 +402,7 @@ set_psk_key ------------ **syntax:** *ok, err = ssl.set_psk_key(psk_key)* -**context:** *ssl_psk_by_lua** +**context:** *ssl_certificate_by_lua** Sets the TLS-PSK key for the current SSL connection. @@ -416,7 +416,7 @@ get_psk_identity ------------ **syntax:** *identity, err = ssl.get_psk_identity()* -**context:** *ssl_psk_by_lua** +**context:** *ssl_certificate_by_lua** Returns a TLS-PSK identity a client sent for the current SSL connection. Returns `nil` and a string describing the error otherwise. diff --git a/t/ssl-psk.t b/t/ssl-psk.t index 32823d63d..780e5dfa4 100644 --- a/t/ssl-psk.t +++ b/t/ssl-psk.t @@ -34,15 +34,19 @@ __DATA__ ssl_protocols TLSv1; ssl_ciphers PSK; - ssl_psk_by_lua_block { + ssl_certificate_by_lua_block { local ssl = require "ngx.ssl" local psk_key = "psk_test_key" local psk_identity, err = ssl.get_psk_identity() if not psk_identity then + if err == "not in psk context" then + -- handler was not called by TLS-PSK callback + return + end ngx.log(ngx.ERR, "failed to get psk identity: ", err) - return ngx.ERROR + return ngx.exit(ngx.ERROR) end print("client psk identity: ", psk_identity) @@ -50,7 +54,7 @@ __DATA__ local ok, err = ssl.set_psk_key(psk_key) if not ok then ngx.log(ngx.ERR, "failed to set psk key: ", err) - return ngx.ERROR + return ngx.exit(ngx.ERROR) end } @@ -158,15 +162,19 @@ client psk identity: psk_test_identity ssl_protocols TLSv1; ssl_ciphers PSK; - ssl_psk_by_lua_block { + ssl_certificate_by_lua_block { local ssl = require "ngx.ssl" local psk_key = "psk_test_key2" local psk_identity, err = ssl.get_psk_identity() if not psk_identity then + if err == "not in psk context" then + -- handler was not called by TLS-PSK callback + return + end ngx.log(ngx.ERR, "failed to get psk identity: ", err) - return ngx.ERROR + return ngx.exit(ngx.ERROR) end print("client psk identity: ", psk_identity) @@ -174,7 +182,7 @@ client psk identity: psk_test_identity local ok, err = ssl.set_psk_key(psk_key) if not ok then ngx.log(ngx.ERR, "failed to set psk key: ", err) - return ngx.ERROR + return ngx.exit(ngx.ERROR) end }