commit | author | age
|
5686c9
|
1 |
#!/bin/bash |
JK |
2 |
|
aec94b
|
3 |
set -e |
80d5f7
|
4 |
|
aec94b
|
5 |
function genAndSign() { |
JK |
6 |
local cn=$1 |
|
7 |
local file=$2 |
|
8 |
openssl genrsa -out "/tmp/${file}.key" 2048 |
|
9 |
openssl req -new -key "/tmp/${file}.key" -out "/tmp/${file}.csr" -subj "/CN=${cn}/" |
|
10 |
openssl x509 -req -in "/tmp/${file}.csr" -out "/tmp/${file}.crt" \ |
|
11 |
-CA /tmp/ca.crt -CAkey /tmp/ca.key -CAcreateserial |
|
12 |
cat "/tmp/${file}.crt" "/tmp/${file}.key" > "/tmp/${file}.pem" |
|
13 |
} |
5686c9
|
14 |
|
aec94b
|
15 |
openssl genrsa -out /tmp/ca.key 2048 |
JK |
16 |
openssl req -new -key /tmp/ca.key -out /tmp/ca.crt -subj '/CN=Test CA/' -x509 |
5686c9
|
17 |
|
aec94b
|
18 |
genAndSign "127.0.0.1" "correct" |
JK |
19 |
genAndSign "127.0.0.2" "wrongcn" |