Jump to content



  • Please log in to reply
2 replies to this topic

#1 caduceus

  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 27 October 2005 - 12:25 AM

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?

#2 eawf

  • Members
  • PipPip
  • Member
  • 10 posts
  • LocationTacoma, WA

Posted 27 October 2005 - 06:17 AM

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.


#3 PriceComparison

  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 23 December 2005 - 04:22 AM

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:

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]

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users