Skip to content

Instantly share code, notes, and snippets.

@tondol
Created September 1, 2017 18:11
Show Gist options
  • Save tondol/b8335c269cb99792eb65c71f8da5f23b to your computer and use it in GitHub Desktop.
Save tondol/b8335c269cb99792eb65c71f8da5f23b to your computer and use it in GitHub Desktop.
tondol.com: ruby script for renewal certifications w/ Let's Encrypt
#!/usr/local/bin/ruby
# -*- coding: utf-8 -*-
puts <<'EOS'
$challenges = array(
EOS
File.read(ARGV[0]).each_line {|line|
line.chomp!
puts " \"#{$1}\" => \"#{$1}.#{$2}\"," if line =~ /^([0-9A-Za-z_-]+)\.([0-9A-Za-z_-]+)$/
}
puts <<'EOS'
);
foreach ($challenges as $k => $v) {
if ($_SERVER['REQUEST_URI'] == "/.well-known/acme-challenge/{$k}") {
echo $v;
exit;
}
}
EOS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment