fix(core): Use hostname from URL instead of Host header for SNI (#8562)

This commit is contained in:
Elias Meire
2024-02-06 19:38:36 +01:00
committed by GitHub
parent 76f317074e
commit 7531f34386
2 changed files with 52 additions and 13 deletions

View File

@@ -2,6 +2,7 @@ import {
copyInputItems,
getBinaryDataBuffer,
parseIncomingMessage,
parseRequestObject,
proxyRequestToAxios,
setBinaryDataBuffer,
} from '@/NodeExecuteFunctions';
@@ -21,6 +22,7 @@ import nock from 'nock';
import { tmpdir } from 'os';
import { join } from 'path';
import Container from 'typedi';
import type { Agent } from 'https';
const temporaryDir = mkdtempSync(join(tmpdir(), 'n8n'));
@@ -358,6 +360,16 @@ describe('NodeExecuteFunctions', () => {
});
});
describe('parseRequestObject', () => {
test('should not use Host header for SNI', async () => {
const axiosOptions = await parseRequestObject({
url: 'https://example.de/foo/bar',
headers: { Host: 'other.host.com' },
});
expect((axiosOptions.httpsAgent as Agent).options.servername).toEqual('example.de');
});
});
describe('copyInputItems', () => {
it('should pick only selected properties', () => {
const output = copyInputItems(