-
Notifications
You must be signed in to change notification settings - Fork 0
/
openssl-create-self-signed-key
executable file
·80 lines (64 loc) · 1.44 KB
/
openssl-create-self-signed-key
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/sh
#
# This is a wrapper script for making self-signed certificates
#
#
# Make errors be fatal.
#
set -e
if test ! "$1"
then
echo "Syntax: $0 basename"
exit 1
fi
BASENAME=$1
#
# Our secret key
#
KEY="${BASENAME}.key"
#
# Our certificate signing request (we won't need this)
#
CSR="${BASENAME}.csr"
#
# Our self-signed certificate
#
CERTIFICATE="${BASENAME}.crt"
KEYSIZE=2048
#
# Don't worry about the password here. The assumption
# is that only yourself and root will have access to this key.
#
echo "#"
echo "#"
echo "# About to generate private key"
echo "#"
echo "#"
openssl genrsa -des3 -passout pass:12345 -out ${KEY} ${KEYSIZE}
echo "#"
echo "#"
echo "# About to create certificate signing request"
echo "# For these questions, if the key is being used for AWS or anywhere BUT a public server, you can just mash the enter key."
echo "#"
echo "#"
openssl req -new -passin pass:12345 -key ${KEY} -out ${CSR}
#
# This will remove the passphrase from the key
#
cp ${KEY} ${KEY}.orig
openssl rsa -passin pass:12345 -in ${KEY}.orig -out ${KEY}
rm -f ${KEY}.orig
echo "#"
echo "#"
echo "# Creating the self-signed certificate."
echo "#"
echo "#"
openssl x509 -req -days 365 -in ${CSR} -signkey ${KEY} -out ${CERTIFICATE}
echo "#"
echo "#"
echo "# All done! Here are your files:"
echo "# Private key: ${KEY}"
echo "# Certificate: ${CERTIFICATE}"
echo "# Certtificate signing request: ${CSR} (In case you want this signed later)"
echo "#"
echo "#"