php icon indicating copy to clipboard operation
php copied to clipboard

upgrade pdo_pgsql to support SNI

Open guoxiangke opened this issue 1 year ago • 16 comments

upgrade pdo_pgsql to support SNI

Hi, I use 8.1 & 8.2 and try to connect pgsql( provided by neon.tech) with laravel+vercel [email protected] - PHP 8.2.x (https://example-php-8-2.vercel.app/) [email protected] - PHP 8.1.x (https://example-php-8-1.vercel.app/)

But I met blow problems:

SQLSTATE[08006] [7] ERROR: Endpoint ID is not specified. Either please upgrade the postgres client library (libpq) for SNI support or pass the endpoint ID (first part of the domain name) as a parameter: '?options=endpoint%3D<endpoint-id>'. See more at https://neon.tech/sni
ERROR: connection is insecure (try using `sslmode=require`) (Connection: pgsql, SQL: select * from "users" where "email" = 
https://neon.tech/docs/connect/connectivity-issues

I tried config/database.config each options, not work 'sslmode' => 'verify-full',//prefer/require

I think we need update pdo_pgsql > 10.21
my local is pdo_pgsql 15.1 and works.

guoxiangke avatar Jun 02 '23 13:06 guoxiangke

thanks.

guoxiangke avatar Jun 02 '23 13:06 guoxiangke

I am also facing that issue too, we have to update that in vercel php.

theaungmyatmoe avatar Jun 12 '23 14:06 theaungmyatmoe

Related: https://github.com/vercel/storage/issues/120

asispts avatar Jun 26 '23 15:06 asispts

Hi. Do you know which exactly libraries needs to be upgraded?

f3l1x avatar Jun 26 '23 18:06 f3l1x

pgsql Liv I think so

theaungmyatmoe avatar Jun 26 '23 19:06 theaungmyatmoe

Same here. Is there any way to upgrade the libpq?

The [email protected] - PHP 8.2.x (https://example-php-8-2.vercel.app/) shows the version of libpq is 10.21, which is unsupported now.

The latest version is 16 and according to neon.tech (Vercel's Postgres provider), SNI support was added to the libpq in version 14, which was released in September 2021.

coolymoon avatar Nov 14 '23 05:11 coolymoon

I ran into a similar problem today. I make connection via pg_connect and to solve the problem I added options='endpoint=ep-shrill-disk-*****'

The connection worked successfully $connect_data = "host=ep-shrill-disk-.eu-central-1.aws.neon.tech port=5432 dbname=php-neon user=daniil.bazhenov password= sslmode=require options='endpoint=ep-shrill-disk-*****'";

$db_connect = pg_connect($connect_data);

dbazhenov avatar Nov 20 '23 12:11 dbazhenov

@dbazhenov I was having the same issue in laravel vercel, How to do this "options='endpoint=ep-shrill-disk-*****'" in laravel, i tried but not working

deepakplay avatar Dec 04 '23 16:12 deepakplay

If you're using Laravel, you can use this package https://github.com/braumye/laravel-vercel-postgres that add the endpoint to the options of the dsn and it worked for me.

Neon document: https://neon.tech/docs/connect/connection-errors#b-use-libpq-keyvalue-syntax-in-the-database-field

braumye avatar Dec 25 '23 04:12 braumye

I encountered the same issue during deployment today and hope that Vercel can promptly upgrade pdo_pgsql to support SNI.

JIeJaitt avatar Jan 09 '24 06:01 JIeJaitt

I faced same error today. I think it is because of pgsql lib.

aungmoe32 avatar Jan 13 '24 19:01 aungmoe32

hi i have a same error, i trying to use laravel with postgres, but when i access database to get data i have this error: "could not find driver (Connection: pgsql, SQL: select * from "users" where "email" = [email protected] limit 1)". Does anyone know how to solve this?

DavidHGJ avatar Jan 23 '24 21:01 DavidHGJ

Hi, I will prepare PHP update with postgres14. I hope it will solve your troubles.

f3l1x avatar Jan 24 '24 00:01 f3l1x

Hello, The official work-around that seems to work is to append the endpoint_ID with the password in the connection string like

DATABASE_URL=postgres://dbuser:<endpoint=<endpoint_id>>;<your_password>@ep-broad-snowflake-sdexc.il-central-1.aws.neon.tech/neondb?pgbouncer=true&connect_timeout=10

So basically, add this --> endpoint=<endpoint_id>; (including the comma)

Alternatively, if you are using database connection parameters, you can use the following

...
DB_PASSWORD='<endpoint=<endpoint_id>>;<your_password>' 

In our case, the endpoint ID is --> ep-broad-snowflake-sdexc (as seen in the connection URL above)

Hope this helps.

zone-connect avatar Feb 15 '24 19:02 zone-connect

@zone-connect Thenk you kind sir

Yorften avatar Jun 07 '24 14:06 Yorften

If you're using Laravel, you can use this package https://github.com/braumye/laravel-vercel-postgres that add the endpoint to the options of the dsn and it worked for me.

Neon document: https://neon.tech/docs/connect/connection-errors#b-use-libpq-keyvalue-syntax-in-the-database-field

Connect with success using this package, but now I have this error:

 INFO  Preparing database.  

  Creating migration table .............................................................................................................. 425ms DONE

   INFO  Running migrations.  

  2014_10_12_000000_create_users_table .................................................................................................. 704ms DONE
  2014_10_12_100000_create_password_reset_tokens_table .................................................................................. 844ms FAIL

   Illuminate\Database\QueryException 

  SQLSTATE[25P02]: In failed sql transaction: 7 ERROR:  current transaction is aborted, commands ignored until end of transaction block (Connection: pgsql, SQL: alter table "password_reset_tokens" add primary key ("email"))

  at vendor\laravel\framework\src\Illuminate\Database\Connection.php:822
    818▕                     $this->getName(), $query, $this->prepareBindings($bindings), $e
    819▕                 );
    820▕             }
    821▕
  ➜ 822▕             throw new QueryException(
    823▕                 $this->getName(), $query, $this->prepareBindings($bindings), $e
    824▕             );
    825▕         }
    826▕     }

  1   vendor\laravel\framework\src\Illuminate\Database\Connection.php:580
      PDOException::("SQLSTATE[25P02]: In failed sql transaction: 7 ERROR:  current transaction is aborted, commands ignored until end of transaction block")

  2   vendor\laravel\framework\src\Illuminate\Database\Connection.php:580
      PDOStatement::execute()

ThiagoDOM avatar Jun 26 '24 19:06 ThiagoDOM