blob: 011e902ef80cd3e4375e532b8c148648b5728f2f [file] [log] [blame]
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -08001#!/bin/bash
2
3if [ $# -ne 2 ]
4then
5 echo "Usage: $0 alias \"pass phrase\""
6 exit -1
7fi
8
9# Generate a 2048 bit RSA key with public exponent 3.
10# Encrypt private key with provided password.
11openssl genrsa -3 -out $1.pem -passout pass:"$2" 2048
12
13# Create a self-signed cert for this key.
14openssl 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.
20openssl pkcs12 -export -in $1-cert.pem -inkey $1.pem -passin pass:"$2" \
21 -out $1.p12 -name $1 -passout pass:"$2"
22
23rm $1.pem
24rm $1-cert.pem
25