[issue741] zsh aliases for displaying ssl certificate information/fingerprints

Frank Terbeck bts at bts.grml.org
Mon Sep 21 12:46:01 CEST 2009


Frank Terbeck <ft at grml.org> added the comment:

Michael Prokop <bts at 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

----------
messages: 2491, 2492, 2493
nosy: abe, ft, mika
priority: wish
status: chatting
title: zsh aliases for displaying ssl certificate information/fingerprints
topic: grml-etc-core, zsh

_____________________________________
GRML issue tracker <bts at bts.grml.org>
<http://bts.grml.org/grml/issue741>
_____________________________________


More information about the Bugs-changes mailing list