-
Notifications
You must be signed in to change notification settings - Fork 1
/
pemTOder.sh
executable file
·54 lines (40 loc) · 1.12 KB
/
pemTOder.sh
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
#!/bin/bash
export flgin=0
export flgfiletype=0
export flgout=0
export out=""
export in=""
export filetype=""
for arg in "$@"
do
if [ "$flgfiletype" == 1 ]; then
filetype=$arg
flgfiletype=0
fi
if [ "$flgout" == 1 ]; then
out=$arg
flgout=0
fi
if [ "$flgin" == 1 ]; then
in=$arg
flgin=0
fi
if [ "$arg" == "--filetype" ] || [ "$arg" == "-filetype" ]; then
flgfiletype=1
fi
if [ "$arg" == "--in" ] || [ "$arg" == "-in" ]; then
flgin=1
fi
if [ "$arg" == "--out" ] || [ "$arg" == "-out" ]; then
flgout=1
fi
done
if [ "$filetype" == "key" ] || [ "$filetype" == "KEY" ]; then
openssl ec -in $in -outform DER -out $out
fi
if [ "$filetype" == "cert" ] || [ "$filetype" == "CERT" ] || [ "$filetype" == "certificate" ] || [ "$filetype" == "CERTIFICATE" ]; then
openssl x509 -outform der -in $in -out $out
fi
if [ "$filetype" != "key" ] && [ "$filetype" != "KEY" ] && [ "$filetype" != "cert" ] && [ "$filetype" != "CERT" ] && [ "$filetype" != "certificate" ] && [ "$filetype" != "CERTIFICATE" ]; then
echo Please specify filetype : key/cert !!
fi