From 8f647b9abe483ca7cea8ae520c006259d148a27a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Slavi=C5=A1a=20Are=C5=BEina?= <58952836+tremor021@users.noreply.github.com> Date: Sun, 18 May 2025 09:27:55 +0200 Subject: [PATCH] tools.func - Add function to create self-signed certificates (#4562) --- misc/tools.func | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/misc/tools.func b/misc/tools.func index efcea57f2..5a91033ce 100644 --- a/misc/tools.func +++ b/misc/tools.func @@ -1180,3 +1180,22 @@ setup_rbenv_stack() { rm -rf "$TMP_DIR" msg_ok "rbenv stack ready (Ruby $RUBY_VERSION)" } + +# ------------------------------------------------------------------------------ +# Creates and installs self-signed certificates. +# +# Description: +# - Create a self-signed certificate with option to override application name +# +# Variables: +# APP - Application name (default: $APPLICATION variable) +# ------------------------------------------------------------------------------ +create_selfsigned_certs() { + local app=${APP:-$(echo "${APPLICATION,,}" | tr -d ' ')} + $STD msg_info "Creating Self-Signed Certificate" + $STD openssl req -x509 -nodes -days 365 -newkey rsa:4096 \ + -keyout /etc/ssl/private/"$app"-selfsigned.key \ + -out /etc/ssl/certs/"$app"-selfsigned.crt \ + -subj "/C=US/O=$app/OU=Domain Control Validated/CN=localhost" + $STD msg_ok "Created Self-Signed Certificate" +}