1#!/bin/sh 2# 3# Copyright The Mbed TLS Contributors 4# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 5 6set -eu 7 8: ${OPENSSL:=openssl} 9NB=20 10 11OPT="-days 3653 -sha256" 12 13# generate self-signed root 14$OPENSSL ecparam -name prime256v1 -genkey -out 00.key 15$OPENSSL req -new -x509 -subj "/C=UK/O=mbed TLS/CN=CA00" $OPT \ 16 -key 00.key -out 00.crt 17 18# cXX.pem is the chain starting at XX 19cp 00.crt c00.pem 20 21# generate long chain 22i=1 23while [ $i -le $NB ]; do 24 UP=$( printf "%02d" $((i-1)) ) 25 ME=$( printf "%02d" $i ) 26 27 $OPENSSL ecparam -name prime256v1 -genkey -out ${ME}.key 28 $OPENSSL req -new -subj "/C=UK/O=mbed TLS/CN=CA${ME}" \ 29 -key ${ME}.key -out ${ME}.csr 30 $OPENSSL x509 -req -CA ${UP}.crt -CAkey ${UP}.key -set_serial 1 $OPT \ 31 -extfile int.opensslconf -extensions int \ 32 -in ${ME}.csr -out ${ME}.crt 33 34 cat ${ME}.crt c${UP}.pem > c${ME}.pem 35 36 rm ${ME}.csr 37 i=$((i+1)) 38done 39