Manuel Pégourié-Gonnard | 1beb048 | 2017-06-05 13:49:44 +0200 | [diff] [blame] | 1 | #!/bin/sh |
Bence Szépkúti | 468a76f | 2020-05-26 00:33:31 +0200 | [diff] [blame] | 2 | # |
Bence Szépkúti | a2947ac | 2020-08-19 16:37:36 +0200 | [diff] [blame^] | 3 | # Copyright The Mbed TLS Contributors |
Bence Szépkúti | f744bd7 | 2020-06-05 13:02:18 +0200 | [diff] [blame] | 4 | # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later |
| 5 | # |
| 6 | # This file is provided under the Apache License 2.0, or the |
| 7 | # GNU General Public License v2.0 or later. |
| 8 | # |
| 9 | # ********** |
| 10 | # Apache License 2.0: |
Bence Szépkúti | 51b41d5 | 2020-05-26 01:54:15 +0200 | [diff] [blame] | 11 | # |
| 12 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 13 | # not use this file except in compliance with the License. |
| 14 | # You may obtain a copy of the License at |
| 15 | # |
| 16 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 17 | # |
| 18 | # Unless required by applicable law or agreed to in writing, software |
| 19 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 20 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 21 | # See the License for the specific language governing permissions and |
| 22 | # limitations under the License. |
Bence Szépkúti | 468a76f | 2020-05-26 00:33:31 +0200 | [diff] [blame] | 23 | # |
Bence Szépkúti | f744bd7 | 2020-06-05 13:02:18 +0200 | [diff] [blame] | 24 | # ********** |
| 25 | # |
| 26 | # ********** |
| 27 | # GNU General Public License v2.0 or later: |
| 28 | # |
| 29 | # This program is free software; you can redistribute it and/or modify |
| 30 | # it under the terms of the GNU General Public License as published by |
| 31 | # the Free Software Foundation; either version 2 of the License, or |
| 32 | # (at your option) any later version. |
| 33 | # |
| 34 | # This program is distributed in the hope that it will be useful, |
| 35 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 36 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 37 | # GNU General Public License for more details. |
| 38 | # |
| 39 | # You should have received a copy of the GNU General Public License along |
| 40 | # with this program; if not, write to the Free Software Foundation, Inc., |
| 41 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 42 | # |
| 43 | # ********** |
Manuel Pégourié-Gonnard | 1beb048 | 2017-06-05 13:49:44 +0200 | [diff] [blame] | 44 | |
| 45 | set -eu |
| 46 | |
| 47 | : ${OPENSSL:=openssl} |
| 48 | NB=20 |
| 49 | |
| 50 | OPT="-days 3653 -sha256" |
| 51 | |
| 52 | # generate self-signed root |
| 53 | $OPENSSL ecparam -name prime256v1 -genkey -out 00.key |
| 54 | $OPENSSL req -new -x509 -subj "/C=UK/O=mbed TLS/CN=CA00" $OPT \ |
| 55 | -key 00.key -out 00.crt |
| 56 | |
| 57 | # cXX.pem is the chain starting at XX |
| 58 | cp 00.crt c00.pem |
| 59 | |
| 60 | # generate long chain |
Manuel Pégourié-Gonnard | 5be13d8 | 2017-07-06 14:31:54 +0200 | [diff] [blame] | 61 | i=1 |
| 62 | while [ $i -le $NB ]; do |
Manuel Pégourié-Gonnard | 1beb048 | 2017-06-05 13:49:44 +0200 | [diff] [blame] | 63 | UP=$( printf "%02d" $((i-1)) ) |
| 64 | ME=$( printf "%02d" $i ) |
| 65 | |
| 66 | $OPENSSL ecparam -name prime256v1 -genkey -out ${ME}.key |
| 67 | $OPENSSL req -new -subj "/C=UK/O=mbed TLS/CN=CA${ME}" \ |
| 68 | -key ${ME}.key -out ${ME}.csr |
| 69 | $OPENSSL x509 -req -CA ${UP}.crt -CAkey ${UP}.key -set_serial 1 $OPT \ |
| 70 | -extfile int.opensslconf -extensions int \ |
| 71 | -in ${ME}.csr -out ${ME}.crt |
| 72 | |
| 73 | cat ${ME}.crt c${UP}.pem > c${ME}.pem |
| 74 | |
| 75 | rm ${ME}.csr |
Manuel Pégourié-Gonnard | 5be13d8 | 2017-07-06 14:31:54 +0200 | [diff] [blame] | 76 | i=$((i+1)) |
Manuel Pégourié-Gonnard | 1beb048 | 2017-06-05 13:49:44 +0200 | [diff] [blame] | 77 | done |