pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
using ssl some of the time
8+ messages / 3 participants
[nested] [flat]

* using ssl some of the time
@ 2003-07-22 23:09 Charles Hornberger <charlie@hss.caltech.edu>
  2003-07-23 04:24 ` Re: using ssl some of the time Bruce Momjian <pgman@candle.pha.pa.us>
  0 siblings, 1 reply; 8+ messages in thread

From: Charles Hornberger @ 2003-07-22 23:09 UTC (permalink / raw)
  To: pgsql-admin

I'm having a bit of trouble understanding exactly how SSL-encrypted 
connections are supposed to work -- and specifically whether it's 
possible to "use SSL some of the time."

Here's what I want to do:

1) I want one of my web servers to be able to connect to the database 
without the overhead of SSL (it connects as an unprivileged user who 
just does SELECTs).

2) I want to allow connections from another machine -- also a web server 
-- ONLY if they're encrypted with SSL (users with the ability to 
INSERT/UPDATE will be connecting with passwords via a web/db interface 
hosted on this machine).

It seems to me that I can't do both. If I turn on the 'ssl=true' option 
in $PGDATA/postgresql.conf, then connections from psql at least are 
_always_ encrypted, no matter what's in pg_hba.conf.

For the record, here's what's in pg_hba.conf (notably, there's no 
hostssl entry):

local    all    all                                     trust
host     all    all       127.0.0.1   255.255.255.255   trust


And here's what happens when I connect with psql:

[economex] charlie/$ psql -h 127.0.0.1 template1
Welcome to psql 7.3.1, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
        \h for help with SQL commands
        \? for help on internal slash commands
        \g or terminate with semicolon to execute query
        \q to quit

SSL connection (cipher: EDH-RSA-DES-CBC3-SHA, bits: 168)

template1=> \q

... which looks encrypted to me.

Am I right in interpreting this to mean that I either have to use SSL 
all the time or none of the time?  I'm especially tempted to believe 
this might be the case after seeing this item in the "Clients" section 
of http://developer.postgresql.org/todo.php:

   - Allow SSL-enabled clients to turn off SSL transfers

Does that mean that, if SSL is enabled for the postmaster, the client 
will always be forced to use SSL? Or is there something I need to do to 
force the client to NOT use SSL?

Thanks,
Charlie




^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: using ssl some of the time
  2003-07-22 23:09 using ssl some of the time Charles Hornberger <charlie@hss.caltech.edu>
@ 2003-07-23 04:24 ` Bruce Momjian <pgman@candle.pha.pa.us>
  2003-07-23 04:38   ` Re: using ssl some of the time Charles Hornberger <charlie@hss.caltech.edu>
  0 siblings, 1 reply; 8+ messages in thread

From: Bruce Momjian @ 2003-07-23 04:24 UTC (permalink / raw)
  To: Charles Hornberger <charlie@hss.caltech.edu>; +Cc: pgsql-admin

Charles Hornberger wrote:
> Am I right in interpreting this to mean that I either have to use SSL 
> all the time or none of the time?  I'm especially tempted to believe 
> this might be the case after seeing this item in the "Clients" section 
> of http://developer.postgresql.org/todo.php:
> 
>    - Allow SSL-enabled clients to turn off SSL transfers
> 
> Does that mean that, if SSL is enabled for the postmaster, the client 
> will always be forced to use SSL? Or is there something I need to do to 
> force the client to NOT use SSL?

Right, it will use SSL if possible, so if both client and server are SSL
enabled, SSL will be used. 7.4 will allow you to control that.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: using ssl some of the time
  2003-07-22 23:09 using ssl some of the time Charles Hornberger <charlie@hss.caltech.edu>
  2003-07-23 04:24 ` Re: using ssl some of the time Bruce Momjian <pgman@candle.pha.pa.us>
@ 2003-07-23 04:38   ` Charles Hornberger <charlie@hss.caltech.edu>
  2003-07-23 17:54     ` Re: using ssl some of the time Bruce Momjian <pgman@candle.pha.pa.us>
  0 siblings, 1 reply; 8+ messages in thread

