Skip to content

Commit

Permalink
[Branding] allow for SSL setup failures (opensearch-project#1414) (op…
Browse files Browse the repository at this point in the history
…ensearch-project#1417)

Setup HTTP Agent in the render portion when it did not need to be
it just needed a one time setup for the life time of the server.

Also if this fails to read the keys then it would fail. But it's
only used for custom branding. We shouldn't failed for custom branding
just rely on default branding.

Issue Resolved:
https://discuss.opendistrocommunity.dev/t/is-opensearch-dashboard-server-certificate-and-key-required-to-be-reloaded-everytime-when-gui-is-accessed/9069/13

Signed-off-by: Kawika Avilla <[email protected]>
(cherry picked from commit 0bd14bd)

Co-authored-by: Kawika Avilla <[email protected]>
  • Loading branch information
opensearch-trigger-bot[bot] and kavilla authored Apr 1, 2022
1 parent f54ed1c commit 7195123
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/core/server/rendering/rendering_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ export class RenderingService {
this.coreContext.configService.atPath<HttpConfigType>('server').pipe(first()).toPromise(),
]);

this.setupHttpAgent(serverConfig as HttpConfigType);

return {
render: async (
request,
Expand All @@ -96,8 +98,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
Expand Down Expand Up @@ -169,7 +169,8 @@ export class RenderingService {
* @param {Readonly<HttpConfigType>} httpConfig
*/
private setupHttpAgent(httpConfig: Readonly<HttpConfigType>) {
if (httpConfig.ssl?.enabled) {
if (!httpConfig.ssl?.enabled) return;
try {
const sslConfig = new SslConfig(httpConfig.ssl);
this.httpsAgent = new HttpsAgent({
ca: sslConfig.certificateAuthorities,
Expand All @@ -178,6 +179,8 @@ export class RenderingService {
passphrase: sslConfig.keyPassphrase,
rejectUnauthorized: false,
});
} catch (e) {
this.logger.get('branding').error('HTTP agent failed to setup for SSL.');
}
}

Expand Down

0 comments on commit 7195123

Please sign in to comment.