letsencrypt certs

Lets Encrypt certs are neat because they're dirt cheap (free), are backed by EFF etal and are making a serious effort to support many situations and walks of life.


For me, seemingly not so much. I have a Mac mini running mac OS Sierra and the relevant version of mac OS Server. I've tried to follow the instructions to have Lets Encrypt not just install a cert but to keep the cert valid. It isn't working because, I suspect, Lets Encrypt (using a tool currently called CertBot) does not install the cert in the right place I need for mail.


It looks like all the certs I've ever installed in the past are in /etc/ssl/cert.pem, but since macOS Server provides a drag and drop interface for installing certs, I'm not really sure where they wind up. At any rate, I keep the web service turned off on this machine.


Is anyone out there on top of this?


I would find it very useful for Apple to connect with Lets Encrypt and make cert installs and updating very smooth. In the meantime, dropping a Lets Encrypt cert on the certs page in macOS Server would be terrific. Lets Encrypt does not simply provide a cert as a download, tho, they're all about making sure you own the machine you're trying to certify, so they use a protocol called ACME, and you need to install stuff on your machine via homebrew to get it to work on the machine. Once that works, the software maintains the valid cert, so that's a big plus.


Mike

Posted on Apr 27, 2018 8:29 AM

Reply
Question marked as Top-ranking reply

Posted on Apr 29, 2018 11:01 AM

Hi Michael,


After installing the first certificate, macOS Server requires a bit of work every 90 days. Should be no more than 5 minutes per server every 3 months, which is acceptable. Nice way to look how the server is doing 🙂

You can use the contents of this script below to prepare for renewal and importing the new certificate into the Server.app. Then you would need to select the new certificate in the server.app per service. And remove the old certificate. Adapt this script, name it renew.sh or something and use chmod +x to make it executable:


#!/bin/sh

DOMAIN="your.domain.here"

PEM_FOLDER="/etc/letsencrypt/live/${DOMAIN}/"


# Renew the certificate

sudo certbot renew --quiet


# Generate a passphrase

PASS=$(openssl rand -base64 45 | tr -d /=+ | cut -c -30)


# Transform the pem files into a p12 file

sudo openssl pkcs12 -export -inkey "${PEM_FOLDER}privkey.pem" -in "${PEM_FOLDER}cert.pem" -certfile "${PEM_FOLDER}fullchain.pem" -out "${PEM_FOLDER}letsencrypt_sslcert.p12" -passout pass:$PASS


# Import the p12 file into the keychain

sudo security import "${PEM_FOLDER}letsencrypt_sslcert.p12" -f pkcs12 -k /Library/Keychains/System.keychain -P $PASS -T /Applications/Server.app/Contents/ServerRoot/System/Library/CoreServices/Server ManagerDaemon.bundle/Contents/MacOS/servermgrd


Goodluck!

Jeffrey

Similar questions

9 replies
Question marked as Top-ranking reply

Apr 29, 2018 11:01 AM in response to Michael Brian Bentley

Hi Michael,


After installing the first certificate, macOS Server requires a bit of work every 90 days. Should be no more than 5 minutes per server every 3 months, which is acceptable. Nice way to look how the server is doing 🙂

You can use the contents of this script below to prepare for renewal and importing the new certificate into the Server.app. Then you would need to select the new certificate in the server.app per service. And remove the old certificate. Adapt this script, name it renew.sh or something and use chmod +x to make it executable:


#!/bin/sh

DOMAIN="your.domain.here"

PEM_FOLDER="/etc/letsencrypt/live/${DOMAIN}/"


# Renew the certificate

sudo certbot renew --quiet


# Generate a passphrase

PASS=$(openssl rand -base64 45 | tr -d /=+ | cut -c -30)


# Transform the pem files into a p12 file

