1#!/bin/bash 2# 3# Copyright (c) 2020 Huawei Device Co., Ltd. 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16set -e 17 18if [ -f rsa_public_key_2048.der ]; then 19 echo already have the cert! 20 else 21 openssl genrsa -out rsa_private_2048.key 2048 22 openssl rsa -in rsa_private_2048.key -pubout -out rsa_public_2048.key 23 openssl req -new -x509 -sha256 -key rsa_private_2048.key -out ca_2048.crt 24 openssl x509 -outform der -inform pem -in ca_2048.crt -out rsa_public_key_2048.der 25fi 26 27 28if [ -f rsa_public_key_4096.der ]; then 29 echo already have the cert! 30 else 31 openssl genrsa -out rsa_private_4096.key 4096 32 openssl rsa -in rsa_private_4096.key -pubout -out rsa_public_4096.key 33 openssl req -new -x509 -sha256 -key rsa_private_4096.key -out ca_4096.crt 34 openssl x509 -outform der -inform pem -in ca_4096.crt -out rsa_public_key_4096.der 35fi 36