UNPKG

1.03 kBJavaScriptView Raw
1'use strict'
2
3let co = require('co')
4let cli = require('heroku-cli-util')
5
6let error = require('../../lib/error.js')
7let readFile = require('../../lib/read_file.js')
8let sslDoctor = require('../../lib/ssl_doctor.js')
9
10function * run (context) {
11 if (context.args.length < 2) {
12 error.exit(1, 'Usage: heroku certs:key CRT KEY [KEY ...]\nMust specify one certificate file and at least one key file.')
13 }
14
15 let res = yield context.args.map(function (arg) { return readFile(arg) })
16
17 let body = JSON.parse(yield sslDoctor('resolve-chain-and-key', res, 'Testing for signing key'))
18 cli.console.writeLog(body.key)
19}
20
21module.exports = {
22 topic: 'certs',
23 command: 'key',
24 description: 'print the correct key for the given certificate',
25 help: `You must pass one single certificate, and one or more keys.\nThe first key that signs the certificate will be printed back.
26
27Example:
28
29 $ heroku certs:key example.com.crt example.com.key
30`,
31 needsApp: true,
32 needsAuth: true,
33 variableArgs: true,
34 run: cli.command(co.wrap(run))
35}