|
|
|
@@ -15,15 +15,17 @@ const dayjs = require('dayjs'); // 需安装dayjs库 |
|
|
|
// SSL根目录 |
|
|
|
const ROOT_PATH = path.join(think.ROOT_PATH, 'ssl'); |
|
|
|
const PEM_PATH = path.join(ROOT_PATH, 'cert'); |
|
|
|
const LETSENCRYPT_PATH = path.join(ROOT_PATH, 'letsencrypt'); |
|
|
|
const LECHALLENGE_PATH = path.join(ROOT_PATH, 'lechallenge'); |
|
|
|
// 创建存储对象 |
|
|
|
const leStore = GreenlockStoreFs.create({ |
|
|
|
configDir: path.join(ROOT_PATH, 'letsencrypt'), |
|
|
|
basePath: path.join(ROOT_PATH, 'letsencrypt'), |
|
|
|
configDir: LETSENCRYPT_PATH, |
|
|
|
basePath: LETSENCRYPT_PATH, |
|
|
|
env: think.env |
|
|
|
}); |
|
|
|
// 创建验证对象 |
|
|
|
const leHttpChallenge = LeChallengeFs.create({ |
|
|
|
webrootPath: path.join(ROOT_PATH, 'lechallenge'), |
|
|
|
webrootPath: LECHALLENGE_PATH, |
|
|
|
}); |
|
|
|
// 是否同意协议 |
|
|
|
function leAgree (opts, agreeCb) { |
|
|
|
@@ -242,4 +244,13 @@ export default class extends Base { |
|
|
|
console.error('部署失败:', error.message); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 配置路由 |
|
|
|
*/ |
|
|
|
async lechallengeAction () { |
|
|
|
let params = this.param(); |
|
|
|
let txt = fs.readFileSync(path.join(LECHALLENGE_PATH,params.file)) |
|
|
|
this.json(txt); |
|
|
|
} |
|
|
|
} |