Add /dbg certs command
This commit is contained in:
parent
50ca26a89a
commit
c96eae3015
3 changed files with 101 additions and 7 deletions
|
|
@ -110,6 +110,32 @@ local function handle_general()
|
|||
ngx.status = ngx.HTTP_CREATED
|
||||
end
|
||||
|
||||
local function handle_certs()
|
||||
if ngx.var.request_method ~= "GET" then
|
||||
ngx.status = ngx.HTTP_BAD_REQUEST
|
||||
ngx.print("Only GET requests are allowed!")
|
||||
return
|
||||
end
|
||||
|
||||
local query = ngx.req.get_uri_args()
|
||||
if not query["hostname"] then
|
||||
ngx.status = ngx.HTTP_BAD_REQUEST
|
||||
ngx.print("Hostname must be specified.")
|
||||
return
|
||||
end
|
||||
|
||||
local key = _M.get_pem_cert_key(query["hostname"])
|
||||
if key then
|
||||
ngx.status = ngx.HTTP_OK
|
||||
ngx.print(key)
|
||||
return
|
||||
else
|
||||
ngx.status = ngx.HTTP_NOT_FOUND
|
||||
ngx.print("No key associated with this hostname.")
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
function _M.call()
|
||||
if ngx.var.request_method ~= "POST" and ngx.var.request_method ~= "GET" then
|
||||
ngx.status = ngx.HTTP_BAD_REQUEST
|
||||
|
|
@ -127,6 +153,11 @@ function _M.call()
|
|||
return
|
||||
end
|
||||
|
||||
if ngx.var.uri == "/configuration/certs" then
|
||||
handle_certs()
|
||||
return
|
||||
end
|
||||
|
||||
if ngx.var.request_uri ~= "/configuration/backends" then
|
||||
ngx.status = ngx.HTTP_NOT_FOUND
|
||||
ngx.print("Not found!")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue