| 1 | #!/usr/bin/env bash |
| 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 3 | # |
| 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 | # A copy of the License is located at |
| 7 | # |
| 8 | # http://aws.amazon.com/apache2.0 |
| 9 | # |
| 10 | # or in the "license" file accompanying this file. This file is distributed |
| 11 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
| 12 | # express or implied. See the License for the specific language governing |
| 13 | # permissions and limitations under the License. |
| 14 | # |
| 15 | |
| 16 | # This script regenerates the Apache certificates with RSA 2048-bit keys |
| 17 | # while preserving all the certificate information. |
| 18 | |
| 19 | set -eu |
| 20 | |
| 21 | # Common configuration for both certificates |
| 22 | SUBJECT="/C=US/ST=Massachusetts/L=Boston/O=Amazon/OU=s2n/CN=localhost" |
| 23 | DAYS=36500 # 100 years, same as in gen_self_signed_cert.sh |
| 24 | |
| 25 | # Generate server certificate |
| 26 | echo "Generating Apache server certificate with RSA 2048-bit key..." |
| 27 | openssl req -x509 -newkey rsa:2048 -sha256 -nodes \ |
| 28 | -keyout apache_server_key.pem -out apache_server_cert.pem \ |
| 29 | -days $DAYS -subj "$SUBJECT" |
| 30 | |
| 31 | # Generate client certificate |
| 32 | echo "Generating Apache client certificate with RSA 2048-bit key..." |
| 33 | openssl req -x509 -newkey rsa:2048 -sha256 -nodes \ |
| 34 | -keyout apache_client_key.pem -out apache_client_cert.pem \ |
| 35 | -days $DAYS -subj "$SUBJECT" |
| 36 | |
| 37 | echo "Apache certificates have been regenerated with RSA 2048-bit keys." |