def ssl_provision_certs(): from ssl_certificates import provision_certificates agree_to_tos_url = request.form.get('agree_to_tos_url') status = provision_certificates(env, agree_to_tos_url=agree_to_tos_url, jsonable=True) return json_response(status)
def ssl_provision_certs(): from ssl_certificates import provision_certificates agree_to_tos_url = request.form.get('agree_to_tos_url') status = provision_certificates(env, agree_to_tos_url=agree_to_tos_url, jsonable=True) return json_response(status)
def ssl_provision_certs(): from ssl_certificates import provision_certificates requests = provision_certificates(env, limit_domains=None) return json_response({ "requests": requests })
def ssl_renew(domain): from utils import load_environment from ssl_certificates import provision_certificates existing_key = request.form.get('existing_key') env = load_environment() if existing_key == "yes": status = provision_certificates(env, limit_domains=[], domain_to_be_renewed=domain) app.logger.warning("renew without new key=", status) # TODO: remove this line after testing elif existing_key == "no": import glob try: # steps followed # 1. take a backup of the current /home/user-data/ssl/ folder to be safe # 2. renew all the existing certificates from CSR generated from the existing next_ssl_private_key # 3. if the renew is successful, replace the current ssl_private_key with the next_ssl_private_key and # 4. generate the next_ssl_private_key # 5. if any error occurs, copy everything from the /home/user-data/ssl-backup folder to /home/user-data/ssl # step 1 files = glob.glob(env["STORAGE_ROOT"] + "/ssl/*") for file in files: subprocess.check_output( ["cp", "-r", file, env["STORAGE_ROOT"] + "/ssl-backup/"]) # step 2 status = provision_certificates(env, limit_domains=[], new_key=True) # step 3 and 4 is in post_install_func method of ssl_certificates.py app.logger.warning( "renew with new key=", status) # TODO: remove this line after proper testing except Exception as e: import traceback files = glob.glob(env["STORAGE_ROOT"] + "/ssl-backup/*") for file in files: subprocess.check_output( ["cp", "-r", file, env["STORAGE_ROOT"] + "/ssl/"]) app.logger.warning(traceback.print_exc() ) # TODO: remove this line after proper testing return json_response({ "title": "Error", "log": "Sorry, something is not right!", }) else: return json_response({ "title": "Error", "log": "Sorry, something is not right!", }) ret_message = {"title": "", "log": ""} for item in status: if isinstance(item, str): continue elif existing_key == "no": message = return_message(item) ret_message["title"] = message["title"] ret_message["log"] += "\n" + message["log"] elif existing_key == "yes" and domain in item["domains"]: return json_response(return_message(item)) return json_response(ret_message)
def ssl_provision_certs(): from ssl_certificates import provision_certificates requests = provision_certificates(env, limit_domains=None) return json_response({ "requests": requests })