Пример #1
0
def main(domain_name, certificate_file, private_key_file, suppress_reload):
    if not os.path.exists(certificate_file):
        print("Could not find certificate file {certificate_file}".format(
            certificate_file=certificate_file))
        sys.exit(1)
    with open(certificate_file, "r") as f:
        certificate = f.read()

    if not os.path.exists(private_key_file):
        print("Could not find private key file {private_key_file}".format(
            private_key_file=private_key_file))
        sys.exit(1)
    with open(private_key_file, "r") as f:
        private_key = f.read()

    webapp = Webapp(domain_name)
    webapp.set_ssl(certificate, private_key)
    if not suppress_reload:
        webapp.reload()

    ssl_details = webapp.get_ssl_info()
    print(
        snakesay("That's all set up now :-)\n"
                 "Your new certificate will expire on {expiry:%d %B %Y},\n"
                 "so shortly before then you should renew it\n"
                 "and install the new certificate.".format(
                     expiry=ssl_details["not_after"])))
def main(domain_name, suppress_reload):
    homedir = expanduser("~")
    possible_paths = (
        os.path.join(homedir, 'letsencrypt', domain_name),
        os.path.join(homedir, 'letsencrypt', 'certs', domain_name),
    )
    done = False
    for path in possible_paths:
        certificate_file = os.path.join(path, 'fullchain.pem')
        private_key_file = os.path.join(path, 'privkey.pem')
        if os.path.exists(certificate_file) and os.path.exists(
                private_key_file):
            with open(certificate_file, "r") as f:
                certificate = f.read()
            with open(private_key_file, "r") as f:
                private_key = f.read()

            webapp = Webapp(domain_name)
            webapp.set_ssl(certificate, private_key)
            if not suppress_reload:
                webapp.reload()

            ssl_details = webapp.get_ssl_info()
            print(
                snakesay(
                    "This method of handling Let's Encrypt certs\n"
                    "**************IS DEPRECATED.**************\n\n"
                    "You can now have a Let's Encrypt certificate managed by PythonAnywhere.\n"
                    "We handle all the details of getting it, installing it,\n"
                    "and managing renewals for you. So you don't need to do\n"
                    "any of the stuff below any more.\n\n"
                    "Anyway, All is set up for now. \n"
                    "Your new certificate will expire on {expiry:%d %B %Y},\n"
                    "so shortly before then you should switch to the new system\n"
                    "(see https://help.pythonanywhere.com/pages/HTTPSSetup/)\n"
                    "".format(expiry=ssl_details["not_after"])))

            done = True
            break

    if not done:
        print(
            "Could not find certificate or key files (looked in {possible_paths})"
            .format(possible_paths=possible_paths))
        sys.exit(2)
Пример #3
0
def main(domain_name, suppress_reload):
    homedir = expanduser("~")
    possible_paths = (
        os.path.join(homedir, 'letsencrypt', domain_name),
        os.path.join(homedir, 'letsencrypt', 'certs', domain_name),
    )
    done = False
    for path in possible_paths:
        certificate_file = os.path.join(path, 'fullchain.pem')
        private_key_file = os.path.join(path, 'privkey.pem')
        if os.path.exists(certificate_file) and os.path.exists(private_key_file):
            with open(certificate_file, "r") as f:
                certificate = f.read()
            with open(private_key_file, "r") as f:
                private_key = f.read()

            webapp = Webapp(domain_name)
            webapp.set_ssl(certificate, private_key)
            if not suppress_reload:
                webapp.reload()

            ssl_details = webapp.get_ssl_info()
            print(snakesay(
                "That's all set up now :-)\n"
                "Your new certificate will expire on {expiry:%d %B %Y},\n"
                "so shortly before then you should renew it\n"
                "(see https://help.pythonanywhere.com/pages/LetsEncrypt/)\n"
                "and install the new certificate.".format(
                    expiry=ssl_details["not_after"]
                )
            ))


            done = True
            break

    if not done:
        print("Could not find certificate or key files (looked in {possible_paths})".format(
            possible_paths=possible_paths
        ))
        sys.exit(2)
Пример #4
0
def main(domain_name):
    webapp = Webapp(domain_name)
    webapp.reload()
    print(snakesay("{} has been reloaded".format(domain_name)))