Created
September 9, 2016 11:32
-
-
Save sgielen/9966ea3833622a75b43b84d5ad676d8c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
my $email = 'letsencrypt@sjor.sg'; | |
my $sslroot = '/etc/ssl/private'; | |
# This script assumes every hostname under __DATA__ has its .well-known pointing to the following directory: | |
my $webroot = '/var/www/well-known'; | |
while(<DATA>) { | |
my @domains = split /\s+/; | |
my $domain = $domains[0]; | |
my $domaindir = "$sslroot/$domain"; | |
if(! -d $domaindir) { | |
mkdir($domaindir); | |
} | |
chdir($domaindir); | |
my @command = ("simp_le", "--email", $email, "-f", "account_key.json", "-f", "fullchain.pem", "-f", "key.pem", "--default_root", $webroot); | |
foreach(@domains) { | |
push @command, "-d", $_; | |
} | |
system(@command); | |
chmod(0600, "account_key.json") || warn "Could not chmod account key: $!\n"; | |
chmod(0640, "key.pem") || warn "Could not chmod private key: $!\n"; | |
system("chgrp", "ssl-cert", "key.pem"); | |
} | |
__DATA__ | |
bulbasaur.sjorsgielen.nl | |
dazeus.org www.dazeus.org | |
sjorsgielen.nl www.sjorsgielen.nl | |
g.sjor.sg www.g.sjor.sg | |
private.sjorsgielen.nl | |
vakantiepeilingen.nl www.vakantiepeilingen.nl |
In nginx, .well-known
requests can be aliased using the following three lines in your server
config block:
location /.well-known {
root /var/www/well-known;
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add to your crontab: