SSL Connections in Ruby with ruby-postgres

Not much here, just a quick note about getting SSL connections to PostgreSQL in Ruby. According to the ruby-postgres documentation arbitrary libpg options can be passed to the PGconn.open() call. Calling PGconn.open like this:

conn = PGconn.open( 'host'    => 'host.domain.com',
                    'options' => 'sslmode=require' )

results in PGError: FATAL: invalid command-line arguments for server process. After digging at some forums and the ruby-postgres source code I found that one needs to prepend the options string with -o, so a working example is:

conn = PGconn.open( 'host'    => 'host.domain.com',
                    'options' => '-o sslmode=require' )

Comments are closed.