mirror of
https://github.com/certbot/certbot.git
synced 2026-08-04 08:03:44 +02:00
Merge branch 'master' of github.com:research/chocolate
This commit is contained in:
@@ -177,9 +177,10 @@ def make_request(server, m, csr, quiet=False):
|
|||||||
m.request.csr = csr
|
m.request.csr = csr
|
||||||
hashcash_cmd = ["hashcash", "-P", "-m", "-z", "12", "-b", `difficulty`, "-r", server]
|
hashcash_cmd = ["hashcash", "-P", "-m", "-z", "12", "-b", `difficulty`, "-r", server]
|
||||||
if quiet:
|
if quiet:
|
||||||
hashcash = subprocess.check_output(hashcash_cmd, preexec_fn=drop_privs, shell=False, stderr=open("/dev/null", "w")).rstrip()
|
hashcash = subprocess.Popen(hashcash_cmd, preexec_fn=drop_privs, shell= False, stdout=subprocess.PIPE, stderr=open("/dev/null", "w")).communicate()[0].rstrip()
|
||||||
else:
|
else:
|
||||||
hashcash = subprocess.check_output(hashcash_cmd, preexec_fn=drop_privs, shell=False).rstrip()
|
hashcash = subprocess.Popen(hashcash_cmd, preexec_fn=drop_privs, shell= False, stdout=subprocess.PIPE).communicate()[0].rstrip()
|
||||||
|
|
||||||
if hashcash: m.request.clientpuzzle = hashcash
|
if hashcash: m.request.clientpuzzle = hashcash
|
||||||
|
|
||||||
def sign(key, m):
|
def sign(key, m):
|
||||||
|
|||||||
@@ -63,10 +63,9 @@ class Configurator(object):
|
|||||||
if cert_chain is not None:
|
if cert_chain is not None:
|
||||||
path["cert_chain"] = self.find_directive("SSLCertificateChainFile", None, vhost.path)
|
path["cert_chain"] = self.find_directive("SSLCertificateChainFile", None, vhost.path)
|
||||||
|
|
||||||
for k in path.iterkeys():
|
if len(path["cert_file"]) == 0 or len(path["cert_key"]) == 0:
|
||||||
if len(path[k]) == 0:
|
|
||||||
# Throw some "can't find all of the directives error"
|
# Throw some "can't find all of the directives error"
|
||||||
print "DEBUG - Error: cannot find ", search[k]
|
print "DEBUG - Error: cannot find a cert or key directive"
|
||||||
print "DEBUG - in ", vhost.path
|
print "DEBUG - in ", vhost.path
|
||||||
print "VirtualHost was not modified"
|
print "VirtualHost was not modified"
|
||||||
# Presumably break here so that the virtualhost is not modified
|
# Presumably break here so that the virtualhost is not modified
|
||||||
@@ -77,6 +76,9 @@ class Configurator(object):
|
|||||||
self.aug.set(path["cert_file"][0], cert)
|
self.aug.set(path["cert_file"][0], cert)
|
||||||
self.aug.set(path["cert_key"][0], key)
|
self.aug.set(path["cert_key"][0], key)
|
||||||
if cert_chain is not None:
|
if cert_chain is not None:
|
||||||
|
if len(path["cert_chain"]) == 0:
|
||||||
|
self.add_dir(vhost.path, "SSLCertificateChainFile", cert_chain)
|
||||||
|
else:
|
||||||
self.aug.set(path["cert_chain"][0], cert_chain)
|
self.aug.set(path["cert_chain"][0], cert_chain)
|
||||||
|
|
||||||
return self.save("Virtual Server - deploying certificate")
|
return self.save("Virtual Server - deploying certificate")
|
||||||
@@ -366,7 +368,7 @@ class Configurator(object):
|
|||||||
Checks apache2ctl to get loaded module list
|
Checks apache2ctl to get loaded module list
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
#p = subprocess.check_output(["sudo", "/usr/sbin/apache2ctl", "-M"], stderr=open("/dev/null", 'w'))
|
#p = subprocess.check_output(['sudo', '/usr/sbin/apache2ctl', '-M'], stderr=open("/dev/null", 'w'))
|
||||||
p = subprocess.Popen(['sudo', '/usr/sbin/apache2ctl', '-M'], stdout=subprocess.PIPE, stderr=open("/dev/null", 'w')).communicate()[0]
|
p = subprocess.Popen(['sudo', '/usr/sbin/apache2ctl', '-M'], stdout=subprocess.PIPE, stderr=open("/dev/null", 'w')).communicate()[0]
|
||||||
except:
|
except:
|
||||||
print "Error accessing apache2ctl for loaded modules!"
|
print "Error accessing apache2ctl for loaded modules!"
|
||||||
@@ -518,11 +520,14 @@ class Configurator(object):
|
|||||||
Enables mod_ssl
|
Enables mod_ssl
|
||||||
TODO: TEST
|
TODO: TEST
|
||||||
"""
|
"""
|
||||||
|
try:
|
||||||
# Use check_output so the command will finish before reloading
|
# Use check_output so the command will finish before reloading
|
||||||
#subprocess.check_output(["sudo", "a2enmod", "ssl"], stdout=open("/dev/null", 'w'), stderr=open("/dev/null", 'w'))
|
subprocess.check_call(["sudo", "a2enmod", "ssl"], stdout=open("/dev/null", 'w'), stderr=open("/dev/null", 'w'))
|
||||||
# Hopefully this waits for output
|
# Hopefully this waits for output
|
||||||
text = subprocess.Popen(['sudo', 'a2enmod', 'ssl'], stdout=subprocess.PIPE, stderr=open("/dev/null", 'w')).communicate()[0]
|
subprocess.check_call(["sudo", "/etc/init.d/apache2", "reload"], stdout=open("/dev/null", 'w'), stderr=open("/dev/null", 'w'))
|
||||||
subprocess.call(["sudo", "/etc/init.d/apache2", "reload"], stdout=open("/dev/null", 'w'))
|
except:
|
||||||
|
print "Error enabling mod_ssl"
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
def fnmatch_to_re(self, cleanFNmatch):
|
def fnmatch_to_re(self, cleanFNmatch):
|
||||||
"""
|
"""
|
||||||
@@ -626,11 +631,11 @@ def main():
|
|||||||
config.redirect_all_ssl(vh, ["localhost"])
|
config.redirect_all_ssl(vh, ["localhost"])
|
||||||
config.save()
|
config.save()
|
||||||
"""
|
"""
|
||||||
"""
|
|
||||||
for vh in config.vhosts:
|
for vh in config.vhosts:
|
||||||
if len(vh.names) > 0:
|
if len(vh.names) > 0:
|
||||||
config.deploy_cert(vh, "/home/james/Documents/apache_choc/req.pem", "/home/james/Documents/apache_choc/key.pem")
|
config.deploy_cert(vh, "/home/james/Documents/apache_choc/req.pem", "/home/james/Documents/apache_choc/key.pem", "/home/james/Downloads/sub.class1.server.ca.pem")
|
||||||
"""
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import hmac
|
|||||||
import hashlib
|
import hashlib
|
||||||
from shutil import move
|
from shutil import move
|
||||||
from os import remove, close, path
|
from os import remove, close, path
|
||||||
|
import sys
|
||||||
import binascii
|
import binascii
|
||||||
import augeas
|
import augeas
|
||||||
|
|
||||||
@@ -180,10 +181,14 @@ def apache_restart(quiet=False):
|
|||||||
"""
|
"""
|
||||||
Restarts apache server
|
Restarts apache server
|
||||||
"""
|
"""
|
||||||
|
try:
|
||||||
if quiet:
|
if quiet:
|
||||||
subprocess.call(["sudo", "/etc/init.d/apache2", "reload"], stdout=open("/dev/null","w"), stderr=open("/dev/null", "w"))
|
subprocess.check_call(["sudo", "/etc/init.d/apache2", "reload"], stdout=open("/dev/null","w"), stderr=open("/dev/null", "w"))
|
||||||
else:
|
else:
|
||||||
subprocess.call(["sudo", "/etc/init.d/apache2", "reload"])
|
subprocess.check_call(["sudo", "/etc/init.d/apache2", "reload"])
|
||||||
|
except:
|
||||||
|
print "Apache Restart Failed - Please Check the Configuration"
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
# TODO: This function is insufficient as the user could edit the files
|
# TODO: This function is insufficient as the user could edit the files
|
||||||
# before the challenge is completed. It is safer to log all of the changes
|
# before the challenge is completed. It is safer to log all of the changes
|
||||||
|
|||||||
Reference in New Issue
Block a user