Skip to content

Commit

Permalink
tests: Changed ssl_psk_by_lua* with ssl_certificate_by_lua*.
Browse files Browse the repository at this point in the history
doc: Changed ssl_psk_by_lua* with ssl_certificate_by_lua*.
  • Loading branch information
Tuure Vartiainen committed Oct 9, 2017
1 parent 5cb101c commit ed103c0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/ngx/ssl.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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.
Expand Down
20 changes: 14 additions & 6 deletions t/ssl-psk.t
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,27 @@ __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)

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
}

Expand Down Expand Up @@ -158,23 +162,27 @@ 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)

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
}

Expand Down

0 comments on commit ed103c0

Please sign in to comment.