Skip to content

Commit 7195123

Browse files
[Branding] allow for SSL setup failures (#1414) (#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 <kavilla414@gmail.com> (cherry picked from commit 0bd14bd) Co-authored-by: Kawika Avilla <kavilla414@gmail.com>
1 parent f54ed1c commit 7195123

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/core/server/rendering/rendering_service.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ export class RenderingService {
7575
this.coreContext.configService.atPath<HttpConfigType>('server').pipe(first()).toPromise(),
7676
]);
7777

78+
this.setupHttpAgent(serverConfig as HttpConfigType);
79+
7880
return {
7981
render: async (
8082
request,
@@ -96,8 +98,6 @@ export class RenderingService {
9698
? Boolean(settings.user['theme:darkMode'].userValue)
9799
: false;
98100

99-
this.setupHttpAgent(serverConfig as HttpConfigType);
100-
101101
const brandingAssignment = await this.assignBrandingConfig(
102102
darkMode,
103103
opensearchDashboardsConfig as OpenSearchDashboardsConfigType
@@ -169,7 +169,8 @@ export class RenderingService {
169169
* @param {Readonly<HttpConfigType>} httpConfig
170170
*/
171171
private setupHttpAgent(httpConfig: Readonly<HttpConfigType>) {
172-
if (httpConfig.ssl?.enabled) {
172+
if (!httpConfig.ssl?.enabled) return;
173+
try {
173174
const sslConfig = new SslConfig(httpConfig.ssl);
174175
this.httpsAgent = new HttpsAgent({
175176
ca: sslConfig.certificateAuthorities,
@@ -178,6 +179,8 @@ export class RenderingService {
178179
passphrase: sslConfig.keyPassphrase,
179180
rejectUnauthorized: false,
180181
});
182+
} catch (e) {
183+
this.logger.get('branding').error('HTTP agent failed to setup for SSL.');
181184
}
182185
}
183186

0 commit comments

Comments
 (0)