|
1 |
| -import * as https from 'https'; |
2 | 1 | import * as os from 'os';
|
3 | 2 | import * as path from 'path';
|
4 | 3 | import * as cxapi from '@aws-cdk/cx-api';
|
@@ -375,31 +374,23 @@ function parseHttpOptions(options: SdkHttpOptions) {
|
375 | 374 | config.customUserAgent = userAgent;
|
376 | 375 |
|
377 | 376 | const caBundlePath = options.caBundlePath || caBundlePathFromEnvironment();
|
378 |
| - |
379 |
| - if (options.proxyAddress && caBundlePath) { |
380 |
| - throw new Error(`At the moment, cannot specify Proxy (${options.proxyAddress}) and CA Bundle (${caBundlePath}) at the same time. See https://github.com/aws/aws-cdk/issues/5804`); |
381 |
| - // Maybe it's possible after all, but I've been staring at |
382 |
| - // https://github.com/TooTallNate/node-proxy-agent/blob/master/index.js#L79 |
383 |
| - // a while now trying to figure out what to pass in so that the underlying Agent |
384 |
| - // object will get the 'ca' argument. It's not trivial and I don't want to risk it. |
385 |
| - } |
386 |
| - |
387 | 377 | if (caBundlePath) {
|
388 | 378 | debug('Using CA bundle path: %s', caBundlePath);
|
389 |
| - config.httpOptions.agent = new https.Agent({ |
390 |
| - ca: readIfPossible(caBundlePath), |
391 |
| - keepAlive: true, |
392 |
| - }); |
393 |
| - } else { |
394 |
| - // Configure the proxy agent. By default, this will use HTTPS?_PROXY and |
395 |
| - // NO_PROXY environment variables to determine which proxy to use for each |
396 |
| - // request. |
397 |
| - // |
398 |
| - // eslint-disable-next-line @typescript-eslint/no-require-imports |
399 |
| - const ProxyAgent: any = require('proxy-agent'); |
400 |
| - config.httpOptions.agent = new ProxyAgent(); |
| 379 | + (config.httpOptions as any).ca = readIfPossible(caBundlePath); |
401 | 380 | }
|
402 | 381 |
|
| 382 | + if (options.proxyAddress) { |
| 383 | + debug('Proxy server from command-line arguments: %s', options.proxyAddress); |
| 384 | + } |
| 385 | + |
| 386 | + // Configure the proxy agent. By default, this will use HTTPS?_PROXY and |
| 387 | + // NO_PROXY environment variables to determine which proxy to use for each |
| 388 | + // request. |
| 389 | + // |
| 390 | + // eslint-disable-next-line @typescript-eslint/no-require-imports |
| 391 | + const ProxyAgent = require('proxy-agent'); |
| 392 | + config.httpOptions.agent = new ProxyAgent(options.proxyAddress); |
| 393 | + |
403 | 394 | return config;
|
404 | 395 | }
|
405 | 396 |
|
|
0 commit comments