BTS

Message2493

Author ft
Recipients abe, mika
Date 2009-09-21.10:45:55
Content
Michael Prokop <bts@bts.grml.org>:
> Frank, can you please review? Maybe we should add some simple usage information 
> if $1 is missing?

Yes, I can[tm].

I'd do it like this:

[snip]
ssl_hashes=( sha512 sha256 sha1 md5 )

for sh in ${ssl_hashes}; do
    ssl-cert-${sh}() {
        emulate -L zsh
        if [[ -z $1 ]] ; then
            printf 'usage: %s <hash-name>\n' "ssh-cert-${sh}"
            printf '  where "hash-name" is one of: %s\n' "${ssl_hashes}"
            return 1
        fi
        openssl x509 -noout -fingerprint -${sh} -in $1
    }
done

ssl-cert-fingerprints() {
    emulate -L zsh
    if [[ -z $1 ]] ; then
        printf 'usage: ssl-cert-fingerprints <file>\n'
        return 1
    fi
    for i in ${ssl_hashes}
        do ssl-cert-$i $1;
    done
}

ssl-cert-info() {
    emulate -L zsh
    if [[ -z $1 ]] ; then
        printf 'usage: ssl-cert-info <file>\n'
        return 1
    fi
    openssl x509 -noout -text -in $1 
    ssl-cert-fingerprints $1
}
[snap]

I thinks that's reasonable.

Also note, that I was assuming for ssl-cert-fingerprints() and
ssl-cert-info() to take a *file* as their sole argument. I got no idea
about the workings of openssl. I'm really just a DAU with it.

Anyway, this is my take on the subject.

Regards, Frank
History
Date User Action Args
2009-09-21 10:46:01ftlinkissue741 messages
2009-09-21 10:45:56ftcreate