-
Notifications
You must be signed in to change notification settings - Fork 205
feat: support sslmode=verify-ca and sslmode=verify-full with sslrootcert for PostgreSQL #294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
7a8aa16
2e2d072
d642c43
8a6822b
693035e
27d6d1c
4719de5
093b0d1
d735ea3
cbfd093
4f2ccf6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -324,21 +324,44 @@ function validateSourceConfig(source: SourceConfig, configPath: string): void { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Validate sslmode if provided | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (source.sslmode !== undefined) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // SQLite doesn't support SSL (local file-based database) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (source.type === "sqlite") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| throw new Error( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| `Configuration file ${configPath}: source '${source.id}' has sslmode but SQLite does not support SSL. ` + | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| `Remove the sslmode field for SQLite sources.` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const validSslModes = ["disable", "require"]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const validSslModes = ["disable", "require", "verify-ca", "verify-full"]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!validSslModes.includes(source.sslmode)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| throw new Error( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| `Configuration file ${configPath}: source '${source.id}' has invalid sslmode '${source.sslmode}'. ` + | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| `Valid values: ${validSslModes.join(", ")}` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ((source.sslmode === "verify-ca" || source.sslmode === "verify-full") && source.type !== "postgres") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| throw new Error( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| `Configuration file ${configPath}: source '${source.id}' has sslmode '${source.sslmode}' which is only supported for PostgreSQL. ` + | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| `Valid values for ${source.type}: disable, require` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+342
to
+347
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Validate sslrootcert if provided | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (source.sslrootcert !== undefined) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (source.sslmode !== "verify-ca" && source.sslmode !== "verify-full") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| throw new Error( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| `Configuration file ${configPath}: source '${source.id}' has sslrootcert but sslmode is '${source.sslmode ?? "not set"}'. ` + | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| `sslrootcert requires sslmode 'verify-ca' or 'verify-full'` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const expandedPath = expandHomeDir(source.sslrootcert); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!fs.existsSync(expandedPath)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| throw new Error( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| `Configuration file ${configPath}: source '${source.id}' sslrootcert file not found: '${expandedPath}'` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+360
to
+364
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!fs.existsSync(expandedPath)) { | |
| throw new Error( | |
| `Configuration file ${configPath}: source '${source.id}' sslrootcert file not found: '${expandedPath}'` | |
| ); | |
| } | |
| let stats: fs.Stats; | |
| try { | |
| stats = fs.statSync(expandedPath); | |
| } catch { | |
| throw new Error( | |
| `Configuration file ${configPath}: source '${source.id}' sslrootcert file not found or not accessible: '${expandedPath}'` | |
| ); | |
| } | |
| if (!stats.isFile()) { | |
| throw new Error( | |
| `Configuration file ${configPath}: source '${source.id}' sslrootcert path is not a regular file: '${expandedPath}'` | |
| ); | |
| } | |
| try { | |
| fs.accessSync(expandedPath, fs.constants.R_OK); | |
| } catch { | |
| throw new Error( | |
| `Configuration file ${configPath}: source '${source.id}' sslrootcert file is not readable: '${expandedPath}'` | |
| ); | |
| } |
Uh oh!
There was an error while loading. Please reload this page.