Browse Source

Merge pull request #5364 from kamalmahmudi/fix/ssl-connection-config-with-file-path

fix (dbConfig): ssl connection with file path is not handled correctly
pull/5413/head
աɨռɢӄաօռɢ 2 years ago committed by GitHub
parent
commit
98cf923d78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      packages/nocodb/src/lib/db/sql-client/lib/SqlClientFactory.ts
  2. 15
      packages/nocodb/src/lib/utils/NcConfigFactory.ts

15
packages/nocodb/src/lib/db/sql-client/lib/SqlClientFactory.ts

@ -48,19 +48,22 @@ export default class {
typeof connectionConfig.connection.ssl === 'object' typeof connectionConfig.connection.ssl === 'object'
) { ) {
if (connectionConfig.connection.ssl.caFilePath) { if (connectionConfig.connection.ssl.caFilePath) {
connectionConfig.connection.ssl.ca = await promisify(fs.readFile)( connectionConfig.connection.ssl.ca = (await promisify(fs.readFile)(
connectionConfig.connection.ssl.caFilePath connectionConfig.connection.ssl.caFilePath
).toString(); )).toString();
delete connectionConfig.connection.ssl.caFilePath;
} }
if (connectionConfig.connection.ssl.keyFilePath) { if (connectionConfig.connection.ssl.keyFilePath) {
connectionConfig.connection.ssl.key = await promisify(fs.readFile)( connectionConfig.connection.ssl.key = (await promisify(fs.readFile)(
connectionConfig.connection.ssl.keyFilePath connectionConfig.connection.ssl.keyFilePath
).toString(); )).toString();
delete connectionConfig.connection.ssl.keyFilePath;
} }
if (connectionConfig.connection.ssl.certFilePath) { if (connectionConfig.connection.ssl.certFilePath) {
connectionConfig.connection.ssl.cert = await promisify(fs.readFile)( connectionConfig.connection.ssl.cert = (await promisify(fs.readFile)(
connectionConfig.connection.ssl.certFilePath connectionConfig.connection.ssl.certFilePath
).toString(); )).toString();
delete connectionConfig.connection.ssl.certFilePath;
} }
} }

15
packages/nocodb/src/lib/utils/NcConfigFactory.ts

@ -380,22 +380,25 @@ export default class NcConfigFactory implements NcConfig {
typeof dbConfig?.connection?.ssl === 'object' typeof dbConfig?.connection?.ssl === 'object'
) { ) {
if (dbConfig.connection.ssl.caFilePath && !dbConfig.connection.ssl.ca) { if (dbConfig.connection.ssl.caFilePath && !dbConfig.connection.ssl.ca) {
dbConfig.connection.ssl.ca = await promisify(fs.readFile)( dbConfig.connection.ssl.ca = (await promisify(fs.readFile)(
dbConfig.connection.ssl.caFilePath dbConfig.connection.ssl.caFilePath
).toString(); )).toString();
delete dbConfig.connection.ssl.caFilePath;
} }
if (dbConfig.connection.ssl.keyFilePath && !dbConfig.connection.ssl.key) { if (dbConfig.connection.ssl.keyFilePath && !dbConfig.connection.ssl.key) {
dbConfig.connection.ssl.key = await promisify(fs.readFile)( dbConfig.connection.ssl.key = (await promisify(fs.readFile)(
dbConfig.connection.ssl.keyFilePath dbConfig.connection.ssl.keyFilePath
).toString(); )).toString();
delete dbConfig.connection.ssl.keyFilePath;
} }
if ( if (
dbConfig.connection.ssl.certFilePath && dbConfig.connection.ssl.certFilePath &&
!dbConfig.connection.ssl.cert !dbConfig.connection.ssl.cert
) { ) {
dbConfig.connection.ssl.cert = await promisify(fs.readFile)( dbConfig.connection.ssl.cert = (await promisify(fs.readFile)(
dbConfig.connection.ssl.certFilePath dbConfig.connection.ssl.certFilePath
).toString(); )).toString();
delete dbConfig.connection.ssl.certFilePath;
} }
} }

Loading…
Cancel
Save