<commit_before>/* options and config for Let's Encrypt */

var LE = require('greenlock');
var LE_express = require('greenlock-express');

const certEmail = "";   // email for certs
const certDomain = "";      // Domain to get certs for

var leStore = require('le-store-certbot').create({
    configDir: '/etc/letsencrypt',
    debug: false
});

var leHTTPChallenge = require('le-challenge-fs').create({
    webrootPath: '/tmp/acme-challenge',
    debug: false
});

var leSNIChallenge = require('le-challenge-sni').create({
    debug: false
});

function agreeToTOS(opts, agree_cb) {
    opts.email = certEmail;

    console.log("Getting certs for: " + opts.domains.toString());
    console.log("TOS URL at " + opts.tosUrl.toString());
    if(opts.domains.length > 1 || opts.domains[0] !== certDomain) {
        console.log("Cert domains don't match expected values, aborting!");
        return;
    }

    agree_cb(null, opts.tosUrl);
}

var le_xp = LE_express.create({
    server: LE.stagingServerUrl, // change to LE.productionServerUrl when ready
    store: leStore,
    challenges: {
        'http-01': leHTTPChallenge,
        'tls-sni-01': leSNIChallenge,
        'tls-sni-02': leSNIChallenge,
    },
    challengeType: 'tls-sni-01',
    agreeToTerms: agreeToTOS,
    debug: true
});

function do_cert_check() {
    le_xp.check({ domains: [ certDomain ] }).then(
        (results) => {
            if(results) { console.log("Found existing certs from Let's Encrypt."); return; } // do we already have certs?

            // we need to register certs
            console.log("Getting new certificates from Let's Encrypt...");
            le_xp.register({
                domains: [certDomain],
                email: certEmail,
                rsaKeySize: 2048,
                challengeType: 'tls-sni-01'
            }).then(
                (results) => {
                    console.log("Got a certificate for " + results.subject + " ("+results.altnames.toString()+")!");
                }
            ).catch(<commit_msg>Try to fix LE support?<commit_after>/* options and config for Let's Encrypt */

var LE = require('greenlock');
var LE_express = require('greenlock-express');

const certEmail = "";   // email for certs
const certDomain = "";      // Domain to get certs for

var leStore = require('le-store-certbot').create({
    configDir: '/etc/letsencrypt',
    debug: false
});

var leHTTPChallenge = require('le-challenge-fs').create({
    webrootPath: '/tmp/acme-challenge',
    debug: false
});

var leSNIChallenge = require('le-challenge-sni').create({
    debug: false
});

function agreeToTOS(opts, agree_cb) {
    opts.email = certEmail;

    console.log("Getting certs for: " + opts.domains.toString());
    console.log("TOS URL at " + opts.tosUrl.toString());
    if(opts.domains.length > 1 || opts.domains[0] !== certDomain) {
        console.log("Cert domains don't match expected values, aborting!");
        return;
    }

    agree_cb(null, opts.tosUrl);
}

var le_xp = LE_express.create({
    server: LE.stagingServerUrl, // change to LE.productionServerUrl when ready
    store: leStore,
    challenges: {
        'http-01': leHTTPChallenge,
        'tls-sni-01': leSNIChallenge,
        'tls-sni-02': leSNIChallenge,
    },
    challengeType: 'tls-sni-01',
    agreeToTerms: agreeToTOS,
    approveDomains: [certDomain],
    email: certEmail,
    debug: true
});

function do_cert_check() {
    le_xp.check({ domains: [ certDomain ] }).then(
        (results) => {
            if(results) { console.log("Found existing certs from Let's Encrypt."); return; } // do we already have certs?

            // we need to register certs
            console.log("Getting new certificates from Let's Encrypt...");
            le_xp.register({
                domains: [certDomain],
                email: certEmail,
                rsaKeySize: 2048,
                challengeType: 'tls-sni-01'
            }).then(
                (results) => {
                    console.log("Got a certificate for " + results.subject + " ("+results.altnames.toString()+")!");
                }
            ).catch(
{'fraction_non_alphanumeric': 0.1427878787878788, 'fraction_numerical': 0.007757575757575757, 'mean_word_length': 2.4585079631181896, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5478896', 'n_tokens_mistral': 1318, 'n_tokens_neox': 1238, 'n_words': 297}