blob: 4e1fd48dc67dd1c369f90fc39f9cd75999570bad [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#
Bence Szépkúti1e148272020-08-07 13:07:28 +02003# Copyright The Mbed TLS Contributors
Dave Rodgman7ff79652023-11-03 12:04:52 +00004# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
Manuel Pégourié-Gonnard1beb0482017-06-05 13:49:44 +02005
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
Manuel Pégourié-Gonnard5be13d82017-07-06 14:31:54 +020022i=1
23while [ $i -le $NB ]; do
Manuel Pégourié-Gonnard1beb0482017-06-05 13:49:44 +020024 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
Manuel Pégourié-Gonnard5be13d82017-07-06 14:31:54 +020037 i=$((i+1))
Manuel Pégourié-Gonnard1beb0482017-06-05 13:49:44 +020038done