def assign(self, assign): """ Assign a TLS certificate to a website or service. :param dict assign: ``Assign`` object to assign :returns: self """ signals.emit("certificates", "pre_assign", (self, assign)) nginx_reload = False if assign["type"] == "genesis": config.set("genesis", "cert_file", self.cert_path) config.set("genesis", "cert_key", self.key_path) config.set("genesis", "ssl", True) config.save() self.assigns.append(assign) elif assign["type"] == "website": w = websites.get(assign["id"]) w.cert = self w.ssl_enable() self.assigns.append(assign) nginx_reload = True else: d = applications.get(assign["aid"]).ssl_enable(self, assign["sid"]) self.assigns.append(d) if nginx_reload: websites.nginx_reload() signals.emit("certificates", "post_assign", (self, assign)) return self
def unassign(self, assign): """ Unassign a TLS certificate from a website or service. :param dict assign: ``Assign`` object to unassign :returns: self """ signals.emit("certificates", "pre_unassign", (self, assign)) nginx_reload = False if assign["type"] == "website": websites.get(assign["id"]).ssl_disable() self.assigns.remove(assign) nginx_reload = True elif assign["type"] == "genesis": config.set("genesis", "cert_file", "") config.set("genesis", "cert_key", "") config.set("genesis", "ssl", False) config.save() self.assigns.remove(assign) else: applications.get(assign["aid"]).ssl_disable(assign["sid"]) self.assigns.remove(assign) if nginx_reload: websites.nginx_reload() signals.emit("certificates", "post_unassign", (self, assign)) return None
def unassign(self, assign): signals.emit("certificates", "pre_unassign", (self, assign)) nginx_reload = False if assign["type"] == "website": websites.get(assign["id"]).ssl_disable() self.assigns.remove(assign) nginx_reload = True elif assign["type"] == "genesis": config.set("genesis", "cert_file", "") config.set("genesis", "cert_key", "") config.set("genesis", "ssl", False) config.save() self.assigns.remove(assign) else: applications.get(assign["aid"]).ssl_disable(assign["sid"]) self.assigns.remove(assign) if nginx_reload: websites.nginx_reload() signals.emit("certificates", "post_unassign", (self, assign)) return None
def assign(self, assign): signals.emit("certificates", "pre_assign", (self, assign)) nginx_reload = False if assign["type"] == "genesis": config.set("genesis", "cert_file", self.cert_path) config.set("genesis", "cert_key", self.key_path) config.set("genesis", "ssl", True) config.save() self.assigns.append(assign) elif assign["type"] == "website": w = websites.get(assign["id"]) w.cert = self w.ssl_enable() self.assigns.append(assign) nginx_reload = True else: d = applications.get(assign["aid"]).ssl_enable(self, assign["sid"]) self.assigns.append(d) if nginx_reload: websites.nginx_reload() signals.emit("certificates", "post_assign", (self, assign)) return self