Merge pull request #21660 from overleaf/jpa-s3-https

[object-persistor] s3: simplify using a custom CA for HTTPS endpoints

GitOrigin-RevId: 2c6a5312a842582e5e40e917ccc586392087cb7a
This commit is contained in:
Jakob Ackermann
2024-11-08 09:33:22 +01:00
committed by Copybot
parent 65dc6bf940
commit 122d89a831
5 changed files with 18 additions and 34 deletions

View File

@@ -523,7 +523,7 @@ class S3Persistor extends AbstractPersistor {
if (this.settings.endpoint) {
const endpoint = new URL(this.settings.endpoint)
options.endpoint = this.settings.endpoint
options.sslEnabled = endpoint.protocol === 'https'
options.sslEnabled = endpoint.protocol === 'https:'
}
// path-style access is only used for acceptance tests
@@ -537,6 +537,14 @@ class S3Persistor extends AbstractPersistor {
}
}
if (options.sslEnabled && this.settings.ca && !options.httpOptions?.agent) {
options.httpOptions = options.httpOptions || {}
options.httpOptions.agent = new https.Agent({
rejectUnauthorized: true,
ca: this.settings.ca,
})
}
return options
}