From 4e196b418a303d3badcb9479e36e949a2daf3d1a Mon Sep 17 00:00:00 2001 From: Frank Terbeck Date: Mon, 21 Sep 2009 13:21:58 +0200 Subject: [PATCH] zshrc: add openssl hash functions Initially written by Axel Beckert, minor changes by me. --- debian/changelog | 6 ++++++ etc/zsh/zshrc | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/debian/changelog b/debian/changelog index 020f1fc..35be720 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +grml-etc-core (0.3.76) UNRELEASED; urgency=low + + * zshrc: add openssl hash functions + + -- Frank Terbeck Mon, 21 Sep 2009 13:20:36 +0200 + grml-etc-core (0.3.75) unstable; urgency=low [ Frank Terbeck ] diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index c7ddace..6221861 100644 --- a/etc/zsh/zshrc +++ b/etc/zsh/zshrc @@ -2985,6 +2985,41 @@ exit 0; return $? } +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 \n' "ssh-cert-${sh}" + return 1 + fi + openssl x509 -noout -fingerprint -${sh} -in $1 + } +done; unset sh + +ssl-cert-fingerprints() { + emulate -L zsh + local i + if [[ -z $1 ]] ; then + printf 'usage: ssl-cert-fingerprints \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 \n' + return 1 + fi + openssl x509 -noout -text -in $1 + ssl-cert-fingerprints $1 +} + # }}} # {{{ make sure our environment is clean regarding colors -- 2.1.4