From: Charles Hornberger @ 2003-07-23 04:38 UTC (permalink / raw)
  To: Bruce Momjian <pgman@candle.pha.pa.us>; +Cc: pgsql-admin

On Wed, 23 Jul 2003, Bruce Momjian wrote:
> Charles Hornberger wrote:
> > Am I right in interpreting this to mean that I either have to use SSL 
> > all the time or none of the time?  I'm especially tempted to believe 
> > this might be the case after seeing this item in the "Clients" section 
> > of http://developer.postgresql.org/todo.php:
> > 
> >    - Allow SSL-enabled clients to turn off SSL transfers
> > 
> > Does that mean that, if SSL is enabled for the postmaster, the client 
> > will always be forced to use SSL? Or is there something I need to do to 
> > force the client to NOT use SSL?
> 
> Right, it will use SSL if possible, so if both client and server are SSL
> enabled, SSL will be used. 7.4 will allow you to control that.

Interesting. So, am I right in thinking that in 7.3.x, theoretically it'd
be possible to build the postgres backends with SSL support but the
clients -- and I guess libpq is really what I'm talking about here, since
normally I'm connecting via Python or PHP -- without it? And would an
SSL-enabled backend agree to talk to a SSL-disabled client?

As an aside: The only reason I'm worring about this is that sometimes my
client apps generate rather large query results and as far as I can tell,
the overhead of SSL encryption/decryption is slowing things down quite
noticeably in those cases. But I'm pretty ignorant about these matters,
and maybe SSL's not to blame (although I'd be hard pressed to explain the
difference in query performance between local and SSL-over-TCP connections
otherwise).

-Charlie




^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: using ssl some of the time
  2003-07-22 23:09 using ssl some of the time Charles Hornberger <charlie@hss.caltech.edu>
  2003-07-23 04:24 ` Re: using ssl some of the time Bruce Momjian <pgman@candle.pha.pa.us>
  2003-07-23 04:38   ` Re: using ssl some of the time Charles Hornberger <charlie@hss.caltech.edu>
@ 2003-07-23 17:54     ` Bruce Momjian <pgman@candle.pha.pa.us>
  2003-07-24 18:18       ` Re: using ssl some of the time Charles Hornberger <charlie@hss.caltech.edu>
  0 siblings, 1 reply; 8+ messages in thread

From: Bruce Momjian @ 2003-07-23 17:54 UTC (permalink / raw)
  To: Charles Hornberger <charlie@hss.caltech.edu>; +Cc: pgsql-admin

Charles Hornberger wrote:
> On Wed, 23 Jul 2003, Bruce Momjian wrote:
> > Charles Hornberger wrote:
> > > Am I right in interpreting this to mean that I either have to use SSL 
> > > all the time or none of the time?  I'm especially tempted to believe 
> > > this might be the case after seeing this item in the "Clients" section 
> > > of http://developer.postgresql.org/todo.php:
> > > 
> > >    - Allow SSL-enabled clients to turn off SSL transfers
> > > 
> > > Does that mean that, if SSL is enabled for the postmaster, the client 
> > > will always be forced to use SSL? Or is there something I need to do to 
> > > force the client to NOT use SSL?
> > 
> > Right, it will use SSL if possible, so if both client and server are SSL
> > enabled, SSL will be used. 7.4 will allow you to control that.
> 
> Interesting. So, am I right in thinking that in 7.3.x, theoretically it'd
> be possible to build the postgres backends with SSL support but the
> clients -- and I guess libpq is really what I'm talking about here, since
> normally I'm connecting via Python or PHP -- without it? And would an
> SSL-enabled backend agree to talk to a SSL-disabled client?

Yes, you could to it, but by default, libpq will have SSL compiled in it
just like the backend, but if you created a non-ssl client, it would
talk to the postmaster just fine, unless you have hostssl in
pg_hba.conf.

