pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Juan Miguel Paredes <juan.paredes@gmail.com>
To: Jeanna Geier <jgeier@apt-cafm.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: Beginner's Question: No pg_hba.conf entry for host...SSL Off
Date: Tue, 26 Sep 2006 09:34:11 -0400
Message-ID: <9e0a28690609260634n76a8a45fo6e5c28be367aad2f@mail.gmail.com> (raw)
In-Reply-To: <005a01c6e16f$36655d70$6700a8c0@geier>
References: <005a01c6e16f$36655d70$6700a8c0@geier>

On 9/26/06, Jeanna Geier <jgeier@apt-cafm.com> wrote:
> Hi All-
>
> I am hoping for some help on this one...  we are in the process of
> implementing our program with SSL enabled on the Postgres side of things.  I
> can start and connect to the database from the command line ok using my
> current configuration:
>
>   C:\msys\1.0\local\pgsql\bin>psql -d apt -U postgres
>   Welcome to psql 8.0.8, the PostgreSQL interactive terminal.
>
>   Type:  \copyright for distribution terms
>        \h for help with SQL commands
>        \? for help with psql commands
>        \g or terminate with semicolon to execute query
>        \q to quit
>
>   SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256)
>
>   Warning: Console code page (437) differs from Windows code page (1252)
>          8-bit characters may not work correctly. See psql reference
>          page "Notes for Windows users" for details.
>
>   apt=#
>
> However, when I try to run our application to and connect to the database, I
> am receiving the following error: Connection rejected: FATAL: no pg_hba.conf
> entry for host "127.0.0.1", user "postgres", database "apt", SSL off.
>
> Here is my pg_hba.conf file:
>
>   # TYPE DATABASE USER CIDR-ADDRESS METHOD
>   # IPv4 local connections:
>   #host all all 127.0.0.1/32 trust
>   # IPv6 local connections:
>   hostssl all all 127.0.0.1/32 trust
>
> I'm assuming that I have to put some code in my program to enable this
> connection besides just putting it in the conf file...but where exactly
> would this go?  Below is an excerpt of our connection code:
>
> public class DatabaseConnection {
>     private static String DB_IP;
>
>     private static final String DB_PORT = "5432";
>     private static String DB_CATALOG = "apt";
>     private static final String DB_USER = "postgres";
>     private static final String DB_PASSWORD = "XXXX";
>
>     public static void initIPAddress(String address){
>         DB_IP = address;
>     }
>
>     public static void initCatalog(String catalog){
>         DB_CATALOG = catalog;
>     }
>
>     public static Connection initialize() throws SQLException
>     {
>         final Connection connection;
>         Properties prop = new Properties();
>         String url;
>
>         try{
>             Class.forName("org.postgresql.Driver");
>
>             //url = "jdbc:postgresql://64.34.162.40:5432/apt";
>             url = "jdbc:postgresql://" + DB_IP + ":" + DB_PORT + "/" +
> DB_CATALOG;
>
>             //prop.setProperty("user","postgres");
>             //prop.setProperty("password", "XXXX");
>             prop.setProperty("user", DB_USER);
>             prop.setProperty("password", DB_PASSWORD);

Hi, Jeanna... I'm not a java programmer, but it looks like you could use

props.setProperty("ssl","true");

as seen in postgresql jdbc documentation:

http://jdbc.postgresql.org/documentation/80/connect.html

Regards.



view thread (7+ messages)  latest in thread

Message-ID: <9e0a28690609260634n76a8a45fo6e5c28be367aad2f@mail.gmail.com>
Permalink:  ../9e0a28690609260634n76a8a45fo6e5c28be367aad2f@mail.gmail.com/
Also on:    postgresql.org/message-id/9e0a28690609260634n76a8a45fo6e5c28be367aad2f@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: juan.paredes@gmail.com, jgeier@apt-cafm.com
  Subject: Re: Beginner's Question: No pg_hba.conf entry for host...SSL Off
  In-Reply-To: <9e0a28690609260634n76a8a45fo6e5c28be367aad2f@mail.gmail.com>
  References: <005a01c6e16f$36655d70$6700a8c0@geier> <9e0a28690609260634n76a8a45fo6e5c28be367aad2f@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox