You are not logged in.
Pages: 1
Hey guys, so i'm not sure the syntax on this but I have the base ready. So what i'm doing is making a script to check for SSL's on a domain. So I have this
 #/bin/bash
for dir in $(ls)
do
        echo $dir
        curl -Iv https://$dir --connect-timeout 5
done Just not sure how to get it to only show me if it has a ssl or not, I was thinking some sort of if elif using a grep for 'SSL connect error' but not sure on the syntax to do so any suggestions?  
thanks 
Last edited by hauntedbyshadow (2014-08-05 14:41:51)
Offline

When you try to connect to a server which doesn't support https, you'll get a connection refused error, for example:
$ curl -I https://distrowatch.com
curl: (7) Failed to connect to distrowatch.com port 443: Connection refusedSo you can just check for the exit status and print a statement accordingly.
Here's one example script:
#!/usr/bin/env bash
urls=(https://distrowatch.com https://sphinx-doc.org https://www.archlinux.org)
for url in ${urls[@]}; do
    curl -I "$url" > /dev/null 2>&1
    if [[ $? -ne 7 ]]; then
        echo "SSL present for $url"
    else
        echo "SSL not present for $url"
    fi
doneNote: urls above is an array, and you'll need to separate the actual urls using spaces.
Last edited by x33a (2014-08-05 13:57:22)
Offline
Wow that is exactly what I was looking for brilliant, Thanks a bunch 
Offline
Pages: 1