Skip to content

Add sslcert and sslrootcert to PgSQL\Connection and fix a small bug#461

Open
mesour wants to merge 7 commits intodg:masterfrom
mesour:mesour/pgsql-driver
Open

Add sslcert and sslrootcert to PgSQL\Connection and fix a small bug#461
mesour wants to merge 7 commits intodg:masterfrom
mesour:mesour/pgsql-driver

Conversation

@mesour
Copy link
Copy Markdown

@mesour mesour commented Aug 22, 2025

  • Add sslcert and sslrootcert to PgSQL\Connection and fix a small bug
  • BC break?no

Changes Made:

  1. Added SSL Certificate Support for PostgreSQL:

    • Extended the list of supported configuration parameters to include and sslcert, sslrootcert
    • These parameters allow specifying SSL certificates for secure connections to PostgreSQL databases
  2. Fixed TypeError Bug in Connection Handling:

    • Problem: The original code directly assigned values to $this->connection property, which has a strict type PgSql\Connection declaration
    • Issue: When pg_connect() returned false (connection failure), it caused a TypeError because false cannot be assigned to a property typed as PgSql\Connection
    • Consequence: The TypeError was thrown before reaching the proper error handling code below, making it impossible to determine what connection error actually occurred
    • Solution: Introduced a local variable that: $connection
      • First collects the connection result (whether from $config['resource'] or pg_pconnect())
      • Then validates the connection type with proper error checking
      • Only assigns to $this->connection after successful validation
      • This ensures that connection failures are properly caught and reported with meaningful error messages instead of generic TypeErrors

Technical Impact:

  • Before: Connection failures resulted in unhelpful TypeErrors, masking the actual database connection issues
  • After: Connection failures now properly throw with descriptive error messages, making debugging much easier Dibi\DriverException
  • Bonus: Added support for SSL certificate configuration in PostgreSQL connections

@dg dg force-pushed the master branch 3 times, most recently from 013da5d to c097256 Compare December 29, 2025 00:22
@dg dg force-pushed the master branch 2 times, most recently from e4d026a to b8621a7 Compare February 22, 2026 21:25
@dg dg force-pushed the master branch 5 times, most recently from 6935db8 to f167095 Compare April 5, 2026 04:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants