在做接入器中间件需求时,接入器需要支持cdn通过https协议回源,测试怎么验证证书有没有生效呢?
在/etc/hosts
文件中添加域名映射,如:
172.18.12.21 www.wujiuye.com
不生效输出如下:
wujiuye@wujiuyedeMacBook-Pro ~ % curl -v https://www.wujiuye.com:45689
* Trying 172.18.12.21...
* TCP_NODELAY set
* Connected to www.wujiuye.com (172.18.12.21) port 45689 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/ssl/cert.pem
CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (OUT), TLS alert, certificate unknown (558):
* SSL certificate verification failed
* Closing connection 0
curl: (60) SSL certificate verification failed
More details here: 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. To learn more about this situation and
how to fix it, please visit the web page mentioned above.
生效输出如下
wujiuye@wujiuyedeMacBook-Pro ~ % curl -v https://www.wujiuye.com:45689
* Trying 172.18.12.21...
* TCP_NODELAY set
* Connected to www.wujiuye.com (172.18.12.21) port 45689 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/ssl/cert.pem
CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server accepted to use http/1.1
* Server certificate:
* subject: C=CN; ST=Guangdong; L=Guangzhou; OU=IT Dept.; O=\U5E7F\U5DDE\U8354\U652F\U7F51\U7EDC\U6280\U672F\U6709\U9650\U516C\U53F8; CN=*.wujiuye.com
* start date: May 7 09:14:21 2021 GMT
* expire date: Jun 8 09:14:21 2022 GMT
* subjectAltName: host "www.wujiuye.com" matched cert's "*.wujiuye.com"
* issuer: C=BE; O=GlobalSign nv-sa; CN=GlobalSign RSA OV SSL CA 2018
* SSL certificate verify ok.
> GET / HTTP/1.1
> Host: www.wujiuye.com:45689
> User-Agent: curl/7.64.1
> Accept: */*
>
< HTTP/1.1 404 Not Found
< Connection: keep-alive
< Server: bfe
< Content-Type: text/html; charset=utf-8
< Content-Length: 0
<
* Connection #0 to host www.wujiuye.com left intact
* Closing connection 0