> As an aside: The only reason I'm worring about this is that sometimes my
> client apps generate rather large query results and as far as I can tell,
> the overhead of SSL encryption/decryption is slowing things down quite
> noticeably in those cases. But I'm pretty ignorant about these matters,
> and maybe SSL's not to blame (although I'd be hard pressed to explain the
> difference in query performance between local and SSL-over-TCP connections
> otherwise).

Please let us know what you find from testing.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: using ssl some of the time
  2003-07-22 23:09 using ssl some of the time Charles Hornberger <charlie@hss.caltech.edu>
  2003-07-23 04:24 ` Re: using ssl some of the time Bruce Momjian <pgman@candle.pha.pa.us>
  2003-07-23 04:38   ` Re: using ssl some of the time Charles Hornberger <charlie@hss.caltech.edu>
  2003-07-23 17:54     ` Re: using ssl some of the time Bruce Momjian <pgman@candle.pha.pa.us>
@ 2003-07-24 18:18       ` Charles Hornberger <charlie@hss.caltech.edu>
  2003-07-24 20:44         ` Re: using ssl some of the time Bruce Momjian <pgman@candle.pha.pa.us>
  0 siblings, 1 reply; 8+ messages in thread

From: Charles Hornberger @ 2003-07-24 18:18 UTC (permalink / raw)
  To: Bruce Momjian <pgman@candle.pha.pa.us>; +Cc: pgsql-admin

Bruce Momjian wrote:
> Charles Hornberger wrote:
> 
>>On Wed, 23 Jul 2003, Bruce Momjian wrote:
>>
>>>Charles Hornberger wrote:
>>>
>>>>Am I right in interpreting this to mean that I either have to use SSL 
>>>>all the time or none of the time?  I'm especially tempted to believe 
>>>>this might be the case after seeing this item in the "Clients" section 
>>>>of http://developer.postgresql.org/todo.php:
>>>>
>>>>   - Allow SSL-enabled clients to turn off SSL transfers
>>>>
>>>>Does that mean that, if SSL is enabled for the postmaster, the client 
>>>>will always be forced to use SSL? Or is there something I need to do to 
>>>>force the client to NOT use SSL?
>>>
>>>Right, it will use SSL if possible, so if both client and server are SSL
>>>enabled, SSL will be used. 7.4 will allow you to control that.


I have one more question about the plans for 7.4. How will users of 
clients based on libpq use this? Will there be a new optional connection 
parameter ('ssl=true') or something?


>>As an aside: The only reason I'm worring about this is that sometimes my
>>client apps generate rather large query results and as far as I can tell,
>>the overhead of SSL encryption/decryption is slowing things down quite
>>noticeably in those cases. But I'm pretty ignorant about these matters,
>>and maybe SSL's not to blame (although I'd be hard pressed to explain the
>>difference in query performance between local and SSL-over-TCP connections
>>otherwise).
> 
> 
> Please let us know what you find from testing.
> 

Just a quick follow-up to share one (!) data point, which looks to me 
like it indicates that SSL encryption/decryption is pretty expensive on 
one of our Sun Ultra 5 boxes. The following query ("select * from wp") 
generates ~270K of output. When executed via a psql client that's 
connected over a non-encrypted link, it takes 0.7 seconds; over an 
encrypted link, it takes more than 10 times that long.

# time psql -qAt -c 'select * from wp' eclatch > /dev/null
real    0m0.718s
user    0m0.120s
sys     0m0.080s
# time psql -h localhost -qAt -c 'select * from wp' eclatch > /dev/null
real    0m8.081s
user    0m3.930s
sys     0m0.410s
# psql -qAt -c 'select * from wp' eclatch | wc
     2057   30717  276549
# psql -c "select version()" template1
                              version
------------------------------------------------------------------
  PostgreSQL 7.3.2 on sparc-sun-solaris2.7, compiled by GCC 2.95.2

-Charlie




^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: using ssl some of the time
  2003-07-22 23:09 using ssl some of the time Charles Hornberger <charlie@hss.caltech.edu>
  2003-07-23 04:24 ` Re: using ssl some of the time Bruce Momjian <pgman@candle.pha.pa.us>
  2003-07-23 04:38   ` Re: using ssl some of the time Charles Hornberger <charlie@hss.caltech.edu>
  2003-07-23 17:54     ` Re: using ssl some of the time Bruce Momjian <pgman@candle.pha.pa.us>
  2003-07-24 18:18       ` Re: using ssl some of the time Charles Hornberger <charlie@hss.caltech.edu>
@ 2003-07-24 20:44         ` Bruce Momjian <pgman@candle.pha.pa.us>
  2003-07-24 21:29           ` Re: using ssl some of the time Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 8+ messages in thread

From: Bruce Momjian @ 2003-07-24 20:44 UTC (permalink / raw)
  To: Charles Hornberger <charlie@hss.caltech.edu>; +Cc: pgsql-admin

Charles Hornberger wrote:
> Bruce Momjian wrote:
> > Charles Hornberger wrote:
> > 
> >>On Wed, 23 Jul 2003, Bruce Momjian wrote:
> >>
> >>>Charles Hornberger wrote:
> >>>
> >>>>Am I right in interpreting this to mean that I either have to use SSL 
> >>>>all the time or none of the time?  I'm especially tempted to believe 
> >>>>this might be the case after seeing this item in the "Clients" section 
> >>>>of http://developer.postgresql.org/todo.php:
> >>>>
> >>>>   - Allow SSL-enabled clients to turn off SSL transfers
> >>>>
> >>>>Does that mean that, if SSL is enabled for the postmaster, the client 
> >>>>will always be forced to use SSL? Or is there something I need to do to 
> >>>>force the client to NOT use SSL?
> >>>
> >>>Right, it will use SSL if possible, so if both client and server are SSL
> >>>enabled, SSL will be used. 7.4 will allow you to control that.
> 
> 
> I have one more question about the plans for 7.4. How will users of 
> clients based on libpq use this? Will there be a new optional connection 
> parameter ('ssl=true') or something?

Yes, exactly.

> Just a quick follow-up to share one (!) data point, which looks to me 
> like it indicates that SSL encryption/decryption is pretty expensive on 
> one of our Sun Ultra 5 boxes. The following query ("select * from wp") 
> generates ~270K of output. When executed via a psql client that's 
> connected over a non-encrypted link, it takes 0.7 seconds; over an 
> encrypted link, it takes more than 10 times that long.
> 
> # time psql -qAt -c 'select * from wp' eclatch > /dev/null
> real    0m0.718s
> user    0m0.120s
> sys     0m0.080s
> # time psql -h localhost -qAt -c 'select * from wp' eclatch > /dev/null
> real    0m8.081s
> user    0m3.930s
> sys     0m0.410s
> # psql -qAt -c 'select * from wp' eclatch | wc
>      2057   30717  276549
> # psql -c "select version()" template1

Wow.  I wonder if we should be using SSL by default in our connections.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: using ssl some of the time
  2003-07-22 23:09 using ssl some of the time Charles Hornberger <charlie@hss.caltech.edu>
  2003-07-23 04:24 ` Re: using ssl some of the time Bruce Momjian <pgman@candle.pha.pa.us>
  2003-07-23 04:38   ` Re: using ssl some of the time Charles Hornberger <charlie@hss.caltech.edu>
  2003-07-23 17:54     ` Re: using ssl some of the time Bruce Momjian <pgman@candle.pha.pa.us>
  2003-07-24 18:18       ` Re: using ssl some of the time Charles Hornberger <charlie@hss.caltech.edu>
  2003-07-24 20:44         ` Re: using ssl some of the time Bruce Momjian <pgman@candle.pha.pa.us>
