如何验证upstream的SSL证书指纹(thumbprint/fingerprint)

99 views
Skip to first unread message

qihang

unread,
Oct 8, 2018, 11:45:56 PM10/8/18
to openresty
Hi 大家好,
我在利用openresty开发一个wss(WebSocket over SSL)动态网关。在没有这个动态网关之前,客户端是直连upstream(之一),为了增强安全性,客户端会验证upstream的证书指纹(与客户端已知的相比对)。现在有了这个网关,我想在网关上保持这个机制存在,就需要能够在nginx与upstreamSSL的握手过程中(或者握手后但是传输业务数据之前),获得证书中的指纹用与验证。

我搜索了一下,发现了“ssl_certificate_by_lua_block”,但是文档中说它是用于downstream,而且从流程图上看,它位于Access phase,而连接upstream在content phase,我的问题是:
  1. 针对upstream,openresty有类似的能力么?
  2. 如果有,那么应该用哪个directive?
  3. 如果没有,有什么别的可能的实现方式么?


多谢!

Zexuan Luo

unread,
Oct 9, 2018, 3:49:42 AM10/9/18
to open...@googlegroups.com
据我所知,这个应该没有现成的功能吧。
估计需要一点 C 技巧,用 SSL_CTX_set_cert_verify_callback 注册一个 C 函数,然后在里面用 Lua 进行交互?就像
https://github.com/openresty/lua-nginx-module/blob/v0.10.13/src/ngx_http_lua_module.c#L973

没试过,只是提个想法而已。
qihang <qiha...@gmail.com> 于2018年10月9日周二 上午11:45写道:
> --
> --
> 邮件来自列表“openresty”,专用于技术讨论!
> 订阅: 请发空白邮件到 openresty...@googlegroups.com
> 发言: 请发邮件到 open...@googlegroups.com
> 退订: 请发邮件至 openresty+...@googlegroups.com
> 归档: http://groups.google.com/group/openresty
> 官网: http://openresty.org/
> 仓库: https://github.com/agentzh/ngx_openresty
> 教程: http://openresty.org/download/agentzh-nginx-tutorials-zhcn.html

qihang zhang

unread,
Oct 10, 2018, 1:50:43 AM10/10/18
to open...@googlegroups.com
谢谢zexuan给出线索:)

如果有进展我会在列表里update
Reply all
Reply to author
Forward
0 new messages