mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-21 05:44:07 -07:00
refactoring: log_event(), is_format_valid()
This commit is contained in:
parent
325ca65f32
commit
a61a6e979e
52 changed files with 582 additions and 1170 deletions
|
@ -12,7 +12,6 @@
|
|||
# Argument definition
|
||||
domain=$1
|
||||
domain=$(echo $domain |sed -e 's/\.*$//g' -e 's/^\.*//g')
|
||||
domain=$(echo $domain |tr '[:upper:]' '[:lower:]')
|
||||
domain_alias=$domain
|
||||
email=$2
|
||||
country=$3
|
||||
|
@ -70,6 +69,15 @@ is_format_valid 'domain_alias' 'format'
|
|||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
if [[ "$domain" = *[![:ascii:]]* ]]; then
|
||||
domain_idn=$(idn -t --quiet -a $domain)
|
||||
else
|
||||
domain_idn=$domain
|
||||
fi
|
||||
if [[ "$email" = *[![:ascii:]]* ]]; then
|
||||
email=$(idn -t --quiet -a $email)
|
||||
fi
|
||||
|
||||
# Create temporary work directory
|
||||
workdir=$(mktemp -d)
|
||||
cd $workdir
|
||||
|
@ -79,7 +87,7 @@ openssl genrsa $KEY_SIZE > $domain.key 2>/dev/null
|
|||
|
||||
# Generate the CSR
|
||||
subj="/C=$country/ST=$state/localityName=$city/O=$org"
|
||||
subj="$subj/organizationalUnitName=$org_unit/commonName=$domain"
|
||||
subj="$subj/organizationalUnitName=$org_unit/commonName=$domain_idn"
|
||||
subj="$subj/emailAddress=$email"
|
||||
if [ -z "$aliases" ]; then
|
||||
openssl req -sha256\
|
||||
|
@ -87,7 +95,7 @@ if [ -z "$aliases" ]; then
|
|||
-batch \
|
||||
-subj "$subj" \
|
||||
-key $domain.key \
|
||||
-out $domain.csr >/dev/null 2>&1
|
||||
-out $domain.csr #>/dev/null 2>&1
|
||||
else
|
||||
for alias in $(echo $domain,$aliases |tr ',' '\n' |sort -u); do
|
||||
dns_aliases="${dns_aliases}DNS:$alias,"
|
||||
|
@ -118,6 +126,7 @@ openssl x509 -req -sha256 \
|
|||
-signkey $domain.key \
|
||||
-out $domain.crt >/dev/null 2>&1
|
||||
|
||||
|
||||
# Listing certificates
|
||||
if [ -e "$domain.crt" ]; then
|
||||
crt=$(cat $domain.crt | sed ':a;N;$!ba;s/\n/\\n/g' )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue