mirror of https://github.com/jacekkow/uphpCAS-tests

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