Your sed
command is only capturing openssl s_client
's standard output, but the certificate comes with the other debugging information on standard error. Have you tried something like this?
openssl s_client -connect google.com:443 </dev/null 2>&1 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | openssl x509 -outform DER >/tmp/google.com.der