1#!/bin/sh 2 3# Copyright 2018 The Chromium Authors 4# Use of this source code is governed by a BSD-style license that can be 5# found in the LICENSE file. 6 7try () { 8 echo "$@" 9 "$@" || exit 1 10} 11 12try rm -rf out 13try mkdir out 14 15try openssl genrsa -out out/key_usage_rsa_raw.key 2048 16try openssl ecparam -genkey -name prime256v1 -noout \ 17 -out out/key_usage_p256_raw.key 18 19# Convert the private keys to PKCS#8 format. 20try openssl pkcs8 -topk8 -nocrypt -in out/key_usage_rsa_raw.key \ 21 -out out/key_usage_rsa.key 22try openssl pkcs8 -topk8 -nocrypt -in out/key_usage_p256_raw.key \ 23 -out out/key_usage_p256.key 24 25certs=" \ 26 rsa_no_extension \ 27 rsa_keyencipherment \ 28 rsa_digitalsignature \ 29 rsa_both \ 30 p256_no_extension \ 31 p256_keyagreement \ 32 p256_digitalsignature \ 33 p256_both" 34for cert in $certs; do 35 key=${cert%%_*} 36 SUBJECT_NAME="subj_${cert}" \ 37 try openssl req \ 38 -new \ 39 -key "out/key_usage_${key}.key" \ 40 -out "out/key_usage_${cert}.csr" \ 41 -config ee.cnf 42 try openssl x509 \ 43 -req \ 44 -in "out/key_usage_${cert}.csr" \ 45 -signkey "out/key_usage_${key}.key" \ 46 -days 3650 \ 47 -extfile ee.cnf \ 48 -extensions "ext_${cert}" \ 49 -out "out/key_usage_${cert}.pem" \ 50 -text 51 52 try /bin/sh -c "cat out/key_usage_${key}.key out/key_usage_${cert}.pem \ 53 > ../certificates/key_usage_${cert}.pem" 54done 55 56try cp "out/key_usage_rsa.key" ../certificates 57try cp "out/key_usage_p256.key" ../certificates 58