diff --git a/src/core/server/rendering/rendering_service.tsx b/src/core/server/rendering/rendering_service.tsx index 70d809778f09..28d2b38869fc 100644 --- a/src/core/server/rendering/rendering_service.tsx +++ b/src/core/server/rendering/rendering_service.tsx @@ -73,6 +73,8 @@ export class RenderingService { this.coreContext.configService.atPath('server').pipe(first()).toPromise(), ]); + this.setupHttpAgent(serverConfig as HttpConfigType); + return { render: async ( request, @@ -94,8 +96,6 @@ export class RenderingService { ? Boolean(settings.user['theme:darkMode'].userValue) : false; - this.setupHttpAgent(serverConfig as HttpConfigType); - const brandingAssignment = await this.assignBrandingConfig( darkMode, opensearchDashboardsConfig as OpenSearchDashboardsConfigType @@ -167,7 +167,8 @@ export class RenderingService { * @param {Readonly} httpConfig */ private setupHttpAgent(httpConfig: Readonly) { - if (httpConfig.ssl?.enabled) { + if (!httpConfig.ssl?.enabled) return; + try { const sslConfig = new SslConfig(httpConfig.ssl); this.httpsAgent = new HttpsAgent({ ca: sslConfig.certificateAuthorities, @@ -176,6 +177,8 @@ export class RenderingService { passphrase: sslConfig.keyPassphrase, rejectUnauthorized: false, }); + } catch (e) { + this.logger.get('branding').error('HTTP agent failed to setup for SSL.'); } }