-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconfigure_selfsigned_certificates.sh
33 lines (31 loc) · 1.19 KB
/
configure_selfsigned_certificates.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
#
# Copyright (C) 2016 - DMC Ingenieria SAS. http://dmci.co
# Author: Dorance Martinez C [email protected]
# SPDX-License-Identifier: GPL-3.0+
#
# Descripcion: Script para crear certificados para un sitio web
# Version: 0.1.1 - 09-dic-2016
# Validado: Debian >=8
#
#
# Setup Variables
country=CO
state=ValleDelCauca
locality=Cali
organization=company.local
organizationalunit=monitoring
servername=nagios
days=365
apache_user="www-data"
ca_path="/etc/ssl"
mkdir -p ${ca_path} &&
openssl req -nodes -newkey rsa:2048 -keyout ${ca_path}/${servername}.key -out ${ca_path}/${servername}.csr -days ${days} -subj "/C=$country/ST=$state/L=$locality/O=$organization/OU=$organizationalunit/CN=$servername/emailAddress=$email" &&
cp -v ${ca_path}/${servername}.key ${ca_path}/${servername}.original &&
openssl rsa -in ${ca_path}/${servername}.original -out ${ca_path}/${servername}.key &&
rm -v ${ca_path}/${servername}.original &&
openssl x509 -req -days ${days} -in ${ca_path}/${servername}.csr -signkey ${ca_path}/${servername}.key -out ${ca_path}/${servername}.crt &&
rm -v ${ca_path}/${servername}.csr &&
chown -R ${apache_user}: ${ca_path} &&
chmod 600 ${ca_path}/${servername}.*