解决kubesphere x509: certificate signed by unknown authority问题(Kubesphere 配置镜像仓库)

问题

registry自签的证书,配置secret失败提示certificate signed by unknown authority
在这里插入图片描述

解决办法

通过configmap加载自签的CA证书

  • 查看 CA 证书的位置,在 Harbor 部署时,查看证书生成的位置及值:
ls /etc/docker/certs.d/
cat /etc/docker/certs.d/registry.opsxlab.cn/ca.crt

-----BEGIN CERTIFICATE-----
MIIDATCCAemgAwIBAgIBADANBgkqhkiG9w0BAQsFADAWMRQwEgYDVQQDEwtyZWdp
c3RyeS1jYTAeFw0yNDEwMTcxMzE5MTZaFw0zNDEwMTUxMzE5MTZaMBYxFDASBgNV
BAMTC3JlZ2lzdHJ5LWNhMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
npOr1/ZEqzED6dlRU6tT1Brx9wHY7GiPCxkRUrqI4HGEHhdpcQoEjzYrkwvRrf6T
BWjdV9heUp73nDu2W+4qVZ4REjcmJBPZQjjzB47/AuI8/kPM6XFoXJfOPNw7XS1S
lcLl+OMSJfH4WhBdKaQ2Y7QeyPhm8Kwl+U2WEvvX8Qe/DJnvH4NISnTuhvguq1a0
P0EMjrVjiYZ2wNLX4gVMCowVCH3w3eJH1S+4Psc61PMh/zsV+jl4ReQoPSUl0Xsa
Oe41rfT+09KHrXIgKw0t4JPcu9TvAENfUZ5tV9Gw+qyyW3FzJzfSNt+Qm3ZirL7+
XmePPg2IMQcoD1iKQCj03wIDAQABo1owWDAOBgNVHQ8BAf8EBAMCAqQwDwYDVR0T
AQH/BAUwAwEB/zAdBgNVHQ4EFgQUFZB5nrmbMkUJ5fFppRCMkB3O6owwFgYDVR0R
BA8wDYILcmVnaXN0cnktY2EwDQYJKoZIhvcNAQELBQADggEBAFfRfqIAOpriDEfW
II3OAiFLClgqx0j0oJwr/GBnGSPrm0LSq0Z1RUyChiAq+eaM0RdKAcYUxuQwF2Az
OM28iHXrfIkn+HxqwVNt9MIIcfSvEbGq5/Ffpx/TTV5IRbmPxatMuzokY3RkiAyB
4T1NIlNvF5N0+hPlHeoVjns4Rrf19/0J734NaT6BK2YQSYgc+DXY1W7S546syuaJ
go3t0pQOWmrPIwVSXUXLl7gWvgLC7ByaEv55avVshOpsiscpF+NZax671WdPe1Pr
WsmgThuxlYdEHa65T+/Me/lK6Ip+ZPD9eKt3aDv+PLMGZI7iyj10csoFfySsqGYq
G56GWs4=
-----END CERTIFICATE-----

界面创建configmap:工作台>企业空间>System-workspace>项目>kubesphere-system>配置>配置字典

  • 新建registry-ca

在这里插入图片描述

在这里插入图片描述

  • 编辑 ks-apiserver deployment 文件,进行 configmap 的挂载:
    在这里插入图片描述

  • 更多操作=>编辑设置
    在这里插入图片描述

  • 存储卷=>挂载配置字典或保密字典
    在这里插入图片描述

  • 路径是:/etc/ssl/certs/ca.crt
    在这里插入图片描述

在这里插入图片描述

  • 点确认前没有出现报错.

在这里插入图片描述

  • 这里报错是正常的,deployment会被重建
    在这里插入图片描述
    过一会刷新下就恢复正常了

验证

配置=>保密字典=>创建

在这里插入图片描述
在这里插入图片描述

kubesphere的devops报错

Failed to bind to LDAP: userDnuid=admin,ou=Users,dc=kubesphere,dc=io username=admin