sudo openssl pkcs12 -export -inkey "${PEM_FOLDER}privkey.pem" -in "${PEM_FOLDER}cert.pem" -certfile "${PEM_FOLDER}fullchain.pem" -out "${PEM_FOLDER}letsencrypt_sslcert.p12" -passout pass:$PASS


# Import the p12 file into the keychain

sudo security import "${PEM_FOLDER}letsencrypt_sslcert.p12" -f pkcs12 -k /Library/Keychains/System.keychain -P $PASS -T /Applications/Server.app/Contents/ServerRoot/System/Library/CoreServices/Server ManagerDaemon.bundle/Contents/MacOS/servermgrd


Goodluck!

Jeffrey

May 2, 2018 1:28 AM in response to Michael Brian Bentley

Hi,


Just follow the instructions provided by letsencrypt:

https://letsencrypt.org/getting-started/

you will need certbot:

https://certbot.eff.org/lets-encrypt/osx-apache

which requires homebrew:

https://brew.sh/

so in other words, install homebrew first, follow the instructions then install certbot.

You will need an A record pointing towards your server and have port 80 and 443 open to your webserver.


Depending on your setup this command might help you setup things, but the basic commands of certbot should take you all the way.

certbot certonly --webroot -w /Library/Server/Web/Data/Sites/Default/ -d name.ofyourdomain.com

If your webroot is on another volume, change the full path.

Goodluck


Jeffrey

May 2, 2018 10:36 AM in response to Michael Brian Bentley

Support for LetsEncrypt ACME support is now part of Apache.


Any package with a current Apache should or soon will have mod_md available, too.


We're headed for changes with macOS Server, and the Apache web server is among what's being deprecated. Apple has available a service migration guide document with added details.


In aggregate, this leads to either configuring and loading Apache 2.4.30 or later yourself, or manually building and loading the LetsEncrypt ACME mod_md module into your existing macOS Server.app Apache installation. Or migrating away from macOS for servers, or migrating to some other add-on web server for macOS such as MAMP, of course. Hopefully the built-in Apache web server stays (more) current, and with a full set of modules...


Most any of which will leave you with support for LetsEncrypt certificates and automatic renewals.

May 1, 2018 7:47 PM in response to jepping

Hi Jeffrey,


Thanks for the script, I'll definitely give it a try once I am able to resolve step one, which is to successfully run certbot and get a cert.


I have been surveying the field to find out what other people have tried doing. One solution involves running a temporary python web server on port 9000.


Let's Encrypt's ACME-based solutions appear to not mix well with macOS Server's drag 'n drop solution for installing SSL certificates.

May 2, 2018 9:06 AM in response to jepping

My last attempt to install the cert using certbot resulted in the following:



certbot.errors.FailedChallenges: Failed authorization procedure. www.[ELIDED].com (http-01): urn:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response from http://www.[ELIDED].com/.well-known/acme-challenge/[RANDOM CHAR STRING ELIDED]: "<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">

<html><head>

<title>404 Not Found</title>

</head><body>

<h1>Not Found</h1>

<p"


What permissions are needed for the .well-known/acme-challenge content?


Mike

May 2, 2018 3:27 PM in response to Michael Brian Bentley

Low-cost certs are around $10 to $15 per year, or — if the mail server is your own local activity, and without other "random" mail clients outside your control, and with comparatively little mail exchanged with other mail servers across the 'net — then you can generate a self-signed cert-pair yourself and use that


I'm in the midst of sorting out a similar issue on a not-very-public mail server, and have found the certificate assistant tool is probably best avoided in favor of using the command line to generate the self-signed certs.

May 4, 2018 7:21 AM in response to Michael Brian Bentley

Hi,


Glad to see you got it working! This was the hardest part, but that little command line helps. Otherwise you would need to edit the webfolder and it’s permissions.

Renewing is even easier and Apple does have plans to stop webservices this autumn, but you should be ok for at least a year or so for now. Your needs might change during that time, but for now your mailtraffic is secure.

Have a Nice day.

Jeffrey

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

letsencrypt certs

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.