mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
fix: Fix issue with key based credentials not being read correctly (#6824)
This commit is contained in:
@@ -11,6 +11,7 @@ import type {
|
||||
JsonObject,
|
||||
} from 'n8n-workflow';
|
||||
import { BINARY_ENCODING, NodeApiError } from 'n8n-workflow';
|
||||
import { formatPrivateKey } from '@utils/utilities';
|
||||
import { createWriteStream } from 'fs';
|
||||
import { basename, dirname } from 'path';
|
||||
import type { Readable } from 'stream';
|
||||
@@ -463,14 +464,22 @@ export class Ftp implements INodeType {
|
||||
const credentials = credential.data as ICredentialDataDecryptedObject;
|
||||
try {
|
||||
const sftp = new sftpClient();
|
||||
await sftp.connect({
|
||||
host: credentials.host as string,
|
||||
port: credentials.port as number,
|
||||
username: credentials.username as string,
|
||||
password: credentials.password as string,
|
||||
privateKey: credentials.privateKey as string | undefined,
|
||||
passphrase: credentials.passphrase as string | undefined,
|
||||
});
|
||||
if (credentials.privateKey) {
|
||||
await sftp.connect({
|
||||
host: credentials.host as string,
|
||||
port: credentials.port as number,
|
||||
username: credentials.username as string,
|
||||
privateKey: formatPrivateKey(credentials.privateKey as string),
|
||||
passphrase: credentials.passphrase as string | undefined,
|
||||
});
|
||||
} else {
|
||||
await sftp.connect({
|
||||
host: credentials.host as string,
|
||||
port: credentials.port as number,
|
||||
username: credentials.username as string,
|
||||
password: credentials.password as string,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
return {
|
||||
status: 'Error',
|
||||
@@ -506,14 +515,22 @@ export class Ftp implements INodeType {
|
||||
|
||||
if (protocol === 'sftp') {
|
||||
sftp = new sftpClient();
|
||||
await sftp.connect({
|
||||
host: credentials.host as string,
|
||||
port: credentials.port as number,
|
||||
username: credentials.username as string,
|
||||
password: credentials.password as string,
|
||||
privateKey: credentials.privateKey as string | undefined,
|
||||
passphrase: credentials.passphrase as string | undefined,
|
||||
});
|
||||
if (credentials.privateKey) {
|
||||
await sftp.connect({
|
||||
host: credentials.host as string,
|
||||
port: credentials.port as number,
|
||||
username: credentials.username as string,
|
||||
privateKey: formatPrivateKey(credentials.privateKey as string),
|
||||
passphrase: credentials.passphrase as string | undefined,
|
||||
});
|
||||
} else {
|
||||
await sftp.connect({
|
||||
host: credentials.host as string,
|
||||
port: credentials.port as number,
|
||||
username: credentials.username as string,
|
||||
password: credentials.password as string,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
ftp = new ftpClient();
|
||||
await ftp.connect({
|
||||
|
||||
Reference in New Issue
Block a user