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

21 lines
845 B
JavaScript

const pathHelper = require('../pathHelper');
const fileNames = require('../fileNames');
module.exports.checkKeypair = (opts, options, s3) => {
console.log('certificates.checkKeypair for', opts.subject);
id = opts.certificate.kid || opts.certificate.id || opts.subject;
pemKeyPath = pathHelper.certificatesPath(options, id, fileNames.privkey.pem);
jwkKeyPath = pathHelper.certificatesPath(options, id, fileNames.privkey.jwk);
return s3.getObject({ Key: pemKeyPath, Bucket: options.bucketName }).promise().then((data) => {
console.log('Successfully retrieved certificate PEM keypair.');
return {
privateKeyPem: data.Body.toString()
}
}).catch((err) => {
console.error('There was an error retrieving your certificate PEM keypair:', err.message);
return null;
});
}