Exemple #1
0
def generate_crt(config, name, plugin, csr, key, domain):
    lb = LoadBalancer.find(name, config)
    if lb is None:
        raise storage.InstanceNotFoundError()
    strg = storage.MongoDBStorage(config)
    consul_mngr = consul_manager.ConsulManager(config)

    crt = None

    plugin_class = ssl_plugins.get(plugin)
    if not plugin_class:
        raise Exception("Invalid plugin {}".format(plugin))
    plugin_obj = plugin_class(domain, os.environ.get('RPAAS_PLUGIN_LE_EMAIL', 'admin@'+domain),
                              name, consul_manager=consul_mngr)

    #  Upload csr and get an Id
    plugin_id = plugin_obj.upload_csr(csr)
    crt = plugin_obj.download_crt(id=str(plugin_id))

    #  Download the certificate and update nginx with it
    if crt:
        try:
            js_crt = json.loads(crt)
            cert = js_crt['crt']
            cert = cert+js_crt['chain'] if 'chain' in js_crt else cert
            key = js_crt['key'] if 'key' in js_crt else key
        except:
            cert = crt

        consul_mngr.set_certificate(name, cert, key)
        strg.store_le_certificate(name, domain)
    else:
        raise Exception('Could not download certificate')
Exemple #2
0
def generate_crt(config, name, plugin, csr, key, domain):
    lb = LoadBalancer.find(name, config)
    if lb is None:
        raise storage.InstanceNotFoundError()
    strg = storage.MongoDBStorage(config)
    consul_mngr = consul_manager.ConsulManager(config)

    crt = None

    plugin_class = ssl_plugins.get(plugin)
    if not plugin_class:
        raise Exception("Invalid plugin {}".format(plugin))
    plugin_obj = plugin_class(domain, os.environ.get('RPAAS_PLUGIN_LE_EMAIL', 'admin@'+domain),
                              name, consul_manager=consul_mngr)

    #  Upload csr and get an Id
    plugin_id = plugin_obj.upload_csr(csr)
    crt = plugin_obj.download_crt(id=str(plugin_id))

    #  Download the certificate and update nginx with it
    if crt:
        try:
            js_crt = json.loads(crt)
            cert = js_crt['crt']
            cert = cert+js_crt['chain'] if 'chain' in js_crt else cert
            key = js_crt['key'] if 'key' in js_crt else key
        except:
            cert = crt

        consul_mngr.set_certificate(name, cert, key)
        strg.store_le_certificate(name, domain)
    else:
        raise Exception('Could not download certificate')
Exemple #3
0
    def run(self, config, name, plugin, domain):
        try:
            self.init_config(config)
            lb = LoadBalancer.find(name, self.config)
            if lb is None:
                raise storage.InstanceNotFoundError()

            plugin_class = ssl_plugins.get(plugin)
            plugin_obj = plugin_class(domain, os.environ.get('RPAAS_PLUGIN_LE_EMAIL', 'admin@'+domain),
                                      name)
            plugin_obj.revoke()
            self.storage.remove_le_certificate(name, domain)
        except Exception, e:
            logging.error("Error in ssl plugin task: {}".format(e))
            raise e
Exemple #4
0
    def run(self, config, name, plugin, domain):
        try:
            self.init_config(config)
            lb = LoadBalancer.find(name, self.config)
            if lb is None:
                raise storage.InstanceNotFoundError()

            plugin_class = ssl_plugins.get(plugin)
            plugin_obj = plugin_class(domain, os.environ.get('RPAAS_PLUGIN_LE_EMAIL', 'admin@'+domain),
                                      name)
            plugin_obj.revoke()
            self.storage.remove_le_certificate(name, domain)
        except Exception, e:
            logging.error("Error in ssl plugin task: {}".format(e))
            raise e