KB: OpenSSL - Get certificate as file
Export the SSL certificate(s) of a server to a .pem
file:
1TARGET_HOST="fqdn_of_target_host"
2TARGET_PORT="443"
3openssl s_client -showcerts -connect $TARGET_HOST:$TARGET_PORT </dev/null 2>/dev/null|openssl x509 -outform PEM > $TARGET_HOST.pem