-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.bash_functions.openssl
64 lines (62 loc) · 1.69 KB
/
.bash_functions.openssl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# vim: ft=bash noet:
! declare 2>&1 | \grep -wq ^colors= && [ $BASH_VERSINFO -ge 4 ] && source $initDir/.colors
test "$debug" -gt 0 && echo "=> Running $bold${colors[blue]}$(basename ${BASH_SOURCE[0]})$normal ..."
function viewAllCertsSummary {
for cert
do
while openssl x509 -noout -subject -issuer -dates
do
printf -- "-%.0s" {1..45};echo
done < $cert
done
}
function downloadCert {
local URL=$1
local port=$2
openssl s_client -connect "$URL":$port </dev/null 2>/dev/null | openssl x509
}
function downloadIntermediateCert {
local URL=$1
local port=$2
openssl s_client -connect "$URL":$port -showcerts </dev/null 2>/dev/null | awk '/BEGIN CERTIFICATE/,/END CERTIFICATE/{ if(/BEGIN CERTIFICATE/)a++;if(a==2)print}'
}
function viewCertificateValidity {
for cerCertificate
do
echo "=> cerCertificate = $cerCertificate :"
openssl x509 -in "$cerCertificate" -noout -dates
done
}
function der2pem {
for cerCertificate
do
openssl x509 -in "$cerCertificate" -outform PEM -out "${cerCertificate/.pem/.cer}"
ls -l "${cerCertificate/.pem/.cer}"
done
}
function pem2der {
for pemCertificate
do
openssl x509 -in "$pemCertificate" -outform DER -out "${pemCertificate/.pem/.cer}"
ls -l "${pemCertificate/.pem/.cer}"
echo
done
}
function pem2keyPEM {
for pemCertificate
do
openssl pkey -in "$pemCertificate" -outform PEM -out "${pemCertificate/.pem/.key}"
ls -l "${pemCertificate/.pem/.key}"
echo
done
}
function pem2keyDER {
for pemCertificate
do
openssl pkey -in "$pemCertificate" -outform DER -out "${pemCertificate/.pem/.key}"
ls -l "${pemCertificate/.pem/.key}"
echo
done
}
set +x
test "$debug" -gt 0 && echo "=> END of $bold${colors[blue]}$(basename ${BASH_SOURCE[0]})$normal"