gl-store-s3.js/lib/certificates/setKeypair.js

18 lines
785 B
JavaScript
Raw Normal View History

2019-05-08 16:12:22 +00:00
const pathHelper = require('../pathHelper');
const fileNames = require('../fileNames');
module.exports.setKeypair = (opts, options, s3) => {
id = opts.certificate.kid || opts.certificate.id || opts.subject;
console.log('certificates.setKeypair for', id);
pemKeyPath = pathHelper.certificatesPath(options, id, fileNames.privkey.pem);
jwkKeyPath = pathHelper.certificatesPath(options, id, fileNames.privkey.jwk);
return s3.putObject({ Key: pemKeyPath, Body: opts.keypair.privateKeyPem, Bucket: options.bucketName }).promise().then((data) => {
console.log('Successfully set the PEM privateKey.');
return null;
}).catch((err) => {
console.error('There was an error setting your PEM privateKey:', err.message);
throw err;
});
}