You can use the following syntax:
getcerts google.com 443
getcerts google.com
Place the following line in your aliases file:
alias getcerts='function _getcerts() { echo | openssl s_client -connect "${1}:${2:-443}" | sed -n "/-----BEGIN CERTIFICATE-----/,/-----END CERTIFICATE-----/p"; }; _getcerts '