Skip to content

Commit

Permalink
update the script to generate certificate and bump the version
Browse files Browse the repository at this point in the history
  • Loading branch information
neevek committed Feb 23, 2025
1 parent 186e73f commit 59043cb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rstun"
version = "0.6.6"
version = "0.6.7"
edition = "2021"

[lib]
Expand Down
26 changes: 16 additions & 10 deletions gen_cert_and_key.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash

domain=$1
if [[ $domain = "" ]]; then
echo "Usage: $0 <domain>"
domain_or_ip=$1
if [[ -z $domain_or_ip ]]; then
echo "usage: $0 <domain or ip>"
exit 1
fi

Expand All @@ -14,21 +14,27 @@ if [[ "$platform" = "Darwin" ]]; then
elif [[ "$platform" = "Linux" ]]; then
openssl_cnf="/etc/ssl/openssl.cnf"
else
echo "Not supported!"
echo "not supported!"
exit 1
fi

if [[ $domain_or_ip =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ || $domain_or_ip =~ : ]]; then
san_type="IP"
else
san_type="DNS"
fi

openssl req \
-newkey rsa:2048 \
-x509 \
-nodes \
-keyout $domain.key.pem \
-keyout $domain_or_ip.key.pem \
-new \
-out $domain.crt.pem \
-subj /CN=$domain \
-reqexts SAN \
-extensions SAN \
-out $domain_or_ip.crt.pem \
-subj /CN=$domain_or_ip \
-reqexts san \
-extensions san \
-config <(cat $openssl_cnf \
<(printf "[SAN]\nsubjectAltName=DNS:$domain")) \
<(printf "[san]\nsubjectAltName=$san_type:$domain_or_ip")) \
-sha256 \
-days 3650

0 comments on commit 59043cb

Please sign in to comment.