2015-10-07 379 views
0

我使用resty.http module。但是使用了這些數據。對於通常的http或https沒有驗證的所有作品。lua nginx ssl證書設置

local http = require("resty.http").new() 
local res, err = http:request_uri(url, { 
    method = method, 
    headers = headers, 
    body = body, 
    ssl_verify = false 
}) 

但是,如果我不使用ssl_verify它不會與錯誤的工作:

lua ssl certificate verify error: (20: unable to get local issuer certificate),

我發現使用谷歌認爲lua_ssl_trusted_certificate可以提供幫助。但我不知道它如何提供幫助。我已經測試過這樣的命令:lua_ssl_trusted_certificate /etc/ssl/certs/GlobalSign_Root_CA.pem;但它對我沒有幫助。

如何以正確的方式驗證https?

+0

證書通常是'.crt'文件 – hjpotter92

+0

@ hjpotter92,lua_ssl_trusted_certificate /etc/ssl/certs/ca-certificates.crt;給出相同的錯誤行爲 – Vyacheslav

回答

0

在你nginx.conf您需要配置

lua_ssl_verify_depth 2; 
lua_ssl_trusted_certificate /pathto-ca-certs.pem; 

在我的情況,我的服務器調用出來只有一個外部HTTPS端點。所以我用完整的鏈導出證書(通過Firefox中的導出證書導出)並導入到PEM文件中。這是我上面提供的.pem文件。

我使用lua-resty-http進行https調用,並且工作正常。您可以使用像wireshark/fiddler這樣的工具來監控傳出連接,以查看請求是否以您想要的方式進行。