Storing RSA Keys in Credentials Node

I have an RSA (openssl) key I am trying to store in the credentials node, but upon retrieval, it does not work.

I have an example:

It works when I store in a variable inside the function node using the multiline string ` quotation.
I then converted the string: .replace(/\\n/g, "\n");

let private_key =  `-----BEGIN PRIVATE KEY-----
FAKE123CODEnbgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCe0D/YVKRhJF2D
/mwoSsuI+TZQDcjQhL+tojqQA3dPfZYFATjDHKPEGcyF6AVEm7uO7jUoggd6YOzX
r+xHr2CueeUwc/pF/TVlIyhOx4mBHPy9di90JMCVEOMzmeeE30dgdRoi+kEZyDI2
atLYU/hk0UMgrnWCzJxghm3AjDsOGGnqqTA5TrPTb3MG++fYLAW3t3P7MiW+aZ5O
8OwpglPWDNBOx9MxqNZ+V8kd240c0sig6yf0zu6h2aH1HWMNTVI66vHM/sCoMLdF
3GcFKGBkdAnc7ZzWRHzG7hUmXBicGrKPnW4R7kQxmY3ISWFFowWUCZiEfw8TUoeu
qsuCtrU/AgMBAAECggEABmIETuOH/8eAYq+1FSF8cLLjdfA34/mR4p6kj+kzwGQh
xW25JE5gXp9S0wbyP0GrFiGIzWn8dvSyUDDn5DGuRxTrGzluE6YLoVb6ZcArTJ8n
oU3AtoBLpTIaj5Zd8b8vlTbfqAw61ZhwPDOq6brmPtcSRZv9aRZkKpT8kEKSlQxh
76FszkB8ZYgltgsyKAVVINDESIGVBGvkaCRwkAmVNbKGkOnqFUoYWNuqaVTe6wJRyYf
TT+BkITWc4l3Yi18pHpHppLtQRt+P3Xp5O8227RhLSG19PMS0Swce0jVIBpyZH+4
wSalKRbMk+GRZ1eDXmEMO0/uwr+uCfNxu1bi/iKlEQKBgQDGdpD9ievIYsCDDMwR
FML71H+y2QubhTrkBI5PkObAQblXJqjVQMNXcizSRYxsftZn7YhxC/5Ns7IXGtDC
cu8bFj9zABCDEFG+NylXKdZOjuGkL3zXs5dtjCmFDqJPKuUfypiI32FkLwZY7kY
4W40LlFMg2XPbeO5gh61HYCkowKBgQDM2vv4ZvN563q48ugXpvTt8NMhyUoNquHP
+0fsx4n9m+41UaOvW6FDdk0Qy4bSjhraDkcIjA5Y+Qw9VEk+P+QhracKaeFa1MM0
8VZ4e0mLMn4wnxY4gd4mHzDbQAvvf+J1Qa+py3SqJvlSF+Noq08xxoF5bFqts6xC
uf8g/KtatQKBgHXKT1m7ry56tgnR4ZhNu0BeKgCLY6FFXOOSdKhytxHqsEcykcgo
LQhMop+WWbbXPQfn6jA2TxPtEEk4SCjwsEtiU/xSJDub94ey/LpEmKqTrlq6s5Kr
dU4XYR5hKTDkym1TYGNo7woEEi/7iRNkUNU1nFkOL7ICZcNnoDQcs4qDAoGBAK8B
CK6trKRkIcQsZ1AFZkp7KLM9VZEVgbF+tnQ2BtFsS3SrWM1u1vZd8vo9FOF9Wr0b
410O4RbrM6SVA7k1Nbv7sK75wvYoutbYsYldsXdD3H/G+GGvuEsS7FbxgQDKXHjV
c673S6QshWO3WqPJbW9VaLiFc3Xe/3NFmAnjMLPdAoGBAL0HMY1RXwD4t/dhAhCM
+ugixIBkFwOGhw4WQ+nkQ0j1fRlPYFHo6v46Lp71HAmMc/Z4x/hKFkVDyyYPwZTd
rcd5Jz5NdmZA7ByDvhnB9zdUgduxusfi+DE+Cyc52x7sicJEn06Tw1LnFzpLf1wv
0xB3RMe8km867viSa1ZDlmjq
-----END PRIVATE KEY-----`.replace(/\\n/g, "\n");

This above worked locally in the function node that called the external API that required the key.

However, when I use the key via variable set: msg.private_key
from the node-red-contrib-credentials I get errors :

"Error: error:1E08010C:DECODER routines::unsupported"

Simply the string isn't in the right format.

The key was basically copied from the function node string listed above and pasted into the credentials node.
I suspect there are new line issues or something going on that I am not familiar with in regards to RSA.

Maybe someone has a good workflow to storing these keys in the credentials? Or is there a better more secure way of doing such a task?

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.