I interested is it possible n8n flow node (for example in function node ) to generate self signed certificates private and public keys using input json values and using management REST API add these new certificates. (solution has management REST API that supports certificate adding ).
Example in openssl utlity to describe my aim generate self signed certificates private and public keys
Are you self-hosting n8n? If yes, you can use the Execute Command node. Make sure that you have openssl installed on your server. You may have to rebuild the Docker image to include the openssl package.
Many Thanks for your answer . i tried to add the library and use ths library inside function node
I instlaled the library:
npm -g install selfsigned
and envnment varibale: variable
export NODE_FUNCTION_ALLOW_EXTERNAL=selfsigned
but then tired use the libraaary i got the error messages:
ReferenceError: selfsigned is not defined
at /usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes:1:109
at Object. (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes:4:2)
at NodeVM.run (/usr/local/lib/node_modules/n8n/node_modules/vm2/lib/main.js:1167:29)
at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Function.node.js:66:31)
at Workflow.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/src/Workflow.js:492:37)
at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/src/WorkflowExecute.js:424:62
at processTicksAndRejections (internal/process/task_queues.js:95:5)
I’ m not using PM2 . I start n8n from linux desktop in terminal window like this:
administrator@test:~$ n8n
Initializing n8n process
n8n now checks for new versions and security updates. You can turn this off using the environment variable N8N_VERSION_NOTIFICATIONS_ENABLED to “false”
For more information, please refer to Configuration | Docs
Do yean this package.json file ?
/usr/local/lib/node_modules/n8n/package.json
There are lot of package.json files
Do you mean thatt this export NODE_FUNCTION_ALLOW_EXTERNAL=selfsigned must be in package.json file ? Then it is this case then it is not showing in pacakage.json file.
Thanks for your answer . I have question about /usr/local/lib/node_modules/n8n/package.json file what excatly must i add to this file and where ? For example there is section:
“dependencies”: {
},
I added the to this section
selfsigned": “^1.10.11”
and ectivated the the environmet variable NODE_FUNCTION_ALLOW_EXTERNAL=selfsigned
and started n8n . But i got the same error message as past ERROR: selfsigned is not defined
I suggest you use Docker and build a custom image. This makes it easy to configure n8n with custom settings.
Since you’re using n8n that is globally installed on your machine, you would have to build it again so that it takes your changes into effect. I am not sure how one would go about this with a globally installed npm package.
Then I was presented with the normal console window…
[jonathan@desktop ~]$ n8n
Initializing n8n process
n8n now checks for new versions and security updates. You can turn this off using the environment variable N8N_VERSION_NOTIFICATIONS_ENABLED to "false"
For more information, please refer to https://docs.n8n.io/getting-started/installation/advanced/configuration.html
n8n ready on 0.0.0.0, port 5678
Version: 0.135.1
Editor is now accessible via:
http://localhost:5678/
Press "o" to open in Browser.
I opened the browser and added a function and put in…
var selfsigned = require('selfsigned');
var attrs = [{ name: 'commonName', value: 'contoso.com' }];
var pems = selfsigned.generate(attrs, { days: 365 });
console.log(pems)
return items;
Gave it a run and checked the browser console to see…
Many thanks i tried and it worked , and experimented way to save certs, kys as files also.
Also am looking ways how to use json values to form file name.