2013-07-17 23:30:04 +08:00
|
|
|
#!/bin/sh
|
2020-08-06 20:22:30 +08:00
|
|
|
# Copyright 2013-2020 The OpenSSL Project Authors. All Rights Reserved.
|
2016-06-01 23:26:40 +08:00
|
|
|
#
|
2018-12-06 20:05:25 +08:00
|
|
|
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
2016-06-01 23:26:40 +08:00
|
|
|
# this file except in compliance with the License. You can obtain a copy
|
|
|
|
# in the file LICENSE in the source distribution or at
|
|
|
|
# https://www.openssl.org/source/license.html
|
|
|
|
|
2013-07-17 23:30:04 +08:00
|
|
|
|
|
|
|
# Utility to recreate S/MIME certificates
|
|
|
|
|
|
|
|
OPENSSL=../../apps/openssl
|
|
|
|
OPENSSL_CONF=./ca.cnf
|
|
|
|
export OPENSSL_CONF
|
|
|
|
|
|
|
|
# Root CA: create certificate directly
|
2020-05-11 21:41:08 +08:00
|
|
|
CN="Test S/MIME RSA Root" $OPENSSL req -config ca.cnf -x509 -noenc \
|
2013-07-17 23:30:04 +08:00
|
|
|
-keyout smroot.pem -out smroot.pem -newkey rsa:2048 -days 3650
|
|
|
|
|
|
|
|
# EE RSA certificates: create request first
|
2020-05-11 21:41:08 +08:00
|
|
|
CN="Test S/MIME EE RSA #1" $OPENSSL req -config ca.cnf -noenc \
|
2013-07-17 23:30:04 +08:00
|
|
|
-keyout smrsa1.pem -out req.pem -newkey rsa:2048
|
|
|
|
# Sign request: end entity extensions
|
|
|
|
$OPENSSL x509 -req -in req.pem -CA smroot.pem -days 3600 \
|
|
|
|
-extfile ca.cnf -extensions usr_cert -CAcreateserial >>smrsa1.pem
|
|
|
|
|
2020-05-11 21:41:08 +08:00
|
|
|
CN="Test S/MIME EE RSA #2" $OPENSSL req -config ca.cnf -noenc \
|
2013-07-17 23:30:04 +08:00
|
|
|
-keyout smrsa2.pem -out req.pem -newkey rsa:2048
|
|
|
|
$OPENSSL x509 -req -in req.pem -CA smroot.pem -days 3600 \
|
|
|
|
-extfile ca.cnf -extensions usr_cert -CAcreateserial >>smrsa2.pem
|
|
|
|
|
2020-05-11 21:41:08 +08:00
|
|
|
CN="Test S/MIME EE RSA #3" $OPENSSL req -config ca.cnf -noenc \
|
2013-07-17 23:30:04 +08:00
|
|
|
-keyout smrsa3.pem -out req.pem -newkey rsa:2048
|
|
|
|
$OPENSSL x509 -req -in req.pem -CA smroot.pem -days 3600 \
|
|
|
|
-extfile ca.cnf -extensions usr_cert -CAcreateserial >>smrsa3.pem
|
|
|
|
|
|
|
|
# Create DSA parameters
|
|
|
|
|
|
|
|
$OPENSSL dsaparam -out dsap.pem 2048
|
|
|
|
|
2020-05-11 21:41:08 +08:00
|
|
|
CN="Test S/MIME EE DSA #1" $OPENSSL req -config ca.cnf -noenc \
|
2013-07-17 23:30:04 +08:00
|
|
|
-keyout smdsa1.pem -out req.pem -newkey dsa:dsap.pem
|
|
|
|
$OPENSSL x509 -req -in req.pem -CA smroot.pem -days 3600 \
|
|
|
|
-extfile ca.cnf -extensions usr_cert -CAcreateserial >>smdsa1.pem
|
2020-05-11 21:41:08 +08:00
|
|
|
CN="Test S/MIME EE DSA #2" $OPENSSL req -config ca.cnf -noenc \
|
2013-07-17 23:30:04 +08:00
|
|
|
-keyout smdsa2.pem -out req.pem -newkey dsa:dsap.pem
|
|
|
|
$OPENSSL x509 -req -in req.pem -CA smroot.pem -days 3600 \
|
|
|
|
-extfile ca.cnf -extensions usr_cert -CAcreateserial >>smdsa2.pem
|
2020-05-11 21:41:08 +08:00
|
|
|
CN="Test S/MIME EE DSA #3" $OPENSSL req -config ca.cnf -noenc \
|
2013-07-17 23:30:04 +08:00
|
|
|
-keyout smdsa3.pem -out req.pem -newkey dsa:dsap.pem
|
|
|
|
$OPENSSL x509 -req -in req.pem -CA smroot.pem -days 3600 \
|
|
|
|
-extfile ca.cnf -extensions usr_cert -CAcreateserial >>smdsa3.pem
|
|
|
|
|
|
|
|
# Create EC parameters
|
|
|
|
|
|
|
|
$OPENSSL ecparam -out ecp.pem -name P-256
|
|
|
|
$OPENSSL ecparam -out ecp2.pem -name K-283
|
|
|
|
|
2020-05-11 21:41:08 +08:00
|
|
|
CN="Test S/MIME EE EC #1" $OPENSSL req -config ca.cnf -noenc \
|
2013-07-17 23:30:04 +08:00
|
|
|
-keyout smec1.pem -out req.pem -newkey ec:ecp.pem
|
|
|
|
$OPENSSL x509 -req -in req.pem -CA smroot.pem -days 3600 \
|
|
|
|
-extfile ca.cnf -extensions usr_cert -CAcreateserial >>smec1.pem
|
2020-05-11 21:41:08 +08:00
|
|
|
CN="Test S/MIME EE EC #2" $OPENSSL req -config ca.cnf -noenc \
|
2013-07-17 23:30:04 +08:00
|
|
|
-keyout smec2.pem -out req.pem -newkey ec:ecp2.pem
|
|
|
|
$OPENSSL x509 -req -in req.pem -CA smroot.pem -days 3600 \
|
|
|
|
-extfile ca.cnf -extensions usr_cert -CAcreateserial >>smec2.pem
|
2020-05-11 21:41:08 +08:00
|
|
|
CN="Test S/MIME EE EC #3" $OPENSSL req -config ca.cnf -noenc \
|
2017-08-10 23:45:31 +08:00
|
|
|
-keyout smec3.pem -out req.pem -newkey ec:ecp.pem
|
|
|
|
$OPENSSL x509 -req -in req.pem -CA smroot.pem -days 3600 \
|
|
|
|
-extfile ca.cnf -extensions usr_cert -CAcreateserial >>smec3.pem
|
2013-08-02 22:51:46 +08:00
|
|
|
# Create X9.42 DH parameters.
|
|
|
|
$OPENSSL genpkey -genparam -algorithm DH -pkeyopt dh_paramgen_type:2 \
|
|
|
|
-out dhp.pem
|
|
|
|
# Generate X9.42 DH key.
|
|
|
|
$OPENSSL genpkey -paramfile dhp.pem -out smdh.pem
|
|
|
|
$OPENSSL pkey -pubout -in smdh.pem -out dhpub.pem
|
|
|
|
# Generate dummy request.
|
2020-05-11 21:41:08 +08:00
|
|
|
CN="Test S/MIME EE DH #1" $OPENSSL req -config ca.cnf -noenc \
|
2013-08-02 22:51:46 +08:00
|
|
|
-keyout smtmp.pem -out req.pem -newkey rsa:2048
|
|
|
|
# Sign request but force public key to DH
|
|
|
|
$OPENSSL x509 -req -in req.pem -CA smroot.pem -days 3600 \
|
|
|
|
-force_pubkey dhpub.pem \
|
|
|
|
-extfile ca.cnf -extensions usr_cert -CAcreateserial >>smdh.pem
|
2013-07-17 23:30:04 +08:00
|
|
|
# Remove temp files.
|
2013-08-02 22:51:46 +08:00
|
|
|
rm -f req.pem ecp.pem ecp2.pem dsap.pem dhp.pem dhpub.pem smtmp.pem smroot.srl
|