Modify client hello version when renegotiating to enhance interop with
[openssl.git] / demos / certs / mkcerts.sh
1 #!/bin/sh
2
3 OPENSSL=../../apps/openssl
4 OPENSSL_CONF=../../apps/openssl.cnf
5 export OPENSSL_CONF
6
7 # Root CA: create certificate directly
8 CN="Test Root CA" $OPENSSL req -config ca.cnf -x509 -nodes \
9         -keyout root.pem -out root.pem -newkey rsa:2048 -days 3650
10 # Server certificate: create request first
11 CN="Test Server Cert" $OPENSSL req -config ca.cnf -nodes \
12         -keyout skey.pem -out req.pem -newkey rsa:1024
13 # Sign request: end entity extensions
14 $OPENSSL x509 -req -in req.pem -CA root.pem -days 3600 \
15         -extfile ca.cnf -extensions usr_cert -CAcreateserial -out server.pem
16 # Intermediate CA: request first
17 CN="Test Intermediate CA" $OPENSSL req -config ca.cnf -nodes \
18         -keyout intkey.pem -out intreq.pem -newkey rsa:2048
19 # Sign request: CA extensions
20 $OPENSSL x509 -req -in intreq.pem -CA root.pem -days 3600 \
21         -extfile ca.cnf -extensions v3_ca -CAcreateserial -out intca.pem
22 # Client certificate: request first
23 CN="Test Client Cert" $OPENSSL req -config ca.cnf -nodes \
24         -keyout ckey.pem -out creq.pem -newkey rsa:1024
25 # Sign using intermediate CA
26 $OPENSSL x509 -req -in creq.pem -CA intca.pem -CAkey intkey.pem -days 3600 \
27         -extfile ca.cnf -extensions usr_cert -CAcreateserial -out client.pem
28
29 # Example creating a PKCS#3 DH certificate. 
30
31 # First DH parameters
32
33 $OPENSSL genpkey -genparam -algorithm DH -pkeyopt dh_paramgen_prime_len:1024 -out dhp.pem
34
35 # Uncomment out this line for X9.42 DH parameters instead
36 $OPENSSL genpkey -genparam -algorithm DH -out dhp.pem -pkeyopt dh_rfc5114:2
37
38 # Now a DH private key
39 $OPENSSL genpkey -paramfile dhp.pem -out dhskey.pem
40 # Create DH public key file
41 $OPENSSL pkey -in dhskey.pem -pubout -out dhspub.pem
42 # Certificate request, key just reuses old one as it is ignored when the
43 # request is signed.
44 CN="Test Server DH Cert" $OPENSSL req -config ca.cnf -new \
45         -key skey.pem -out dhsreq.pem
46 # Sign request: end entity DH extensions
47 $OPENSSL x509 -req -in dhsreq.pem -CA root.pem -days 3600 \
48         -force_pubkey dhspub.pem \
49         -extfile ca.cnf -extensions dh_cert -CAcreateserial -out dhserver.pem
50
51 # DH client certificate
52
53 $OPENSSL genpkey -paramfile dhp.pem -out dhckey.pem
54 $OPENSSL pkey -in dhckey.pem -pubout -out dhcpub.pem
55 CN="Test Client DH Cert" $OPENSSL req -config ca.cnf -new \
56         -key skey.pem -out dhcreq.pem
57 $OPENSSL x509 -req -in dhcreq.pem -CA root.pem -days 3600 \
58         -force_pubkey dhcpub.pem \
59         -extfile ca.cnf -extensions dh_cert -CAcreateserial -out dhclient.pem