summaryrefslogtreecommitdiff
path: root/packages/web-util/create_certificate.sh
blob: 980aaf6428c679ced3ffcf892f8817e3589247f9 (plain)
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
#!/usr/bin/env bash
set -eu
org=localhost-ca
domain=localhost

rm -rf keys
mkdir keys
cd keys

openssl genpkey -algorithm RSA -out ca.key
openssl req -x509 -key ca.key -out ca.crt \
    -subj "/CN=$org/O=$org"

openssl genpkey -algorithm RSA -out "$domain".key
openssl req -new -key "$domain".key -out "$domain".csr \
    -subj "/CN=$domain/O=$org"

openssl x509 -req -in "$domain".csr -days 365 -out "$domain".crt \
    -CA ca.crt -CAkey ca.key -CAcreateserial \
    -extfile <(cat <<END
basicConstraints = CA:FALSE
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid,issuer
subjectAltName = DNS:$domain
END
    )

sudo cp ca.crt /usr/local/share/ca-certificates/testing.crt
sudo update-ca-certificates


echo '
## Chrome  
1. go to chrome://settings/certificates
2. tab "authorities"
3. button "import" 
4. choose "ca.crt"
5. trust for identify websites

## Firefox
1. go to about:preferences#privacy
2. button "view certificates"
3. button "import"
4. choose "ca.crt"
5. trust for identify websites
'

echo done!