| 1 |
#!/usr/bin/env bash |
| 2 |
|
| 3 |
set -eou pipefail |
| 4 |
|
| 5 |
SCRIPT_ROOT="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" |
| 6 |
|
| 7 |
cert_file_prefix="${SCRIPT_ROOT}/ecdsa_server" |
| 8 |
export_password="s3cr3t" |
| 9 |
|
| 10 |
openssl req -x509 \ |
| 11 |
-days 3650 \ |
| 12 |
-newkey ec \ |
| 13 |
-pkeyopt ec_paramgen_curve:secp384r1 \ |
| 14 |
-sha384 \ |
| 15 |
-subj "/CN=nats-server" \ |
| 16 |
--addext "subjectAltName=IP:127.0.0.1,DNS:localhost" \ |
| 17 |
-nodes \ |
| 18 |
-out "${cert_file_prefix}.pem" \ |
| 19 |
-keyout "${cert_file_prefix}.key" \ |
| 20 |
-outform PEM >/dev/null 2>&1 |
| 21 |
|
| 22 |
openssl pkcs12 \ |
| 23 |
-inkey "${cert_file_prefix}.key" \ |
| 24 |
-in "${cert_file_prefix}.pem" \ |
| 25 |
-export \ |
| 26 |
-password "pass:${export_password}" \ |
| 27 |
-out "${cert_file_prefix}.pfx" >/dev/null 2>&1 |