2014-10-09 11:28:30 +02:00
|
|
|
# Regenerate certificate
|
|
|
|
|
2014-10-09 11:34:41 +02:00
|
|
|
If you want to generate again -- not renewing -- a certificate for a domain, you can follow those steps:
|
2014-10-09 11:28:30 +02:00
|
|
|
|
|
|
|
(replace **example.org** with your domain)
|
|
|
|
|
|
|
|
```bash
|
|
|
|
# Save YunoHost's SSL directory location for readability
|
|
|
|
ssldir=/usr/share/yunohost/yunohost-config/ssl/yunoCA
|
|
|
|
|
2014-10-09 11:34:41 +02:00
|
|
|
# Save the final SSL path (do not forget to change your domain)
|
|
|
|
finalpath=/etc/yunohost/certs/example.org
|
|
|
|
|
|
|
|
# Save the serial number of the new certificate
|
|
|
|
serial=$(cat "$ssldir/serial")
|
|
|
|
|
2014-10-09 11:28:30 +02:00
|
|
|
# Backup current certificates for your domain
|
2014-10-09 11:34:41 +02:00
|
|
|
cp -a $finalpath $finalpath.back
|
2014-10-09 11:28:30 +02:00
|
|
|
|
|
|
|
# Remove certs and configuration file in it
|
2014-10-09 11:34:41 +02:00
|
|
|
rm $finalpath/{crt.pem,key.pem,openssl.cnf}
|
2014-10-09 11:28:30 +02:00
|
|
|
|
|
|
|
# Copy openSSL's configuration file
|
2014-10-09 11:34:41 +02:00
|
|
|
cp $ssldir/openssl.cnf $finalpath/
|
2014-10-09 11:28:30 +02:00
|
|
|
|
|
|
|
# Generate certificate and key
|
2014-10-09 11:34:41 +02:00
|
|
|
openssl req -new -config $finalpath/openssl.cnf -days 3650 -out $ssldir/certs/yunohost_csr.pem -keyout $ssldir/certs/yunohost_key.pem -nodes -batch
|
2014-10-09 11:28:30 +02:00
|
|
|
|
|
|
|
# Sign certificate with your server's CA
|
2014-10-09 11:34:41 +02:00
|
|
|
openssl ca -config $finalpath/openssl.cnf -days 3650 -in $ssldir/certs/yunohost_csr.pem -out $ssldir/certs/yunohost_crt.pem -batch
|
2014-10-09 11:28:30 +02:00
|
|
|
|
|
|
|
# Copy certificate and key to the right place
|
2014-10-09 11:34:41 +02:00
|
|
|
cp $ssldir/newcerts/$serial.pem $finalpath/crt.pem
|
|
|
|
cp $ssldir/certs/yunohost_key.pem $finalpath/key.pem
|
2014-10-09 11:28:30 +02:00
|
|
|
|
|
|
|
# Fix permissions
|
2014-10-09 11:34:41 +02:00
|
|
|
chmod 755 $finalpath
|
|
|
|
chmod 640 $finalpath/key.pem $finalpath/crt.pem
|
|
|
|
chmod 600 $finalpath/openssl.cnf
|
2014-10-09 11:28:30 +02:00
|
|
|
|
|
|
|
# Allow metronome to access those certificates
|
2014-10-09 11:34:41 +02:00
|
|
|
chown root:metronome $finalpath/key.pem $finalpath/crt.pem
|
2014-10-09 11:28:30 +02:00
|
|
|
```
|