简体   繁体   English

Kubernetes Ingress SSL 证书问题

[英]Kubernetes Ingress SSL certificate problem

I am having a problem with my TLS.我的 TLS 有问题。 I have my TLS secret created:我创建了我的 TLS 密码:

kubectl create secret tls ingress-tls  --key certificate.key  --cert certificate.crt

And I use it in my ingress:我在我的入口中使用它:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress
  annotations:
    kubernetes.io/ingress.global-static-ip-name: "beta"
spec:
  tls:
  - hosts:
    - '*.host.com'
    - 'beta.host.com'
    secretName: ingress-tls
  backend:
    serviceName: nginx
    servicePort: 443

The ingress is created perfectly, I access through a browser and no problem, the problem comes when I do a curl or using the program postman, I get certificate error.入口创建完美,我通过浏览器访问,没问题,当我做卷曲或使用程序邮递员时出现问题,我得到证书错误。

curl: (60) SSL certificate problem: unable to get local issuer certificate More details here: https://curl.haxx.se/docs/sslcerts.html curl:(60)SSL证书问题:无法获取本地颁发者证书更多详细信息: https ://curl.haxx.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not establish a secure connection to it. curl 无法验证服务器的合法性,因此无法建立与它的安全连接。 To learn more about this situation and how to fix it, please visit the web page mentioned above.要了解有关此情况以及如何解决此问题的更多信息,请访问上述网页。

I'm using the GCE driver, it's the default GKE from google cloud.我正在使用 GCE 驱动程序,它是谷歌云的默认 GKE。

I've been reading how to add the ca key, but this error is not fixed.我一直在阅读如何添加 ca 密钥,但此错误未修复。

I did the following:我做了以下事情:

kubectl create secret generic ca --from-file certificate.ca.crt

And I added the following annotation to the ingress:我在入口处添加了以下注释:

ingress.kubernetes.io/auth-tls-secret: ca

But is not working.但不工作。

Does anyone know how to fix the CA certificate?有谁知道如何修复 CA 证书? The certificate is purchased on the DonDominio website and it's a Wildcard.该证书是在 DonDominio 网站上购买的,它是一个通配符。

The problem was basically that I was using the .crt instead of the .pem when I generated the TLS secret.问题基本上是我在生成 TLS 密钥时使用的是 .crt 而不是 .pem。 By changing the secret I got curl to detect it as a valid certificate.通过更改秘密,我得到 curl 以将其检测为有效证书。

New command:新命令:

kubectl create secret tls ingress-tls --key certificate.key --cert certificate.pem 

Thanks to @Michael-sqlbot!感谢@Michael-sqlbot!

If you have .ca-bundle + crt file, append .ca-bundle into the end of .crt and create secret from the new crt file will resolve this issue.如果您有 .ca-bundle + crt 文件,请将 .ca-bundle 附加到 .crt 的末尾并从新的 crt 文件创建密钥将解决此问题。 This is because you need all the immediate keys for your ingress.这是因为您需要所有直接密钥才能进入入口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM