Skip to content

Commit 8f647b9

Browse files
authored
tools.func - Add function to create self-signed certificates (#4562)
1 parent 8a481e1 commit 8f647b9

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

misc/tools.func

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,3 +1180,22 @@ setup_rbenv_stack() {
11801180
rm -rf "$TMP_DIR"
11811181
msg_ok "rbenv stack ready (Ruby $RUBY_VERSION)"
11821182
}
1183+
1184+
# ------------------------------------------------------------------------------
1185+
# Creates and installs self-signed certificates.
1186+
#
1187+
# Description:
1188+
# - Create a self-signed certificate with option to override application name
1189+
#
1190+
# Variables:
1191+
# APP - Application name (default: $APPLICATION variable)
1192+
# ------------------------------------------------------------------------------
1193+
create_selfsigned_certs() {
1194+
local app=${APP:-$(echo "${APPLICATION,,}" | tr -d ' ')}
1195+
$STD msg_info "Creating Self-Signed Certificate"
1196+
$STD openssl req -x509 -nodes -days 365 -newkey rsa:4096 \
1197+
-keyout /etc/ssl/private/"$app"-selfsigned.key \
1198+
-out /etc/ssl/certs/"$app"-selfsigned.crt \
1199+
-subj "/C=US/O=$app/OU=Domain Control Validated/CN=localhost"
1200+
$STD msg_ok "Created Self-Signed Certificate"
1201+
}

0 commit comments

Comments
 (0)