解决 Istio 报错 PeerAuthentication mTLS 冲突服务无法访问
分析 Istio 网格内服务在切换 STRICT 与 PERMISSIVE 模式时报 TLS error 或 503 根因,提供命名空间级继承与 DestinationRule 联动步骤。
问题现象
在对 Istio 服务网格进行安全加固,将 PeerAuthentication 模式调整为 STRICT 后,网格外部流量或未注入 Sidecar 的存量应用访问网格服务时全部失败,返回 HTTP 503 或连接重置:
curl: (35) error:0A000410:SSL routines::sslv3 alert handshake failure
-- Envoy 日志:
[2026-11-15T13:00:00.000Z] "- - -" 0 - - - "-" 0 0 0 - "-" "-" "-" "-" "-"
downstream_peer_subject="-",downstream_local_uri_san="-",connection_termination_details="TLS error: ...:SSL routines:OPENSSL_internal:PEER_DID_NOT_RETURN_A_CERTIFICATE"
触发根因
PeerAuthentication设为了STRICT,强制要求双向 mTLS 证书:客户端如果没有注入 Envoy Sidecar 代理(即发起普通明文 HTTP 请求),服务端 Envoy 会在 TLS 握手阶段直接拦截切断。DestinationRule未配置ISTIO_MUTUAL模式:客户端 Sidecar 未被指示使用 mTLS 发起上游连接,导致两端策略脱节。- 全局 Root 策略与命名空间局部策略发生层叠覆盖冲突。
诊断排查步骤
- 检查目标命名空间与全局的 PeerAuthentication 策略:
kubectl get peerauthentication -A
- 检查对应的 DestinationRule TLS 模式:
kubectl get destinationrule -A -o yaml | grep -A 5 "trafficPolicy"
解决步骤与操作命令
步骤一:过渡阶段使用 PERMISSIVE 模式(平滑迁移)
在存量应用尚未全部完成 Sidecar 注入前,不要直接设置 STRICT。使用宽容模式:
apiVersion: security.istio.io/v1beta1
kind: PeerAuthentication
metadata:
name: default
namespace: prod
spec:
mtls:
mode: PERMISSIVE # 同时接受明文和 mTLS 流量
应用该配置:
kubectl apply -f peer-auth.yaml
步骤二:联动配置客户端 DestinationRule 为 ISTIO_MUTUAL
在必须开启 STRICT 的场景下,确保网格内服务调用配置了自动双向认证:
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: default-mtls
namespace: prod
spec:
host: "*.prod.svc.cluster.local"
trafficPolicy:
tls:
mode: ISTIO_MUTUAL
步骤三:针对外部非网格流量放行明文端口
若必须从集群外部直接通过 NodePort 访问,对特定端口覆盖策略:
spec:
selector:
matchLabels:
app: web-gateway
portLevelMtls:
8080:
mode: DISABLE
步骤四:验证连通性
使用注入了 Sidecar 的客户端与未注入的外部客户端分别测试:
curl -I http://my-service.prod:8080
两端流量均能正确鉴权并顺畅通信。


