Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(server): add subjectAltName field into self signed certificate #1429

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/server_manager/install_scripts/install_server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,20 @@ function generate_certificate() {
local -r CERTIFICATE_NAME="${STATE_DIR}/shadowbox-selfsigned"
readonly SB_CERTIFICATE_FILE="${CERTIFICATE_NAME}.crt"
readonly SB_PRIVATE_KEY_FILE="${CERTIFICATE_NAME}.key"
local SAN_FIELD_PREFIX=""
if [[ ${PUBLIC_HOSTNAME} =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
SAN_FIELD_PREFIX="IP"
else
SAN_FIELD_PREFIX="DNS"
fi

declare -a openssl_req_flags=(
-x509 -nodes -days 36500 -newkey rsa:4096
-subj "/CN=${PUBLIC_HOSTNAME}"
-addext "subjectAltName=${SAN_FIELD_PREFIX}:${PUBLIC_HOSTNAME}"
-keyout "${SB_PRIVATE_KEY_FILE}" -out "${SB_CERTIFICATE_FILE}"
)

openssl req "${openssl_req_flags[@]}" >&2
}

Expand Down