Manuel Pégourié-Gonnard | 1beb048 | 2017-06-05 13:49:44 +0200 | [diff] [blame] | 1 | #!/bin/sh |
Bence Szépkúti | 700ee44 | 2020-05-26 00:33:31 +0200 | [diff] [blame^] | 2 | # |
| 3 | # Copyright (C) 2017, Arm Limited, All Rights Reserved |
| 4 | # |
| 5 | # This file is part of Mbed TLS (https://tls.mbed.org) |
Manuel Pégourié-Gonnard | 1beb048 | 2017-06-05 13:49:44 +0200 | [diff] [blame] | 6 | |
| 7 | set -eu |
| 8 | |
| 9 | : ${OPENSSL:=openssl} |
| 10 | NB=20 |
| 11 | |
| 12 | OPT="-days 3653 -sha256" |
| 13 | |
| 14 | # generate self-signed root |
| 15 | $OPENSSL ecparam -name prime256v1 -genkey -out 00.key |
| 16 | $OPENSSL req -new -x509 -subj "/C=UK/O=mbed TLS/CN=CA00" $OPT \ |
| 17 | -key 00.key -out 00.crt |
| 18 | |
| 19 | # cXX.pem is the chain starting at XX |
| 20 | cp 00.crt c00.pem |
| 21 | |
| 22 | # generate long chain |
Manuel Pégourié-Gonnard | 5be13d8 | 2017-07-06 14:31:54 +0200 | [diff] [blame] | 23 | i=1 |
| 24 | while [ $i -le $NB ]; do |
Manuel Pégourié-Gonnard | 1beb048 | 2017-06-05 13:49:44 +0200 | [diff] [blame] | 25 | UP=$( printf "%02d" $((i-1)) ) |
| 26 | ME=$( printf "%02d" $i ) |
| 27 | |
| 28 | $OPENSSL ecparam -name prime256v1 -genkey -out ${ME}.key |
| 29 | $OPENSSL req -new -subj "/C=UK/O=mbed TLS/CN=CA${ME}" \ |
| 30 | -key ${ME}.key -out ${ME}.csr |
| 31 | $OPENSSL x509 -req -CA ${UP}.crt -CAkey ${UP}.key -set_serial 1 $OPT \ |
| 32 | -extfile int.opensslconf -extensions int \ |
| 33 | -in ${ME}.csr -out ${ME}.crt |
| 34 | |
| 35 | cat ${ME}.crt c${UP}.pem > c${ME}.pem |
| 36 | |
| 37 | rm ${ME}.csr |
Manuel Pégourié-Gonnard | 5be13d8 | 2017-07-06 14:31:54 +0200 | [diff] [blame] | 38 | i=$((i+1)) |
Manuel Pégourié-Gonnard | 1beb048 | 2017-06-05 13:49:44 +0200 | [diff] [blame] | 39 | done |