@ 2003-07-24 21:29           ` Tom Lane <tgl@sss.pgh.pa.us>
  2003-07-24 21:53             ` Re: using ssl some of the time Bruce Momjian <pgman@candle.pha.pa.us>
  0 siblings, 1 reply; 8+ messages in thread

From: Tom Lane @ 2003-07-24 21:29 UTC (permalink / raw)
  To: Bruce Momjian <pgman@candle.pha.pa.us>; +Cc: Charles Hornberger <charlie@hss.caltech.edu>; pgsql-admin

> Charles Hornberger wrote:
>> Just a quick follow-up to share one (!) data point, which looks to me 
>> like it indicates that SSL encryption/decryption is pretty expensive on 
>> one of our Sun Ultra 5 boxes. The following query ("select * from wp") 
>> generates ~270K of output. When executed via a psql client that's 
>> connected over a non-encrypted link, it takes 0.7 seconds; over an 
>> encrypted link, it takes more than 10 times that long.

I suspect most of this is from the ridiculously small renegotiation
interval we put into 7.3.  Try increasing RENEGOTIATION_LIMIT in
src/backend/libpq/be-secure.c (we've bumped it to 512 meg for 7.4).

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: using ssl some of the time
  2003-07-22 23:09 using ssl some of the time Charles Hornberger <charlie@hss.caltech.edu>
  2003-07-23 04:24 ` Re: using ssl some of the time Bruce Momjian <pgman@candle.pha.pa.us>
  2003-07-23 04:38   ` Re: using ssl some of the time Charles Hornberger <charlie@hss.caltech.edu>
  2003-07-23 17:54     ` Re: using ssl some of the time Bruce Momjian <pgman@candle.pha.pa.us>
  2003-07-24 18:18       ` Re: using ssl some of the time Charles Hornberger <charlie@hss.caltech.edu>
  2003-07-24 20:44         ` Re: using ssl some of the time Bruce Momjian <pgman@candle.pha.pa.us>
  2003-07-24 21:29           ` Re: using ssl some of the time Tom Lane <tgl@sss.pgh.pa.us>
@ 2003-07-24 21:53             ` Bruce Momjian <pgman@candle.pha.pa.us>
  0 siblings, 0 replies; 8+ messages in thread

From: Bruce Momjian @ 2003-07-24 21:53 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Charles Hornberger <charlie@hss.caltech.edu>; pgsql-admin

Tom Lane wrote:
> > Charles Hornberger wrote:
> >> Just a quick follow-up to share one (!) data point, which looks to me 
> >> like it indicates that SSL encryption/decryption is pretty expensive on 
> >> one of our Sun Ultra 5 boxes. The following query ("select * from wp") 
> >> generates ~270K of output. When executed via a psql client that's 
> >> connected over a non-encrypted link, it takes 0.7 seconds; over an 
> >> encrypted link, it takes more than 10 times that long.
> 
> I suspect most of this is from the ridiculously small renegotiation
> interval we put into 7.3.  Try increasing RENEGOTIATION_LIMIT in
> src/backend/libpq/be-secure.c (we've bumped it to 512 meg for 7.4).

Yes, good point!  Would you try 7.4 or that change and let us know the
results?

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073



^ permalink  raw  reply  [nested|flat] 8+ messages in thread


end of thread, other threads:[~2003-07-24 21:53 UTC | newest]

Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-07-22 23:09 using ssl some of the time Charles Hornberger <charlie@hss.caltech.edu>
2003-07-23 04:24 ` Bruce Momjian <pgman@candle.pha.pa.us>
2003-07-23 04:38   ` Charles Hornberger <charlie@hss.caltech.edu>
2003-07-23 17:54     ` Bruce Momjian <pgman@candle.pha.pa.us>
2003-07-24 18:18       ` Charles Hornberger <charlie@hss.caltech.edu>
2003-07-24 20:44         ` Bruce Momjian <pgman@candle.pha.pa.us>
2003-07-24 21:29           ` Tom Lane <tgl@sss.pgh.pa.us>
2003-07-24 21:53             ` Bruce Momjian <pgman@candle.pha.pa.us>

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