问题:我们的NGINX实现具有几种不同操作类型的基本位置,例如: / analytics,/ topology,...;并且每个都有自己的 access_by_lua_file ,它会打开传入的令牌,其中包含一些必须经过验证和处理的内容,包括一个新的右侧路径,包含自己的证书,密钥和ca.我们遇到的问题似乎是没有办法对 proxy_ssl_certificate , proxy_ssl_certificate_key 和 proxy_ssl_trusted_certificate 变量进行通配符,因为它们需要静态文件路径。
问题:有没有办法动态配置证书和密钥,即使我们的性能受到影响?我们知道以下限制,但坦率地说,没有任何解决方法在互联网上显示出来。
缺乏支持有两个原因:
答案 0 :(得分:1)
以下是我在其中一个OpenResty模块中使用的一系列SSL API调用。
> bases=c('A','T','G','C')
> expand.grid(bases, bases, bases)
Var1 Var2 Var3
1 A A A
2 T A A
3 G A A
4 C A A
5 A T A
6 T T A
7 G T A
8 C T A
9 A G A
10 T G A
11 G G A
12 C G A
13 A C A
14 T C A
15 G C A
16 C C A
17 A A T
18 T A T
19 G A T
20 C A T
21 A T T
22 T T T
23 G T T
24 C T T
25 A G T
26 T G T
27 G G T
28 C G T
29 A C T
30 T C T
31 G C T
32 C C T
33 A A G
34 T A G
35 G A G
36 C A G
37 A T G
38 T T G
39 G T G
40 C T G
41 A G G
42 T G G
43 G G G
44 C G G
45 A C G
46 T C G
47 G C G
48 C C G
49 A A C
50 T A C
51 G A C
52 C A C
53 A T C
54 T T C
55 G T C
56 C T C
57 A G C
58 T G C
59 G G C
60 C G C
61 A C C
62 T C C
63 G C C
64 C C C
实际上它与https://github.com/openresty/lua-resty-core/blob/master/lib/ngx/ssl.md#synopsis
完全相同答案 1 :(得分:0)
这个问题的建议答案似乎不起作用。这是代码:
if cert ~= nil and key ~= nil then
-- clear the fallback certificates and private keys that are statically
-- set by the ssl_certificate and ssl_certificate_key in proxy.conf
-- directives
ngx.log(ngx.DEBUG, 'Clearing fallback certificates');
local ok, err = ssl.clear_certs()
if not ok then
ngx.log(ngx.ERR, "failed to clear existing (fallback) certificates")
return ngx.exit(ngx.ERROR)
end
ngx.log(ngx.DEBUG, 'Convert private key pem to DER format');
-- key already contains the private key as provided in token
local client_key, err = ssl.priv_key_pem_to_der(key);
if not client_key then
ngx.log(ngx.ERR, "failed to convert PEM priv key to DER: ", err)
return
end
ngx.log(ngx.DEBUG, 'Set private key DER');
ok, err = ssl.set_der_priv_key(client_key)
if not ok then
ngx.log(ngx.ERR, "failed to set DER priv key: ", err)
return
end
ngx.log(ngx.DEBUG, 'Convert certificate pem to DER format');
-- cert already contains the private key as provided in token
local client_cert, err = ssl.cert_pem_to_der(cert);
if not client_cert then
ngx.log(ngx.ERR, "failed to convert PEM cert to DER: ", err)
return
end
ngx.log(ngx.DEBUG, 'Set certificate DER');
ok, err = ssl.set_der_cert(client_cert)
if not ok then
ngx.log(ngx.ERR, "failed to set DER cert: ", err)
return
end
end
ngx.log(ngx.INFO, 'Passing request to: ', ngx.var.target)
输出:
2018/03/06 13:55:31 [debug] 31#0: *12 [lua] analytics_access.lua:270: Clearing fallback certificates
2018/03/06 13:55:31 [debug] 31#0: *12 [lua] analytics_access.lua:277: Convert private key pem to DER format
2018/03/06 13:55:31 [debug] 31#0: *12 [lua] analytics_access.lua:285: Set private key DER
2018/03/06 13:55:31 [debug] 31#0: *12 [lua] analytics_access.lua:292: Convert certificate pem to DER format
2018/03/06 13:55:31 [debug] 31#0: *12 [lua] analytics_access.lua:300: Set certificate DER
2018/03/06 13:55:31 [info] 31#0: *12 [lua] analytics_access.lua:309: Passing request to: https://blah blah...
在控制台上: 400错误请求 未发送所需的SSL证书