The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | if [ $# -ne 2 ] |
| 4 | then |
| 5 | echo "Usage: $0 alias \"pass phrase\"" |
| 6 | exit -1 |
| 7 | fi |
| 8 | |
| 9 | # Generate a 2048 bit RSA key with public exponent 3. |
| 10 | # Encrypt private key with provided password. |
| 11 | openssl genrsa -3 -out $1.pem -passout pass:"$2" 2048 |
| 12 | |
| 13 | # Create a self-signed cert for this key. |
| 14 | openssl req -new -x509 -key $1.pem -passin pass:"$2" \ |
| 15 | -out $1-cert.pem \ |
| 16 | -batch -days 10000 |
| 17 | |
| 18 | # Create a PKCS12 store containing the generated private key. |
| 19 | # Protect the keystore and the private key with the provided password. |
| 20 | openssl pkcs12 -export -in $1-cert.pem -inkey $1.pem -passin pass:"$2" \ |
| 21 | -out $1.p12 -name $1 -passout pass:"$2" |
| 22 | |
| 23 | rm $1.pem |
| 24 | rm $1-cert.pem |
| 25 | |