如何使用 letsencrypt greenlock 设置通配符域 ssl?
How to setup wildcard domain ssl with letsencrypt greenlock?
我对设置 ssl 服务器还很陌生,我只是在探索一个名为 greelock 的包
https://www.npmjs.com/package/greenlock
相信我,我正在使用真实域来设置 ssl。
安装完所有包后我运行这段代码。
'use strict';
require('greenlock-express').create({
// Let's Encrypt v2 is ACME draft 11
version: 'draft-11'
// Note: If at first you don't succeed, switch to staging to debug
// https://acme-staging-v02.api.letsencrypt.org/directory
// https://acme-v02.api.letsencrypt.org/directory
, server: 'https://acme-staging-v02.api.letsencrypt.org/directory'
// Where the certs will be saved, MUST have write access
, configDir: '~/.config/acme/'
// You MUST change this to a valid email address
, email: 'somename@gmail.com'
// You MUST change these to valid domains
// NOTE: all domains will validated and listed on the certificate
, approveDomains: [ 'awesomedomain.com','*.awesomedomain.com' ]
// You MUST NOT build clients that accept the ToS without asking the user
, agreeTos: true
, app: require('express')().use('/', function (req, res) {
res.setHeader('Content-Type', 'text/html; charset=utf-8')
res.end('Hello, World!\n\n .js');
})
// Join the community to get notified of important updates
, communityMember: true
// Contribute telemetry data to the project
, telemetry: true
//, debug: true
}).listen(80, 443);
上面的代码对于 awesomedomain.com 的基域工作正常,但是当我尝试访问一些随机子域时,我遇到了这个错误
[Error] approveDomains rejected tls sni 'david.awesomedomain.com'
[Error] (see https://git.coolaj86.com/coolaj86/greenlock.js/issues/11)
使用Greenlock v2.7+
在 Greenlock v2.7 之前,您必须手动执行许多操作才能使通配符注册正常工作。
我写了一个新的文件存储插件,这样它就不会被不允许 *
.
的文件系统绊倒
我还让根据需要使用 dns-01
并在允许时使用 http-01
变得更聪明。
参见 https://git.coolaj86.com/coolaj86/greenlock-express.js/src/branch/master/examples/wildcard.js
中的示例
DNS-01 插件
您仍然需要一个 dns-01 插件。如果您尝试自述文件的插件部分中列出的其中一个但它不起作用,请向我提出问题:
https://git.coolaj86.com/coolaj86/greenlock-express.js
其中一些已经很旧了,尽管我费了很大的劲才试图保持向后兼容性,但还是有可能出了问题。
我对设置 ssl 服务器还很陌生,我只是在探索一个名为 greelock 的包
https://www.npmjs.com/package/greenlock
相信我,我正在使用真实域来设置 ssl。
安装完所有包后我运行这段代码。
'use strict';
require('greenlock-express').create({
// Let's Encrypt v2 is ACME draft 11
version: 'draft-11'
// Note: If at first you don't succeed, switch to staging to debug
// https://acme-staging-v02.api.letsencrypt.org/directory
// https://acme-v02.api.letsencrypt.org/directory
, server: 'https://acme-staging-v02.api.letsencrypt.org/directory'
// Where the certs will be saved, MUST have write access
, configDir: '~/.config/acme/'
// You MUST change this to a valid email address
, email: 'somename@gmail.com'
// You MUST change these to valid domains
// NOTE: all domains will validated and listed on the certificate
, approveDomains: [ 'awesomedomain.com','*.awesomedomain.com' ]
// You MUST NOT build clients that accept the ToS without asking the user
, agreeTos: true
, app: require('express')().use('/', function (req, res) {
res.setHeader('Content-Type', 'text/html; charset=utf-8')
res.end('Hello, World!\n\n .js');
})
// Join the community to get notified of important updates
, communityMember: true
// Contribute telemetry data to the project
, telemetry: true
//, debug: true
}).listen(80, 443);
上面的代码对于 awesomedomain.com 的基域工作正常,但是当我尝试访问一些随机子域时,我遇到了这个错误
[Error] approveDomains rejected tls sni 'david.awesomedomain.com'
[Error] (see https://git.coolaj86.com/coolaj86/greenlock.js/issues/11)
使用Greenlock v2.7+
在 Greenlock v2.7 之前,您必须手动执行许多操作才能使通配符注册正常工作。
我写了一个新的文件存储插件,这样它就不会被不允许 *
.
我还让根据需要使用 dns-01
并在允许时使用 http-01
变得更聪明。
参见 https://git.coolaj86.com/coolaj86/greenlock-express.js/src/branch/master/examples/wildcard.js
中的示例DNS-01 插件
您仍然需要一个 dns-01 插件。如果您尝试自述文件的插件部分中列出的其中一个但它不起作用,请向我提出问题:
https://git.coolaj86.com/coolaj86/greenlock-express.js
其中一些已经很旧了,尽管我费了很大的劲才试图保持向后兼容性,但还是有可能出了问题。