Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds SSL/TLS toggle to FTP connection #4318

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions packages/nodes-base/credentials/Ftp.credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,39 @@ export class Ftp implements ICredentialType {
},
default: '',
},
{
displayName: 'Connect using SSL/TLS',
name: 'secure',
type: 'options',
options: [
{
name: 'False',
value: false,
description: 'Disable secure connection',
},
{
name: 'True',
value: true,
description: 'Enable encryption for control & data connection',
},
{
name: 'Control',
value: 'control',
description: 'Enable encryption for control connection only',
},
],
default: false,
},
{
displayName: 'Ignore Certificate Validation',
name: 'disableCertificateValidation',
displayOptions: {
hide: {
secure: [false],
},
},
type: 'boolean',
default: false,
},
];
}
33 changes: 33 additions & 0 deletions packages/nodes-base/nodes/Ftp/Ftp.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { basename, dirname } from 'path';

import ftpClient from 'promise-ftp';
import sftpClient from 'ssh2-sftp-client';
import { ConnectionOptions, TlsOptions } from 'tls';

interface ReturnFtpItem {
type: string;
Expand Down Expand Up @@ -350,6 +351,28 @@ export class Ftp implements INodeType {
'Whether to return object representing all directories / objects recursively found within SFTP server',
required: true,
},
{
displayName: 'Options',
displayOptions: {
show: {
protocol: ['ftps'],
},
},
name: 'options',
type: 'collection',
placeholder: 'Add Option',
default: {},
options: [
{
displayName: 'Reject Unauthorized',
name: 'rejectUnauthorized',
type: 'boolean',
default: false,
description:
'Whether the server certificate is verified against the list of supplied CAs',
},
],
},
],
};

Expand All @@ -368,6 +391,13 @@ export class Ftp implements INodeType {
port: credentials.port as number,
user: credentials.username as string,
password: credentials.password as string,
secure: credentials.secure as string | boolean,
secureOptions: (credentials.secure
? {
requestCert: credentials.disableCertificateValidation,
rejectUnauthorized: !credentials.disableCertificateValidation,
}
: undefined) as ConnectionOptions | undefined,
});
} catch (error) {
return {
Expand Down Expand Up @@ -420,6 +450,7 @@ export class Ftp implements INodeType {

let credentials: ICredentialDataDecryptedObject | undefined = undefined;
const protocol = this.getNodeParameter('protocol', 0) as string;
const options = this.getNodeParameter('options', 0, {}) as IDataObject;

if (protocol === 'sftp') {
credentials = await this.getCredentials('sftp');
Expand Down Expand Up @@ -447,6 +478,8 @@ export class Ftp implements INodeType {
port: credentials.port as number,
user: credentials.username as string,
password: credentials.password as string,
secure: credentials.secure as boolean,
// secureOptions: options || ({} as IDataObject),
});
}

Expand Down