blob: 22f3bf548e451cec25dffea8cbb7c9e75ad02144 [file] [log] [blame]
Manuel Pégourié-Gonnard1beb0482017-06-05 13:49:44 +02001#!/bin/sh
2
3set -eu
4
5: ${OPENSSL:=openssl}
6NB=20
7
8OPT="-days 3653 -sha256"
9
10# generate self-signed root
11$OPENSSL ecparam -name prime256v1 -genkey -out 00.key
12$OPENSSL req -new -x509 -subj "/C=UK/O=mbed TLS/CN=CA00" $OPT \
13 -key 00.key -out 00.crt
14
15# cXX.pem is the chain starting at XX
16cp 00.crt c00.pem
17
18# generate long chain
Manuel Pégourié-Gonnard5be13d82017-07-06 14:31:54 +020019i=1
20while [ $i -le $NB ]; do
Manuel Pégourié-Gonnard1beb0482017-06-05 13:49:44 +020021 UP=$( printf "%02d" $((i-1)) )
22 ME=$( printf "%02d" $i )
23
24 $OPENSSL ecparam -name prime256v1 -genkey -out ${ME}.key
25 $OPENSSL req -new -subj "/C=UK/O=mbed TLS/CN=CA${ME}" \
26 -key ${ME}.key -out ${ME}.csr
27 $OPENSSL x509 -req -CA ${UP}.crt -CAkey ${UP}.key -set_serial 1 $OPT \
28 -extfile int.opensslconf -extensions int \
29 -in ${ME}.csr -out ${ME}.crt
30
31 cat ${ME}.crt c${UP}.pem > c${ME}.pem
32
33 rm ${ME}.csr
Manuel Pégourié-Gonnard5be13d82017-07-06 14:31:54 +020034 i=$((i+1))
Manuel Pégourié-Gonnard1beb0482017-06-05 13:49:44 +020035done