├── .gitignore ├── README.md ├── com.bluefeathergroup.fm-ssl.plist ├── LICENSE └── GetSSL.sh /.gitignore: -------------------------------------------------------------------------------- 1 | testing/ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FileMaker-LetsEncrypt-Mac 2 | A bash script for fetching and renewing Let's Encrypt SSL certificates for FileMaker Server running on Mac. 3 | 4 | Setup instructions and an example video can be found at https://bluefeathergroup.com/blog/lets-encrypt-ssl-certificates-for-filemaker-server-for-mac/ 5 | 6 | ## How to use: 7 | The script utilizes certbot to get SSL certificates from Let's Encrypt. Install certbot via homebrew: 8 | ``` 9 | brew install certbot 10 | ``` 11 | 12 | Change directory into the cloned repository and run: 13 | ``` 14 | sudo ./GetSSL.sh 15 | ``` 16 | *Script requires root privileges for certain functions. Always review the code before running any script as root.* 17 | 18 | For help on options, run: 19 | ``` 20 | ./GetSSL.sh --help 21 | ``` -------------------------------------------------------------------------------- /com.bluefeathergroup.fm-ssl.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | EnvironmentVariables 6 | 7 | PATH 8 | /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin 9 | 10 | Label 11 | com.bluefeather.fms-ssl 12 | ProgramArguments 13 | 14 | /bin/sh 15 | /usr/local/bin/GetSSL.sh 16 | 17 | RunAtLoad 18 | 19 | StartCalendarInterval 20 | 21 | 22 | Hour 23 | 18 24 | Minute 25 | 21 26 | Weekday 27 | 6 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Smef 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /GetSSL.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Created by: David Nahodyl, Blue Feather 4 | # Contact: contact@bluefeathergroup.com 5 | 6 | # Need help? We can set this up to run on your server for you! Send an email to 7 | # contact@bluefeathergroup.com or give a call at (770) 765-6258 8 | 9 | function usage() { 10 | cat < /dev/null; 99 | then 100 | printf "\033[1;31mError: Certbot could not be found\033[0m\n" 101 | echo "Install Certbot https://certbot.eff.org" 102 | exit 1 103 | fi 104 | 105 | # Check for arguements. 106 | if [ "$DOMAIN" = "" ]; then 107 | read -p "Set your domain: " DOMAIN 108 | if [[ $DOMAIN == "" ]]; 109 | then printf "\033[1;31mError: Domain not specified. Must enter domain.\033[0m\n" && exit 1 110 | fi 111 | echo 112 | fi 113 | 114 | if [ "$EMAIL" = "" ]; then 115 | read -p "Set your Email: " EMAIL 116 | if [[ $EMAIL == "" ]]; 117 | then printf "\033[1;31mError: Email not specified. Must enter email.\033[0m\n" && exit 1 118 | fi 119 | echo 120 | fi 121 | 122 | if [ "$SERVER_PATH" = "" ]; then 123 | read -p "Set your Server Path. Press 'enter' for default. ('/Library/FileMaker Server/'): " SERVER_PATH 124 | SERVER_PATH=${SERVER_PATH:-"/Library/FileMaker Server/"} 125 | if [[ $SERVER_PATH == "" ]]; 126 | then printf "\033[1;31mError: Server Path not specified. Must enter Server Path.\033[0m\n" && exit 1 127 | fi 128 | echo 129 | fi 130 | 131 | # Confirm arguements 132 | if [[ $NOCONFIRM == "" ]]; 133 | then 134 | while true; do 135 | echo "Domain: $DOMAIN" 136 | echo "Email: $EMAIL" 137 | echo "Server Path: $SERVER_PATH" 138 | echo 139 | read -p "Is the above information correct? Y/n: " YN 140 | case $YN in 141 | [Yy]* ) 142 | echo "Continueing..." 143 | break;; 144 | 145 | [Nn]* ) 146 | echo "Stopping script..." 147 | exit 1 148 | break;; 149 | * ) 150 | echo "Please answer yes or no.";; 151 | esac 152 | done 153 | else 154 | echo "Skipping Confirmation..." 155 | fi 156 | 157 | # testing e-brake 158 | # exit 159 | 160 | WEB_ROOT="${SERVER_PATH}HTTPServer/htdocs" 161 | 162 | 163 | # Get the certificate 164 | certbot certonly --webroot -w "$WEB_ROOT" -d $DOMAIN --agree-tos -m "$EMAIL" --preferred-challenges "http" -n 165 | 166 | cp "/etc/letsencrypt/live/${DOMAIN}/fullchain.pem" "${SERVER_PATH}CStore/fullchain.pem" 167 | cp "/etc/letsencrypt/live/${DOMAIN}/privkey.pem" "${SERVER_PATH}CStore/privkey.pem" 168 | 169 | chmod 640 "${SERVER_PATH}CStore/privkey.pem" 170 | 171 | # Move an old certificate, if there is one, to prevent an error 172 | FILE=${SERVER_PATH}CStore/serverKey.pem 173 | if test -f "$FILE"; then 174 | echo "$FILE exists. Moving to serverKey-old.pem to prevent an error." 175 | mv "${SERVER_PATH}CStore/serverKey.pem" "${SERVER_PATH}CStore/serverKey-old.pem" 176 | fi 177 | 178 | 179 | # Remove the old certificate 180 | fmsadmin certificate delete 181 | 182 | # Install the certificate 183 | fmsadmin certificate import "${SERVER_PATH}CStore/fullchain.pem" --keyfile "${SERVER_PATH}CStore/privkey.pem" -y 184 | 185 | # Stop FileMaker Server 186 | launchctl stop com.filemaker.fms 187 | 188 | # Wait 15 seconds for it to stop 189 | sleep 15s 190 | 191 | # Start FileMaker Server again 192 | launchctl start com.filemaker.fms 193 | 194 | echo 195 | echo "FileMaker Server should now be set to use TLS/SSL" 196 | echo --------------------------------------------------------------------------------