Download a certificate from a web page via CLI

Download a certificate from a web page via CLI

I wanted to download the Certificate from a Kubernetes API Server, so I thought to download it from the https page, but then I have to use it in the CLI, so I searched a way to do it all from bash, this is what I found:

openssl s_client -showcerts -connect server.domain:443 </dev/null 2>/dev/null|openssl x509 -outform PEM >mycertfile.pem

You can use the openssl command line utility to download it and save it as file.