File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change 17
17
# Generates a public/private key pair suitable for use in signing
18
18
# android .apks and OTA update packages.
19
19
20
- if [ " $# " -ne 2 ]; then
20
+ if [ " $# " -lt 2 -o " $# " -gt 3 ]; then
21
21
cat << EOF
22
- Usage: $0 <name> <subject>
22
+ Usage: $0 <name> <subject> [<keytype>]
23
23
24
24
Creates <name>.pk8 key and <name>.x509.pem cert. Cert contains the
25
- given <subject>.
25
+ given <subject>. A keytype of "rsa" or "ec" is accepted.
26
26
EOF
27
27
exit 2
28
28
fi
@@ -49,9 +49,18 @@ chmod 0600 ${one} ${two}
49
49
read -p " Enter password for '$1 ' (blank for none; password will be visible): " \
50
50
password
51
51
52
- ( openssl genrsa -f4 2048 | tee ${one} > ${two} ) &
52
+ if [ " ${3} " = " rsa" -o " $# " -eq 2 ]; then
53
+ ( openssl genrsa -f4 2048 | tee ${one} > ${two} ) &
54
+ hash=" -sha1"
55
+ elif [ " ${3} " = " ec" ]; then
56
+ ( openssl ecparam -name prime256v1 -genkey -noout | tee ${one} > ${two} ) &
57
+ hash=" -sha256"
58
+ else
59
+ echo " Only accepts RSA or EC keytypes."
60
+ exit 1
61
+ fi
53
62
54
- openssl req -new -x509 -sha1 -key ${two} -out $1 .x509.pem \
63
+ openssl req -new -x509 ${hash} -key ${two} -out $1 .x509.pem \
55
64
-days 10000 -subj " $2 " &
56
65
57
66
if [ " ${password} " == " " ]; then
You can’t perform that action at this time.
0 commit comments