Skip to content

Use https and mulitdomain with letsencrypt #25

@morris821028

Description

@morris821028

https://github.com/letsencrypt/letsencrypt

./letsencrypt-auto certonly --standalone --email dplabta@gmail.com -d judgegirl.csie.org
./letsencrypt-auto certonly --standalone --email dplabta@gmail.com -d judgegirl.csie.ntu.edu.tw

change ./bin/www

/*
  https
*/
var crypto = require('crypto');
var https = require('https'),
    fs = require("fs");

function getSecureContext(domain) {
    return crypto.createCredentials({
        key:  fs.readFileSync('/etc/letsencrypt/live/'+ domain + '/privkey.pem'),
        cert:  fs.readFileSync('/etc/letsencrypt/live/' + domain + '/cert.pem')
      }).context;
}

var secureContext = {
    'judgegirl.csie.org': getSecureContext('judgegirl.csie.org'),
    'judgegirl.csie.ntu.edu.tw': getSecureContext('judgegirl.csie.ntu.edu.tw')
};

var options = {
    SNICallback: function(domain) {
        return secureContext[domain];
    },
    port: 443,
    path: '/140.112.31.208',
    method: 'GET',
    key: fs.readFileSync('/etc/letsencrypt/live/judgegirl.csie.org/privkey.pem'),
    cert: fs.readFileSync('/etc/letsencrypt/live/judgegirl.csie.org/cert.pem')
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions