| Manuel Pégourié-Gonnard | 1beb048 | 2017-06-05 13:49:44 +0200 | [diff] [blame] | 1 | #!/bin/sh | 
|  | 2 |  | 
|  | 3 | set -eu | 
|  | 4 |  | 
|  | 5 | : ${OPENSSL:=openssl} | 
|  | 6 | NB=20 | 
|  | 7 |  | 
|  | 8 | OPT="-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 | 
|  | 16 | cp 00.crt c00.pem | 
|  | 17 |  | 
|  | 18 | # generate long chain | 
| Manuel Pégourié-Gonnard | 5be13d8 | 2017-07-06 14:31:54 +0200 | [diff] [blame] | 19 | i=1 | 
|  | 20 | while [ $i -le $NB ]; do | 
| Manuel Pégourié-Gonnard | 1beb048 | 2017-06-05 13:49:44 +0200 | [diff] [blame] | 21 | 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é-Gonnard | 5be13d8 | 2017-07-06 14:31:54 +0200 | [diff] [blame] | 34 | i=$((i+1)) | 
| Manuel Pégourié-Gonnard | 1beb048 | 2017-06-05 13:49:44 +0200 | [diff] [blame] | 35 | done |