Skip to content

Commit

Permalink
fix: Fix issue with key formatting introduced in 1.2.0 (#6896)
Browse files Browse the repository at this point in the history
  • Loading branch information
Joffcom authored and netroy committed Aug 17, 2023
1 parent 2459b0a commit 8423153
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 17 deletions.
7 changes: 0 additions & 7 deletions packages/nodes-base/nodes/MySql/v2/transport/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { formatPrivateKey } from '@utils/utilities';

import mysql2 from 'mysql2/promise';
import type { Client, ConnectConfig } from 'ssh2';
import { rm } from 'fs/promises';

import type { Mysql2Pool } from '../helpers/interfaces';

Expand Down Expand Up @@ -107,12 +106,6 @@ export async function createPool(
dstPort: credentials.port as number,
};

if (sshAuthenticateWith === 'privateKey') {
sshClient.on('end', async () => {
await rm(tunnelConfig.privateKey as string);
});
}

const poolSetup = new Promise<mysql2.Pool>((resolve, reject) => {
sshClient
.on('ready', () => {
Expand Down
6 changes: 0 additions & 6 deletions packages/nodes-base/nodes/Postgres/v2/transport/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ import type { Server } from 'net';
import { createServer } from 'net';

import pgPromise from 'pg-promise';

import { rm } from 'fs/promises';

import type { PgpDatabase } from '../helpers/interfaces';

async function createSshConnectConfig(credentials: IDataObject) {
Expand Down Expand Up @@ -143,9 +140,6 @@ export async function configurePostgres(
});

sshClient.on('end', async () => {
if (tunnelConfig.privateKey) {
await rm(tunnelConfig.privateKey as string, { force: true });
}
if (proxy) proxy.close();
});
}).catch((err) => {
Expand Down
6 changes: 2 additions & 4 deletions packages/nodes-base/utils/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,9 @@ export function formatPrivateKey(privateKey: string): string {
const passRegex = /Proc-Type|DEK-Info/;
if (passRegex.test(part)) {
part = part.replace(/:\s+/g, ':');
formattedPrivateKey += part.replace(/\\n/g, '\n');
formattedPrivateKey += part.replace(/\s+/g, '\n');
formattedPrivateKey += part.replace(/\\n/g, '\n').replace(/\s+/g, '\n');
} else {
formattedPrivateKey += part.replace(/\\n/g, '\n');
formattedPrivateKey += part.replace(/\s+/g, '\n');
formattedPrivateKey += part.replace(/\\n/g, '\n').replace(/\s+/g, '\n');
}
}
});
Expand Down

0 comments on commit 8423153

Please sign in to comment.