Skip to content

Instantly share code, notes, and snippets.

@SavageCore
Last active November 16, 2021 06:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SavageCore/70edef4caf9c453374571fa4ad4f30f3 to your computer and use it in GitHub Desktop.
Save SavageCore/70edef4caf9c453374571fa4ad4f30f3 to your computer and use it in GitHub Desktop.

Follow these steps to generate a valid certificate with LetsEncrypt and install into the Madsonic keystore.

Note

Be sure to forward port 443 to your jail for LE authentication.

Replace example.com with your domain or subdomain.

Based on Madsonic installation in jacobblock's guide

acme.sh

Install

cd /usr/ports/net/socat && make install clean && cd ~ && curl https://get.acme.sh | sh

Now re-log or source profile

Generate cert

acme.sh --issue --standalone -d example.com --renew-hook "/root/madsonic-renewal.sh"

Madsonic Keystore

cp /usr/local/madsonic/madsonic-booter.jar /usr/local/madsonic/madsonic-booter-backup.jar
cd /root/.acme.sh/example.com/
openssl pkcs12 -export -out madsonic.pkcs12 -inkey example.com.key -in example.com.cer -certfile ca.cer -password pass:madsonic
keytool -importkeystore -srckeystore madsonic.pkcs12 -destkeystore madsonic.keystore -srcstoretype PKCS12 -srcalias 1 -destalias madsonic -storepass madsonic -srcstorepass madsonic -noprompt
zip -u /usr/local/madsonic/madsonic-booter.jar madsonic.keystore

Enable HTTPS

Edit your launch daemon (/usr/local/etc/rc.d/madsonic) by adding : ${madsonic_https_port="4443"} under : ${madsonic_port="4040"} and then --https-port=${madsonic_https_port} to the command_args line, make sure this stays as a single line.

Restart Madsonic service madsonic restart

That's it! You should be done.

If you have any problems restore the backup /usr/local/madsonic/madsonic-booter-backup.jar and try again.

Renewals

Create sh script /root/madsonic-renewal.sh as follows:

cd /root/.acme.sh/example.com/
openssl pkcs12 -export -out madsonic.pkcs12 -inkey example.com.key -in example.com.cer -certfile ca.cer -password pass:madsonic
keytool -importkeystore -srckeystore madsonic.pkcs12 -destkeystore madsonic.keystore -srcstoretype PKCS12 -srcalias 1 -destalias madsonic -storepass madsonic -srcstorepass madsonic -noprompt
zip -u /usr/local/madsonic/madsonic-booter.jar madsonic.keystore
service madsonic restart

Make it executable

chmod a+x ~/madsonic-renewal.sh

@SavageCore
Copy link
Author

SavageCore commented Feb 18, 2018

Changed Certbot to acme.sh.

@SavageCore
Copy link
Author

Updated again.

--renew-hook should be specified on --issue not in crontab. Command then gets saved in ~/.acme.sh/example.com/example.com.conf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment