Last active
November 21, 2018 00:24
-
-
Save voiski/cc33190234585b895cbf7fccd4f28f8b to your computer and use it in GitHub Desktop.
Extract certificate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Extract certificate from the target domain. | |
# Usage: | |
# ./extract_certificate.sh {{domain name}} {{target port:default 443}} | |
# Example: | |
# curl -L https://git.io/fp8Za | bash -s google.com | |
# curl -L https://git.io/fp8Za | bash -s google.com 443 | |
target=$1 | |
port=${2:-443} | |
docker run --rm frapsoft/openssl s_client \ | |
-connect ${target}:${port} 2>/dev/null </dev/null \ | |
| sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' \ | |
> ${target}.crt | |
ls -l ${target}.crt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment