$ curl -v -H "Host: admin.test.com" https://52.52.2.9 * About to connect() to 52.52.2.9 port 443 (#0) * Trying 52.52.2.9... * Connected to 52.52.2.9 (52.52.2.9) port 443 (#0) * Initializing NSS with certpath: sql:/etc/pki/nssdb * CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: none * Server certificate: * subject: CN=admin.test.com * start date: Mar 14 00:00:00 2023 GMT * expire date: Mar 13 23:59:59 2024 GMT * common name: admin.test.com * issuer: CN=Sectigo RSA Domain Validation Secure Server CA,O=Sectigo Limited,L=Salford,ST=Greater Manchester,C=GB * NSS error -12276 (SSL_ERROR_BAD_CERT_DOMAIN) * Unable to communicate securely with peer: requested domain name does not match the server's certificate. * Closing connection 0 curl: (51) Unable to communicate securely with peer: requested domain name does not match the server's certificate.
结果显示,请求的域名和服务器中的域名证书不匹配(requested domain name does not match the server's certificate.),通过浏览器直接访问域名(可以将域名和其对应 IP 写入系统 hosts 文件),显示证书正常,使用 openssl s_client 命令验证证书,结果也显示正常
$ echo | openssl s_client -servername admin.test.com -connect 52.52.2.9:443 CONNECTED(00000003) depth=3 C = GB, ST = Greater Manchester, L = Salford, O = Comodo CA Limited, CN = AAA Certificate Services verify return:1 depth=2 C = US, ST = New Jersey, L = Jersey City, O = The USERTRUST Network, CN = USERTrust RSA Certification Authority verify return:1 depth=1 C = GB, ST = Greater Manchester, L = Salford, O = Sectigo Limited, CN = Sectigo RSA Domain Validation Secure Server CA verify return:1 depth=0 CN = admin.test.com verify return:1 --- Certificate chain 0 s:/CN=admin.test.com i:/C=GB/ST=Greater Manchester/L=Salford/O=Sectigo Limited/CN=Sectigo RSA Domain Validation Secure Server CA 1 s:/C=GB/ST=Greater Manchester/L=Salford/O=Sectigo Limited/CN=Sectigo RSA Domain Validation Secure Server CA i:/C=US/ST=New Jersey/L=Jersey City/O=The USERTRUST Network/CN=USERTrust RSA Certification Authority 2 s:/C=US/ST=New Jersey/L=Jersey City/O=The USERTRUST Network/CN=USERTrust RSA Certification Authority i:/C=GB/ST=Greater Manchester/L=Salford/O=Comodo CA Limited/CN=AAA Certificate Services --- Server certificate -----BEGIN CERTIFICATE----- MIIGQTCCBSmgAwIBAgIRAMrTCHWnCEPDYFZcToXLKC8wDQYJKoZIhvcNAQELBQAw gY8xCzAJBgNVBAYTAkdCMRswGQYDVQQIExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAO BgNVBAcTB1NhbGZvcmQxGDAWBgNVBAoTD1NlY3RpZ28gTGltaXRlZDE3MDUGA1UE AxMuU2VjdGlnbyBSU0EgRG9tYWluIFZhbGlkYXRpb24gU2VjdXJlIFNlcnZlciBD ... Srqh+IFfIKzcHX1eyPxluInUGxxHhVVPeLdzBGL2owLJ/u7YxMkmaiCaCZc9Tugt 1aX61uQWmAUM1I4IhPCj1qKNWt94 -----END CERTIFICATE----- subject=/CN=admin.test.com issuer=/C=GB/ST=Greater Manchester/L=Salford/O=Sectigo Limited/CN=Sectigo RSA Domain Validation Secure Server CA --- No client certificate CA names sent Peer signing digest: SHA512 Server Temp Key: ECDH, P-256, 256 bits --- SSL handshake has read 5278 bytes and written 441 bytes --- New, TLSv1/SSLv3, Cipher is ECDHE-RSA-AES256-GCM-SHA384 Server public key is 2048 bit Secure Renegotiation IS supported Compression: NONE Expansion: NONE No ALPN negotiated SSL-Session: Protocol : TLSv1.2 Cipher : ECDHE-RSA-AES256-GCM-SHA384 Session-ID: 40CFB3F53E5143F85E260CE777CEB6885A184401654EE71CB386FD5D3679D822 Session-ID-ctx: Master-Key: 4FBB5C03A77D33AD14326C272F6D7A61528DA39763067EC27D21FFF13B16CDC71CEBCCF3E8443E5961AC7887F272D3CC Key-Arg : None Krb5 Principal: None PSK identity: None PSK identity hint: None TLS session ticket lifetime hint: 300 (seconds) TLS session ticket: 0000 - c1 a5 66 e3 d5 68 a7 c5-02 29 03 60 12 7d 74 bf ..f..h...).`.}t. 0010 - fe 85 25 0f 76 8a 63 59-9c c7 f2 d4 15 5c 95 fb ..%.v.cY.....\.. 0020 - 37 5b 48 d2 74 45 e5 c5-8b af 09 8a 19 14 69 ea 7[H.tE........i. 0030 - cd 23 52 9b a9 e2 2c cb-0d ab 31 9e a9 b4 5f fd .#R...,...1..._. 0040 - f9 ce bd b3 f8 68 0e 76-56 f8 76 a0 6b b2 85 93 .....h.vV.v.k... 0050 - 49 1e a6 61 16 17 73 b5-2c c9 69 53 a1 b3 b2 bf I..a..s.,.iS.... 0060 - 2c 74 7d 4d a5 c2 8d 00-1f 59 ce a5 c3 13 22 0a ,t}M.....Y....". 0070 - eb 85 33 33 a3 26 32 eb-38 1a 0c 16 c6 74 cb 16 ..33.&2.8....t.. 0080 - 34 2d 57 5c b7 3b 3b 68-22 23 4f 6f 52 d3 4f 3f 4-W\.;;h"#OoR.O? 0090 - e9 6b 87 3b 2a da 2f 8f-4d 21 32 e2 c9 d4 3c 01 .k.;*./.M!2...<. 00a0 - f7 96 36 1f 73 39 8c 80-b9 86 aa 01 b6 7b 57 40 ..6.s9.......{W@ 00b0 - 49 c1 ec 17 96 18 3c 65-2e 10 18 b5 3a 14 5d c9 I.....<e....:.].
# curl -v -u elastic1:XhScf5JqwVsSQwHe= -XGET 'https://172.31.25.229:9200/_cluster/health' * About to connect() to 172.31.25.229 port 9200 (#0) * Trying 172.31.25.229... * Connected to 172.31.25.229 (172.31.25.229) port 9200 (#0) * Initializing NSS with certpath: sql:/etc/pki/nssdb * CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: none * NSS error -12263 (SSL_ERROR_RX_RECORD_TOO_LONG) * SSL received a record that exceeded the maximum permissible length. * Closing connection 0 curl: (35) SSL received a record that exceeded the maximum permissible length.
# curl -v -I https://harbor1.mydomain.com/ * About to connect() to harbor1.mydomain.com port 443 (#0) * Trying 172.31.93.6... * Connected to harbor1.mydomain.com (172.31.93.6) port 443 (#0) * Initializing NSS with certpath: sql:/etc/pki/nssdb * CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: none * Server certificate: * subject: CN=harbor1.mydomain.com * start date: Nov 15 00:00:00 2023 GMT * expire date: Nov 14 23:59:59 2024 GMT * common name: harbor1.mydomain.com * issuer: CN=RapidSSL TLS RSA CA G1,OU=www.digicert.com,O=DigiCert Inc,C=US * NSS error -8179 (SEC_ERROR_UNKNOWN_ISSUER) * Peer's Certificate issuer is not recognized. * Closing connection 0 curl: (60) Peer's Certificate issuer is not recognized. More details here: http://curl.haxx.se/docs/sslcerts.html # docker pull harbor1.mydomain.com/ops/all/cloud-server:master-0.0-20230207143540 Error response from daemon: Get "https://harbor1.mydomain.com/v2/": x509: certificate signed by unknown authority # kubectl describe pod -n ops get-cloud-cdn-pjfsc-hwnpp Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled 22s default-scheduler Successfully assigned ops/get-cloud-cdn-pjfsc-hwnpp to fm-k8s-c1-worker1 Normal BackOff 21s kubelet Back-off pulling image "harbor1.mydomain.com/ops/all/cloud-server-cdn-statistics-code:master-0.0-20230207143540" Warning Failed 21s kubelet Error: ImagePullBackOff Normal Pulling 6s (x2 over 21s) kubelet Pulling image "harbor1.mydomain.com/ops/all/cloud-server-cdn-statistics-code:master-0.0-20230207143540" Warning Failed 6s (x2 over 21s) kubelet Failed to pull image "harbor1.mydomain.com/ops/all/cloud-server-cdn-statistics-code:master-0.0-20230207143540": rpc error: code = Unknown desc = failed to pull and unpack image "harbor1.mydomain.com/ops/all/cloud-server-cdn-statistics-code:master-0.0-20230207143540": failed to resolve reference "harbor1.mydomain.com/ops/all/cloud-server-cdn-statistics-code:master-0.0-20230207143540": failed to do request: Head "https://harbor1.mydomain.com/v2/ops/all/cloud-server-cdn-statistics-code/manifests/master-0.0-20230207143540": x509: certificate signed by unknown authority Warning Failed 6s (x2 over 21s) kubelet Error: ErrImagePull
此问题的主要原因为操作系统层面没有所使用证书的 CA 信息,因此无法验证此证书的合法性。解决办法为刷新操作系统 CA 证书列表,添加异常域名的 CA 信息。操作步骤参考以下过程(本示例基于 Centos7,不同操作系统步骤存储 CA 的位置可能不同),此操作 需要在所有使用此域名的主机系统上进行更新(比如所有的 Kubernetes 节点上)