Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSL Certificate Chain Contains RSA Keys Less Than 2048 bits #26

Open
freb opened this issue Oct 14, 2019 · 1 comment
Open

SSL Certificate Chain Contains RSA Keys Less Than 2048 bits #26

freb opened this issue Oct 14, 2019 · 1 comment

Comments

@freb
Copy link
Contributor

freb commented Oct 14, 2019

In order to validate this issue, you have to retrive all intermediate certificates as well. Unfortunately, the Nmap sslcert library only supports retrieving the final cert.

Here is my bash script for validating this:

pt-ssl-cert-rsa-size() {
printf '%s ' 'If you continue, all *.pem files in current directory will be deleted. Are you sure? (y/n) '
read ans
echo
if [[ ! $ans =~ ^[Yy]$ ]]
then
    echo "exiting"
    return
fi

rm *.pem

for host in "$@"; do
    echo "$host:"
    # Download all certs, including intermediate, from HOSTNAME. Files are called cert0.pem, cert1.pem, based on chain number.
    openssl s_client -showcerts -verify 5 -connect "$host":443 < /dev/null | awk '/BEGIN/,/END/{ if(/BEGIN/){a++}; out="cert"a".pem"; print >out}'

    # Loop through downloaded certs and get RSA key sizes.
    for f in *.pem; do
        DATA=$(openssl x509 -in $f -text -noout)
        if echo $DATA | grep --quiet "Public Key Algorithm: rsaEncryption"; then
            echo $DATA | grep "RSA Public-Key:"
        else
            echo "(not RSA)"
        fi
    done
done
}
@freb
Copy link
Contributor Author

freb commented Oct 14, 2019

Note, the nmap ssl-enum-ciphers script actually seems to get all certificates, but it has TODO's for reordering them and further validation.

Look for:

local certs = get_body(handshake, "type", "certificate")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant