我在 foo.example.com
上部署了一个在 Kubernetes (GKE) 上运行的应用程序。入口定义如下所示:
spec:
tls:
- hosts:
- "foo.example.com"
secretName: foo-example-com
rules:
- host: "foo.example.com"
http:
paths:
- path: /*
backend:
serviceName: web
servicePort: 80
当我导航到 http://foo.example.com/
时,我会(正确地)重定向到 https://foo.example.com/
适当的证书。
但是,我的搜索域中有 example.com
。所以 ping foo
正确解析到 Kubernetes 入口。
但是当我在浏览器中访问 https://foo/
时,我在 Chrome 中收到以下错误消息:
Your connection is not private
Attackers might be trying to steal your information from foo (for example, passwords, messages, or credit cards). Learn more
NET::ERR_CERT_AUTHORITY_INVALID
Subject: Kubernetes Ingress Controller Fake Certificate
Issuer: Kubernetes Ingress Controller Fake Certificate
Expires on: Oct 1, 2019
Current date: Oct 9, 2018
你会如何让这个工作?
显然,如果没有一些我不想尝试的自签名 hacker,我无法获得 foo
的证书。
即使在 Kubernetes 之外,这也能正常工作。首先,每个网络浏览器(包括 Chrome)都有一个开箱即用的权限列表:
等等。
您的 CA 证书(在您的 Secret 中)是由您自己的 Certificate Authority 自签名的,Chrome 不信任它,这就是您看到错误的原因。您可能可以将您的 CA 导入 Chrome,并且您的 Chrome 实例会信任它,但是......如您所知,通常为特定域或通配符 (CN) 颁发的 TLS (SSL) 证书,因此 foo
可能与您证书的通配符表达式不匹配,您将看到另一个 SSL 错误:NET::ERR_CERT_COMMON_NAME_INVALID
。因此,您将不得不使用重写规则来使其工作。
我是一名优秀的程序员,十分优秀!