Merge pull request #763 from buster-so/staging

Update PostgreSQL adapter SSL configuration to allow self-signed cert…
This commit is contained in:
dal 2025-08-25 00:34:48 -06:00 committed by GitHub
commit d6e2c70bcf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 5 deletions

View File

@ -43,7 +43,7 @@ describe('PostgreSQLAdapter', () => {
database: 'testdb', database: 'testdb',
user: 'testuser', user: 'testuser',
password: 'testpass', password: 'testpass',
ssl: true, ssl: { rejectUnauthorized: false },
}); });
expect(mockClient.connect).toHaveBeenCalled(); expect(mockClient.connect).toHaveBeenCalled();
}); });
@ -130,7 +130,7 @@ describe('PostgreSQLAdapter', () => {
expect(Client).toHaveBeenCalledWith( expect(Client).toHaveBeenCalledWith(
expect.objectContaining({ expect.objectContaining({
ssl: true, ssl: { rejectUnauthorized: false },
}) })
); );
}); });

View File

@ -51,7 +51,8 @@ export class PostgreSQLAdapter extends BaseAdapter {
// Handle SSL configuration - default to true for security // Handle SSL configuration - default to true for security
// But allow self-signed certificates to avoid connection errors // But allow self-signed certificates to avoid connection errors
if (pgCredentials.ssl !== false) { if (pgCredentials.ssl !== false) {
config.ssl = pgCredentials.ssl === true || pgCredentials.ssl === undefined config.ssl =
pgCredentials.ssl === true || pgCredentials.ssl === undefined
? { rejectUnauthorized: false } // Allow self-signed certificates ? { rejectUnauthorized: false } // Allow self-signed certificates
: pgCredentials.ssl; // Use custom SSL config if provided : pgCredentials.ssl; // Use custom SSL config if provided
} }