mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-12 05:17:28 -08:00
✨ Add SSL support to MySQL.credentials and MySQL.node (#1644)
* added SSL support to MySQL.credentials and MySQL.node
* ⚡ hide certificate field data, change CA name
Co-authored-by: ahsan-virani <ahsan.virani@gmail.com>
This commit is contained in:
parent
315d3b59f5
commit
41088fcd9e
|
@ -48,6 +48,63 @@ export class MySql implements ICredentialType {
|
|||
type: 'number' as NodePropertyTypes,
|
||||
default: 10000,
|
||||
description: 'The milliseconds before a timeout occurs during the initial connection to the MySQL server.',
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'SSL',
|
||||
name: 'ssl',
|
||||
type: 'boolean' as NodePropertyTypes,
|
||||
default: false,
|
||||
},
|
||||
{
|
||||
displayName: 'CA Certificate',
|
||||
name: 'caCertificate',
|
||||
typeOptions: {
|
||||
alwaysOpenEditWindow: true,
|
||||
password: true,
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
ssl: [
|
||||
true,
|
||||
],
|
||||
},
|
||||
},
|
||||
type: 'string' as NodePropertyTypes,
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Client Private Key',
|
||||
name: 'clientPrivateKey',
|
||||
typeOptions: {
|
||||
alwaysOpenEditWindow: true,
|
||||
password: true,
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
ssl: [
|
||||
true,
|
||||
],
|
||||
},
|
||||
},
|
||||
type: 'string' as NodePropertyTypes,
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Client Certificate',
|
||||
name: 'clientCertificate',
|
||||
typeOptions: {
|
||||
alwaysOpenEditWindow: true,
|
||||
password: true,
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
ssl: [
|
||||
true,
|
||||
],
|
||||
},
|
||||
},
|
||||
type: 'string' as NodePropertyTypes,
|
||||
default: '',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
|
@ -218,7 +218,30 @@ export class MySql implements INodeType {
|
|||
throw new Error('No credentials got returned!');
|
||||
}
|
||||
|
||||
const connection = await mysql2.createConnection(credentials);
|
||||
// Destructuring SSL configuration
|
||||
const {
|
||||
ssl,
|
||||
caCertificate,
|
||||
clientCertificate,
|
||||
clientPrivateKey,
|
||||
...baseCredentials
|
||||
} = credentials;
|
||||
|
||||
if (ssl) {
|
||||
baseCredentials.ssl = {};
|
||||
|
||||
if (caCertificate) {
|
||||
baseCredentials.ssl.ca = caCertificate;
|
||||
}
|
||||
|
||||
// client certificates might not be required
|
||||
if (clientCertificate || clientPrivateKey) {
|
||||
baseCredentials.ssl.cert = clientCertificate;
|
||||
baseCredentials.ssl.key = clientPrivateKey;
|
||||
}
|
||||
}
|
||||
|
||||
const connection = await mysql2.createConnection(baseCredentials);
|
||||
const items = this.getInputData();
|
||||
const operation = this.getNodeParameter('operation', 0) as string;
|
||||
let returnItems = [];
|
||||
|
|
Loading…
Reference in a new issue