1 | 'use strict'
|
2 |
|
3 | let co = require('co')
|
4 | let cli = require('heroku-cli-util')
|
5 |
|
6 | let error = require('../../lib/error.js')
|
7 | let readFile = require('../../lib/read_file.js')
|
8 | let sslDoctor = require('../../lib/ssl_doctor.js')
|
9 |
|
10 | function * 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 |
|
21 | module.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 |
|
27 | Example:
|
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 | }
|