Пример #1
0
async def set_certificate():
    # Login
    browser = await launch({'headless': False, 'slowMo': 1, 'devtools': True})
    page = await browser.newPage()
    await page.goto('https://kis.hosteurope.de', {'waitUntil': 'networkidle2'})
    await page.focus("input[autocomplete=email]")
    await page.keyboard.type(config["kis-username"])
    await page.focus("input[type=password]")
    await page.keyboard.type(config["kis-password"])
    await page.keyboard.press("Enter")
    await page.waitForNavigation({'waitUntil': 'networkidle2'})
    time.sleep(1)

    #2FA
    if (config["kis-2fa"]):
        await page.focus("input[id=1]")
        await page.keyboard.type(input("Enter the 2FA you got via SMS here: "))
        await page.keyboard.press("Enter")
        await page.waitForNavigation({'waitUntil': 'networkidle2'})
        time.sleep(1)

    for (domain, url) in cert_config.items():
        cert_file = config_file(os.path.join('live', domain, 'fullchain.pem'))
        key_file = config_file(os.path.join('live', domain, 'privkey.pem'))
        await set_certificate_for(browser, url, cert_file, key_file, domain)

    time.sleep(10)
    await browser.close()
Пример #2
0
import ftplib
import json
import logging
import os
import uuid

from shared import config_file

# manuelles Logging, da certbot Ausgabe dieses Skripts unterdrückt
logging.basicConfig(filename='validation.log',
                    level=logging.DEBUG,
                    format='%(asctime)s %(message)s')

# Mapping zwischen Domains und Verzeichnis auf FTP laden
with open(config_file('domains.json')) as domain_file:
    DOMAINS = json.load(domain_file)

# zu validierende Domain, Dateinamen and Token Inhalt werden von certbot per Umgebungsvariable übergeben
domain = os.environ['CERTBOT_DOMAIN']
filename = os.environ['CERTBOT_TOKEN']
content = os.environ['CERTBOT_VALIDATION']

logging.debug('Domain: ' + domain)
logging.debug('Dateiname: ' + filename)
logging.debug('Inhalt: ' + content)

path = DOMAINS.get(domain)
if not path:
    logging.debug('Kein Mapping für Domain gefunden. Breche ab!')
    exit(1)
Пример #3
0
from shared import domain_list, config_file

# certbot tries to write to /var/log/letsencrypt by default; because of this, running as root is required.
# certbot Error Message:
# Either run as root, or set --config-dir, --work-dir, and --logs-dir to writeable paths.
is_root = os.geteuid() == 0
home_dir = os.path.expanduser('~/.config/hosteurope-letsencrypt')
certbot_config_dir = home_dir
certbot_work_dir = home_dir
certbot_logs_dir = os.path.expanduser('~/.config/hosteurope-letsencrypt/logs')
if not is_root and not os.path.exists(certbot_logs_dir):
    os.makedirs(certbot_logs_dir)

# Einstellungen einlesen
with open(config_file('einstellungen.json')) as cfg_file:
    config = json.load(cfg_file)
email = config['email']
staging = config['staging']

challenge = config.get('preferred-challenge', 'http')

# certbot Kommando zusammenbauen
cmd = 'certbot certonly --manual --agree-tos --manual-public-ip-logging-ok'
cmd += ' -m ' + email
cmd += ' --preferred-challenge=' + challenge
if 'http' == challenge:
    cmd += ' --manual-auth-hook "python3 validate.py"'
if staging:
    cmd += ' --staging'
Пример #4
0
#!/usr/bin/env python3
# coding=utf-8
import json
import os
import asyncio
from pyppeteer import launch
from shared import domain_list, config_file
import time
import sys

cfg_file = open(config_file('einstellungen.json'))
config = json.load(cfg_file)

cert_conf_file = open(config_file('cert-urls.json'))
cert_config = json.load(cert_conf_file)


async def set_certificate_for(browser, url, cert_file, key_file, domain_name):
    page = await browser.newPage()
    # Open SSL page
    await page.goto(url, {'waitUntil': 'networkidle2'})
    await page.setViewport({'width': 1366, 'height': 1000})
    time.sleep(1)

    # Fill in form
    certfileUpload = await page.querySelector("input[name=certfile]")
    keyfileUpload = await page.querySelector("input[name=keyfile]")

    await certfileUpload.uploadFile(cert_file)
    await keyfileUpload.uploadFile(key_file)