2024-10-18 02:00:28.497+0000 [id=193]	WARNING	o.s.c.s.ResourceBundleMessageSource#getResourceBundle: ResourceBundle [org.acegisecurity.messages] not found for MessageSource: Can't find bundle for base name org.acegisecurity.messages, locale en
2024-10-18 02:00:28.498+0000 [id=193]	WARNING	o.a.p.l.a.BindAuthenticator2#handleBindException: Failed to bind to LDAP: userDnuid=admin,ou=Users,dc=kubesphere,dc=io  username=admin
javax.naming.AuthenticationException: [LDAP: error code 49 - Invalid Credentials]
	at java.naming/com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3259)
	at java.naming/com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:3205)
	at java.naming/com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2991)
	at java.naming/com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2905)
	at java.naming/com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:348)
	at java.naming/com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxFromUrl(LdapCtxFactory.java:262)
	at java.naming/com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(LdapCtxFactory.java:226)
	at java.naming/com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(LdapCtxFactory.java:280)
	at java.naming/com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(LdapCtxFactory.java:185)
	at java.naming/com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(LdapCtxFactory.java:115)
	at java.naming/javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:730)
	at java.naming/javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:305)
	at java.naming/javax.naming.InitialContext.init(InitialContext.java:236)
	at java.naming/javax.naming.InitialContext.<init>(InitialContext.java:208)
	at java.naming/javax.naming.directory.InitialDirContext.<init>(InitialDirContext.java:101)
	at org.acegisecurity.ldap.DefaultInitialDirContextFactory.connect(DefaultInitialDirContextFactory.java:180)
	at org.acegisecurity.ldap.DefaultInitialDirContextFactory.newInitialDirContext(DefaultInitialDirContextFactory.java:261)
	at org.acegisecurity.ldap.LdapTemplate.execute(LdapTemplate.java:123)
	at org.acegisecurity.ldap.LdapTemplate.retrieveEntry(LdapTemplate.java:165)
	at org.acegisecurity.providers.ldap.authenticator.BindAuthenticator.bindWithDn(BindAuthenticator.java:87)
	at org.acegisecurity.providers.ldap.authenticator.BindAuthenticator.authenticate(BindAuthenticator.java:72)
	at org.acegisecurity.providers.ldap.authenticator.BindAuthenticator2.authenticate(BindAuthenticator2.java:49)
	at org.acegisecurity.providers.ldap.LdapAuthenticationProvider.retrieveUser(LdapAuthenticationProvider.java:233)
	at org.acegisecurity.providers.dao.AbstractUserDetailsAuthenticationProvider$1.retrieveUser(AbstractUserDetailsAuthenticationProvider.java:52)
	at org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider.authenticate(AbstractUserDetailsAuthenticationProvider.java:133)
	at org.acegisecurity.providers.dao.AbstractUserDetailsAuthenticationProvider.authenticate(AbstractUserDetailsAuthenticationProvider.java:66)
	at org.acegisecurity.providers.ProviderManager.doAuthentication(ProviderManager.java:200)
	at org.acegisecurity.AbstractAuthenticationManager.authenticate(AbstractAuthenticationManager.java:47)

解决办法

修改默认的账户密码,修改为登录kubesphere的账号密码

路径 配置=>保密字典=>devops-jenkins

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
改完之后重新部署devops-controller,devops-apiserver,devops-jenkins 这三个服务
在这里插入图片描述

当你在使用 Go 语言的 `go mod tidy` 或者其他涉及网络请求的 `go get`、`go build` 等命令时,可能会遇到 "tls: failed to verify certificate: x509: certificate signed by unknown authority" 的错误。这通常意味着 Go 安装过程中尝试连接到的第三方包的服务器提供的 SSL/TLS 证书不受信任。 这个问题通常是由于以下几个原因: 1. **自签发证书**:第三方仓库使用的是自签名证书,而不是常见的像 Let's Encrypt 这样的受信任证书颁发机构(CA)签发的证书。 2. **证书过期**:证书已经到期,导致无法验证。 3. **证书列表更新**:你的系统证书存储可能未及时更新,不包含该服务器的新证书。 解决这个问题有几种途径: - **忽略安全警告**:如果你确定这个证书是可信的,可以在运行 `go mod tidy` 之前临时禁用证书检查,但这种方式并不推荐长期使用,因为安全性会受到影响。可以这样做: ```sh GOINSECURE=1 go mod tidy ``` - **添加证书的信任**:如果是第三方仓库的问题,你需要手动导入其证书到你的系统证书存储。但这需要对操作系统的证书管理有一定的了解。 - **更新证书存储**:确保你的操作系统证书存储已更新至最新版本,可以使用 `sudo update-ca-certificates` (Linux) 或 `sccp -f cacert.pem /usr/local/share/ca-certificates` (macOS)。 - **更换镜像源**:如果可能的话,选择一个提供受信任证书的官方或者知名的 Go 包镜像源。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值