X-Git-Url: http://gitweb.pimeys.fr/?a=blobdiff_plain;f=.zsh%2Frc%2Fextra%2F20_ssl_tools;fp=.zsh%2Frc%2Fextra%2F20_ssl_tools;h=1ff51c8854d9bd9a2808b8ec092065f4ef641204;hb=3d71eab53c5b63556363ece880859b0af7f162da;hp=0000000000000000000000000000000000000000;hpb=1f8b08895681d46802368eec0764ca70d08898ca;p=config-20-100.git diff --git a/.zsh/rc/extra/20_ssl_tools b/.zsh/rc/extra/20_ssl_tools new file mode 100644 index 0000000..1ff51c8 --- /dev/null +++ b/.zsh/rc/extra/20_ssl_tools @@ -0,0 +1,57 @@ +#!/bin/zsh + +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 +} + +# I hate lacking backward compatibility, so provide an alternative therefore +if ! check_com -c apache2-ssl-certificate ; then + + apache2-ssl-certificate() { + + print 'Debian does not ship apache2-ssl-certificate anymore (see #398520). :(' + print 'You might want to take a look at Debian the package ssl-cert as well.' + print 'To generate a certificate for use with apache2 follow the instructions:' + + echo ' + +export RANDFILE=/dev/random +mkdir /etc/apache2/ssl/ +openssl req $@ -new -x509 -days 365 -nodes -out /etc/apache2/ssl/apache.pem -keyout /etc/apache2/ssl/apache.pem +chmod 600 /etc/apache2/ssl/apache.pem + +Run "grml-tips ssl-certificate" if you need further instructions. +' + } +fi