[PATCH] zshrc: add openssl hash functions

Frank Terbeck ft at bewatermyfriend.org
Mon Sep 21 13:21:58 CEST 2009


Initially written by mika at grml.org, fixed up a little by me.
---

Frank Terbeck <ft at bewatermyfriend.org>:
> Michael Prokop <bts at bts.grml.org>:
> > Frank, can you please review? Maybe we should add some simple usage inf=
ormation=20
> > if $1 is missing?
[...]
>=20
> I'd do it like this:
[...]

Well, here's what I got in my repo now.

I'll happily push it, if people *test* and ACK this. - I didn't test
this!

Also, I would like new stuff to go in only with accompanying
documentation in doc/grmlzshrc.t2t of grml-etc-core's zshrc5 branch.

Someone who knows what the functions from this patch actually do
should write entries for them.

The guy who already writes the manual entries for the *existing* code
shouldn't be burdened with documenting *new* code, too.

So: Pretty please. :-)

Regards, Frank

 debian/changelog |    6 ++++++
 etc/zsh/zshrc    |   36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 0 deletions(-)

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=3Dlow
+
+  * zshrc: add openssl hash functions
+
+ -- Frank Terbeck <ft at grml.org>  Mon, 21 Sep 2009 13:20:36 +0200
+
 grml-etc-core (0.3.75) unstable; urgency=3Dlow
=20
   [ Frank Terbeck ]
diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc
index c7ddace..0cd52bd 100644
--- a/etc/zsh/zshrc
+++ b/etc/zsh/zshrc
@@ -2985,6 +2985,42 @@ exit 0;
     return $?
 }
=20
+ssl_hashes=3D( 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; unset sh
+
+ssl-cert-fingerprints() {
+    emulate -L zsh
+    local i
+    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
+}
+
 # }}}
=20
 # {{{ make sure our environment is clean regarding colors
--=20
1.6.5.rc0

----------
messages: 2491, 2492, 2493, 2494
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