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 |
Bence Szépkúti | c7da1fe | 2020-05-26 01:54:15 +0200 | [diff] [blame^] | 4 | # SPDX-License-Identifier: Apache-2.0 |
| 5 | # |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 7 | # not use this file except in compliance with the License. |
| 8 | # You may obtain a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 14 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | # See the License for the specific language governing permissions and |
| 16 | # limitations under the License. |
Bence Szépkúti | 700ee44 | 2020-05-26 00:33:31 +0200 | [diff] [blame] | 17 | # |
| 18 | # 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] | 19 | |
| 20 | set -eu |
| 21 | |
| 22 | : ${OPENSSL:=openssl} |
| 23 | NB=20 |
| 24 | |
| 25 | OPT="-days 3653 -sha256" |
| 26 | |
| 27 | # generate self-signed root |
| 28 | $OPENSSL ecparam -name prime256v1 -genkey -out 00.key |
| 29 | $OPENSSL req -new -x509 -subj "/C=UK/O=mbed TLS/CN=CA00" $OPT \ |
| 30 | -key 00.key -out 00.crt |
| 31 | |
| 32 | # cXX.pem is the chain starting at XX |
| 33 | cp 00.crt c00.pem |
| 34 | |
| 35 | # generate long chain |
Manuel Pégourié-Gonnard | 5be13d8 | 2017-07-06 14:31:54 +0200 | [diff] [blame] | 36 | i=1 |
| 37 | while [ $i -le $NB ]; do |
Manuel Pégourié-Gonnard | 1beb048 | 2017-06-05 13:49:44 +0200 | [diff] [blame] | 38 | UP=$( printf "%02d" $((i-1)) ) |
| 39 | ME=$( printf "%02d" $i ) |
| 40 | |
| 41 | $OPENSSL ecparam -name prime256v1 -genkey -out ${ME}.key |
| 42 | $OPENSSL req -new -subj "/C=UK/O=mbed TLS/CN=CA${ME}" \ |
| 43 | -key ${ME}.key -out ${ME}.csr |
| 44 | $OPENSSL x509 -req -CA ${UP}.crt -CAkey ${UP}.key -set_serial 1 $OPT \ |
| 45 | -extfile int.opensslconf -extensions int \ |
| 46 | -in ${ME}.csr -out ${ME}.crt |
| 47 | |
| 48 | cat ${ME}.crt c${UP}.pem > c${ME}.pem |
| 49 | |
| 50 | rm ${ME}.csr |
Manuel Pégourié-Gonnard | 5be13d8 | 2017-07-06 14:31:54 +0200 | [diff] [blame] | 51 | i=$((i+1)) |
Manuel Pégourié-Gonnard | 1beb048 | 2017-06-05 13:49:44 +0200 | [diff] [blame] | 52 | done |