2024-10-03 11:26:39 -05:00
|
|
|
{ writeShellScriptBin, openssl, ... }:
|
2024-02-13 23:01:01 -06:00
|
|
|
|
|
|
|
|
writeShellScriptBin "create_ssl" ''
|
2024-10-03 11:26:39 -05:00
|
|
|
set -e -o pipefail
|
|
|
|
|
name="''${1}"
|
|
|
|
|
root_key="''${2}"
|
2024-02-13 23:01:01 -06:00
|
|
|
|
2024-10-03 11:26:39 -05:00
|
|
|
function usage {
|
|
|
|
|
echo "USAGE: create_ssl <cert name> <root path>"
|
|
|
|
|
}
|
2024-02-13 23:01:01 -06:00
|
|
|
|
2024-10-03 11:26:39 -05:00
|
|
|
if [ -z "''${name}" ]; then
|
|
|
|
|
usage
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
2024-02-13 23:01:01 -06:00
|
|
|
|
2024-10-03 11:26:39 -05:00
|
|
|
if [ -z "''${root_key}" ]; then
|
|
|
|
|
usage
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
2024-02-13 23:01:01 -06:00
|
|
|
|
2024-10-03 11:26:39 -05:00
|
|
|
# Create the certificate key
|
|
|
|
|
${openssl}/bin/openssl ecparam -out "''${name}.key" -name prime256v1 -genkey
|
|
|
|
|
# Create the CSR
|
|
|
|
|
${openssl}/bin/openssl req -name -sha256 -key "''${name}.key" -out "''${name}.csr"
|
|
|
|
|
# Sign it
|
|
|
|
|
${openssl}/bin/openssl x509 -req -in "''${name}.csr" -CA "''${root_key}.crt" -CAkey "''${root_key}.key" -CAcreateserial -out "''${name}.crt" -days 3650 -sha256
|
2024-02-13 23:01:01 -06:00
|
|
|
''
|