Qnap emby et certificat https myqnapcloud.

aureladmin

Apprenti
11 Novembre 2017
59
2
8
une petite doc sur comment utiliser le certificat fournit par Qnap (via Let's Encrypt)
Prérequis: Package Optware-NG

En premier lieu un petit script:
Code:
#!/bin/bash
SSLPORT="VOTRE-NUMERO-DE-PORT"
HOST="VOTRE-HOST.myqnapcloud.com"
RENEWDAY="30"
CERTPATH="/mnt/HDA_ROOT/.config/QcloudSSLCertificate/cert"

EXPIRYDATE=`echo "QUIT" | openssl s_client -connect $HOST:$SSLPORT 2>/dev/null | openssl x5 $
echo $EXPIRYDATE


EXPIRYDATE_epoch=$(date --date "$EXPIRYDATE" +%s)
CURRENT_DATE_epoch=`date +%s`

epochDiff=`echo "$EXPIRYDATE_epoch" - "$CURRENT_DATE_epoch"|/opt/bin/bc`

### Get difference of days
dayDiff=`echo "$epochDiff"/86400|/opt/bin/bc`

if [ "$dayDiff" -le "$RENEWDAY" ]
then
openssl pkcs12 -export -out $CERTPATH/embycertificate.pfx -inkey $CERTPATH/key -in $CERTPAT $
else
echo "There is "$dayDiff" days left for the certificate of "$HOST" and the autorenew is all $
fi

j'explique en gros, le script va vérifier la date d'expiration du certificat et en recréé un au format "PFX" si celui-ci expire dans 15 jours. il suffit de planiffier l'execution du script une fois par semaine et après tout se fait tout seul.
exemple via crontab (tout les dimanche a 5h00):
Code:
0 0 5 * * 0 sh /share/homes/emby-cert-renew.sh

Il suffit ensuite dans l'interface d' Emby dans la partie avancée de lui fournir le chemin vers le certificat "PFX" créé.

Voila