Created
September 1, 2017 18:11
-
-
Save tondol/b8335c269cb99792eb65c71f8da5f23b to your computer and use it in GitHub Desktop.
tondol.com: ruby script for renewal certifications w/ Let's Encrypt
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/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