我们在Istio中使用EnvoyFilter中的Lua过滤器来检查证书细节。用法如下(省略了对client_cert_name的详细验证)。
spec:
workloadSelector:
labels:
istio: ingressgateway
configPatches:
- applyTo: HTTP_FILTER
match:
context: GATEWAY
listener:
filterChain:
filter:
# https://www.envoyproxy.io/docs/envoy/latest/version_history/v1.14.0#deprecated
name: "envoy.filters.network.http_connection_manager"
proxy:
proxyVersion: ^1\.10.*
patch:
operation: INSERT_BEFORE
value:
name: envoy.lua
typed_config:
# https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/http/lua/v3/lua.proto#extension-envoy-filters-http-lua
"@type": "type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua"
inlineCode: |
function envoy_on_request(handle)
-- https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_filters/lua_filter#subjectpeercertificate
local client_cert_name = handle:connection():ssl():subjectPeerCertificate()
if client_cert_name == "" and handle:headers():get("Authorization") == nil then
handle:respond({[":status"] = "401"},"Unauthorized")
end函数handle:connection():ssl():subjectPeerCertificate()在Istio1.9.9中运行良好,但是在升级到1.10.6之后,如果没有其他更改,就不会找到对等证书,并且函数只返回空的。我们已经检查了伊斯蒂奥和特使的文件很长一段时间,但没有发现这一职能的突破变化。添加侦听器合并修补程序(如这 )等几次尝试都没有帮助。你能帮我建议一下哪里有问题吗?
发布于 2022-01-14 13:42:17
最后,从Istio1.10中可以看出,有一个提交使Istio不添加简单的验证上下文。直到最新版本1.12.1,逻辑仍然存在。
我们的服务在网关中使用简单的TLS模式,这导致了这个问题中描述的问题,如下所示:
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
...
servers:
- port:
number: 443
name: https
protocol: HTTPS
tls:
mode: SIMPLE在将模式改为互操作之后,问题就解决了。
https://stackoverflow.com/questions/70620495
复制相似问题