fix: Handle skipTLSVerify properly

Signed-off-by: Carlos Esteban Lopez <lcarlosesteb@vmware.com>
This commit is contained in:
Carlos Esteban Lopez
2022-11-09 16:49:26 -05:00
committed by Fredrik Adelöw
parent b372602d8c
commit 718f66f235
@@ -160,17 +160,17 @@ export class KubernetesProxy {
headers: headers as { [key: string]: string },
};
if (!details.skipTLSVerify) {
if (details.caData) {
const ca = bufferFromFileOrString('', details.caData)?.toString() || '';
reqData.agent = new https.Agent({ ca });
} else {
this.logger.error('could not find CA certificate!');
if (details.skipTLSVerify) {
reqData.agent = new https.Agent({ rejectUnauthorized: false });
} else if (details.caData) {
const ca = bufferFromFileOrString('', details.caData)?.toString() || '';
reqData.agent = new https.Agent({ ca });
} else {
this.logger.error('could not find CA certificate!');
throw new InputError(
'Invalid CA certificate configured within Backstage',
);
}
throw new InputError(
'Invalid CA certificate configured within Backstage',
);
}
if (body && Object.keys(body).length > 0) {