blob: 19794980f83f0bbb0e38259117131b515f8d4383 [file] [log] [blame]
Manuel Pégourié-Gonnard1beb0482017-06-05 13:49:44 +02001#!/bin/sh
Bence Szépkúti700ee442020-05-26 00:33:31 +02002#
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é-Gonnard1beb0482017-06-05 13:49:44 +02006
7set -eu
8
9: ${OPENSSL:=openssl}
10NB=20
11
12OPT="-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
20cp 00.crt c00.pem
21
22# generate long chain
Manuel Pégourié-Gonnard5be13d82017-07-06 14:31:54 +020023i=1
24while [ $i -le $NB ]; do
Manuel Pégourié-Gonnard1beb0482017-06-05 13:49:44 +020025 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é-Gonnard5be13d82017-07-06 14:31:54 +020038 i=$((i+1))
Manuel Pégourié-Gonnard1beb0482017-06-05 13:49:44 +020039done