]> gitweb.pimeys.fr Git - config-20-100.git/blob - .zsh/rc/extra/20_ssl_tools
Ajout du zshrc, même s'il manque encore de commentaires etc.
[config-20-100.git] / .zsh / rc / extra / 20_ssl_tools
1 #!/bin/zsh
2
3 ssl_hashes=( sha512 sha256 sha1 md5 )
4
5 for sh in ${ssl_hashes}; do
6 ssl-cert-${sh}() {
7 emulate -L zsh
8 if [[ -z $1 ]] ; then
9 printf 'usage: %s <file>\n' "ssh-cert-${sh}"
10 return 1
11 fi
12 openssl x509 -noout -fingerprint -${sh} -in $1
13 }
14 done; unset sh
15
16 ssl-cert-fingerprints() {
17 emulate -L zsh
18 local i
19 if [[ -z $1 ]] ; then
20 printf 'usage: ssl-cert-fingerprints <file>\n'
21 return 1
22 fi
23 for i in ${ssl_hashes}
24 do ssl-cert-$i $1;
25 done
26 }
27
28 ssl-cert-info() {
29 emulate -L zsh
30 if [[ -z $1 ]] ; then
31 printf 'usage: ssl-cert-info <file>\n'
32 return 1
33 fi
34 openssl x509 -noout -text -in $1
35 ssl-cert-fingerprints $1
36 }
37
38 # I hate lacking backward compatibility, so provide an alternative therefore
39 if ! check_com -c apache2-ssl-certificate ; then
40
41 apache2-ssl-certificate() {
42
43 print 'Debian does not ship apache2-ssl-certificate anymore (see #398520). :('
44 print 'You might want to take a look at Debian the package ssl-cert as well.'
45 print 'To generate a certificate for use with apache2 follow the instructions:'
46
47 echo '
48
49 export RANDFILE=/dev/random
50 mkdir /etc/apache2/ssl/
51 openssl req $@ -new -x509 -days 365 -nodes -out /etc/apache2/ssl/apache.pem -keyout /etc/apache2/ssl/apache.pem
52 chmod 600 /etc/apache2/ssl/apache.pem
53
54 Run "grml-tips ssl-certificate" if you need further instructions.
55 '
56 }
57 fi