-
Notifications
You must be signed in to change notification settings - Fork 298
Open
Description
Node.js Version
22.12.0
NPM Version
10.9.0
Operating System
root:xnu-10063.101.17~1/RELEASE_ARM64_T8112 arm64
Subsystem
buffer
Description
async getSignedURL(filePath: string) {
try {
const privateKey = fs.readFileSync('private-key.pem', { encoding: 'utf8' });//.replace(/\\n/g, '\n');
console.log("privateKey", privateKey);
const url = `https://${cdn_domain}.d1a3sb2t664pk3.cloudfront.net/${filePath}`;
const keyPairId = this.cloudFrontKeyPairId;
const dateLessThan = Math.floor((Date.now() + 60 * 60 * 1000) / 1000);
const policy = {
Statement: [
{
Resource: url,
Condition: {
DateLessThan: {
"AWS:EpochTime": new Date(dateLessThan).getTime() / 1000,
},
},
},
],
};
const signedUrl = await getSignedUrl({
url: url,
privateKey: privateKey,
keyPairId: keyPairId,
policy: JSON.stringify(policy),
});
console.log("Signed URL:", signedUrl);
return signedUrl;
} catch (error) {
console.error("Error generating CloudFront signed URL:", error);
throw error;
}
}
Minimal Reproduction
No response
Output
privateKey -----BEGIN PRIVATE KEY-----djfnhjidnfefjnijfnhienhgvijufnvjlk-----END PRIVATE KEY-----
Error generating CloudFront signed URL: Error: error:1E08010C:DECODER routines::unsupported
at Sign.sign (node:internal/crypto/sig:128:29)
[error] error:1E08010C:DECODER routines::unsupported. METADATA: {"metadata":{"stack":"Error: error:1E08010C:DECODER routines::unsupported\n at Sign.sign (node:internal/crypto/sig:128:29)\n at _CloudfrontSignBuilder.signData
Before You Submit
- I have looked for issues that already exist before submitting this
- My issue follows the guidelines in the README file, and follows the 'How to ask a good question' guide at https://stackoverflow.com/help/how-to-ask