JuanWTF
JuanWTF
CDCloudflare Developers
Created by JuanWTF on 11/23/2023 in #workers-help
Store a PKCS #8 as a secret of a worker
I have e PKCS #8 that I need to create a JSON with other data and send to an API in order to authenticate to it and obtain a JWT to interact with other APIs. I had planned to store that PKCS #8 as a secret for the worker. In my local environment when saving it in de .dev.vars file I can access it without problems; but when publishing the worker and adding the secret with wrangler secret put or in the web dashboard it looks like it escapes the newline characters (\n) which are part of the private key. Ex. The original key is -----BEGIN PRIVATE KEY-----\nMIIEvQIBAD..., but it's stored as -----BEGIN PRIVATE KEY-----\\nMIIEvQIBAD.... When I create the JSON with the other data it is store as {"private_key":" -----BEGIN PRIVATE KEY-----\\\\nMIIEvQIBAD..."}. What's the best way to store this Key so that the newline characters (\n) are not escaped?
2 replies