Jump to content

Recommended Posts

HI,

Can anybody help how to connect to PostgreSQL form PHP over SSL.

I know PG_Connect can be used with option requiressl, but I did not find any resource about that. Do you have some links to web pages where this is well explained?

Any other way how to remotely connect to Postgres securely?

Link to comment
https://forums.phpfreaks.com/topic/2741-postgresql-secure-connection-php/
Share on other sites

Check out Justin Vincents "ez_sql" database wrapper class, modify it for PostgreSQL(only takes a couple lines), and then check out how it all works. It will ultimately save you LOTS of headaches, and database can be anywhere, ssl or not.

 

HTH!

  • 1 month later...

First you have to turn on SSL support in the postgresql.conf configuration file.

 

Then it depends on your library of choice to use from php.

I use the standard libpq default if you compile PHP with postgresql support.

 

The pg_connect function supports the connection to a Postgresql SSL ready server.

Just look at the parameter option about the SSL:

 

connection_string

The connection_string can be empty to use all default parameters, or it can contain one or more parameter settings separated by whitespace. Each parameter setting is in the form keyword = value. Spaces around the equal sign are optional. To write an empty value or a value containing spaces, surround it with single quotes, e.g., keyword = 'a value'. Single quotes and backslashes within the value must be escaped with a backslash, i.e., \' and \\.

 

The currently recognized parameter keywords are: host, hostaddr, port, dbname, user, password, connect_timeout, options, tty (ignored), sslmode, requiressl (deprecated in favor of sslmode), and service. Which of these arguments exist depends on your PostgreSQL version.

 

Andrew - DBA for [a href=\"http://www.PriceComparison.com\" target=\"_blank\"]http://www.PriceComparison.com[/a]

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.