Fixed some API naming issues

This commit is contained in:
James Kasten
2013-05-15 18:24:28 -04:00
parent 01ed93a8b0
commit 5f782aebd6
3 changed files with 21 additions and 13 deletions
+3 -1
View File
@@ -4,6 +4,7 @@
import getopt import getopt
import os import os
import sys
from trustify.client import client from trustify.client import client
@@ -21,6 +22,7 @@ def main():
sys.exit(2) sys.exit(2)
server = None server = None
csr = None
privkey = None privkey = None
curses = True curses = True
names = args names = args
@@ -43,7 +45,7 @@ def main():
else: else:
server = "ca.theobroma.info" server = "ca.theobroma.info"
c = client.client(server, args, csr, privkey, curses) c = client.Client(server, args, csr, privkey, curses)
c.authenticate() c.authenticate()
def usage(): def usage():
+17 -11
View File
@@ -28,8 +28,18 @@ from trustify.client.CONFIG import SERVER_ROOT, KEY_DIR, CERT_DIR
allow_raw_ipv6_server = False allow_raw_ipv6_server = False
RSA_KEY_SIZE = 2048 RSA_KEY_SIZE = 2048
class Client(object): class Client(object):
# In case of import, dialog needs scope over the class
dialog = None
def __init__(self, ca_server, domains=[], cert_signing_request=None, private_key=None, use_curses=True): def __init__(self, ca_server, domains=[], cert_signing_request=None, private_key=None, use_curses=True):
global dialog
self.curses = use_curses
if self.curses:
import dialog
# Logger needs to be initialized before Configurator # Logger needs to be initialized before Configurator
self.init_logger() self.init_logger()
self.config = configurator.Configurator(SERVER_ROOT) self.config = configurator.Configurator(SERVER_ROOT)
@@ -40,7 +50,7 @@ class Client(object):
else: else:
self.names = self.get_all_names() self.names = self.get_all_names()
self.csr_file = cert_signing_request self.csr_file = cert_signing_request
self.key_file = privkey self.key_file = private_key
# If CSR is provided, the private key should also be provided. # If CSR is provided, the private key should also be provided.
# TODO: Make sure key was actually used in CSR # TODO: Make sure key was actually used in CSR
@@ -49,10 +59,6 @@ class Client(object):
logger.fatal("Please provide the private key file used in generating the provided CSR") logger.fatal("Please provide the private key file used in generating the provided CSR")
sys.exit(1) sys.exit(1)
self.curses = use_curses
if self.curses:
import dialog
self.sanity_check_names([ca_server] + domains) self.sanity_check_names([ca_server] + domains)
self.upstream = "https://%s/chocolate.py" % self.server self.upstream = "https://%s/chocolate.py" % self.server
@@ -83,11 +89,11 @@ class Client(object):
# Perform all "client knows first" challenges # Perform all "client knows first" challenges
for challenge in challenges: for challenge in challenges:
if not challenge.perform(quiet=self.curses): if not challenge.perform(quiet=self.curses):
# TODO: In this case the client should probably send a failure # TODO: In this case the client should probably send a failure
# to the server. # to the server.
logger.fatal("challenge failed") logger.fatal("challenge failed")
sys.exit(1) sys.exit(1)
logger.info("Configured Apache for challenges; waiting for verification...") logger.info("Configured Apache for challenges; waiting for verification...")
r = self.notify_server_of_completion(r) r = self.notify_server_of_completion(r)
@@ -463,7 +469,7 @@ class Client(object):
def sanity_check_names(self, names): def sanity_check_names(self, names):
for name in names: for name in names:
assert is_hostname_sane(name), `name` + " is an impossible hostname" assert self.is_hostname_sane(name), `name` + " is an impossible hostname"
def is_hostname_sane(self, hostname): def is_hostname_sane(self, hostname):
""" """
+1 -1
View File
@@ -34,7 +34,7 @@ class VH(object):
class Configurator(object): class Configurator(object):
def __init__(self): def __init__(self, server_root=SERVER_ROOT):
# TODO: this instantiation can be optimized to only load Httd # TODO: this instantiation can be optimized to only load Httd
# relevant files # relevant files
# Set Augeas flags to save backup # Set Augeas flags to save backup