PostgreSQL + SSL DSN?

136 views
Skip to first unread message

Seth Johnson

unread,
Mar 28, 2013, 11:31:42 AM3/28/13
to ra...@googlegroups.com
Is it possible using Railo to create a data source pointing to a PostgreSQL database that requires SSL on a remote server using Railo?

Thank you,

Seth

Chris Blackwell

unread,
Mar 28, 2013, 12:18:48 PM3/28/13
to ra...@googlegroups.com
yes, but you have to configure the datasource as type "other"

class: org.postgresql.Driver
connection string: jdbc:postgresql://host:port/database?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory

This is one of those situations where it'd be really useful to have an "additional params" field in predefined datasource types (like ACF does ;)

Chris

--
Need help right now? Why not have one of the Railo Team help you directly: http://www.getrailo.com/index.cfm/consulting/
---
You received this message because you are subscribed to the Google Groups "Railo" group.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Igal Sapir

unread,
Mar 28, 2013, 12:20:55 PM3/28/13
to Railo List

@Chris -- can you open a Feature Request for that in the JIRA?

Thanks

--
typos, misspels, and other weird words brought to you courtesy of my mobile device and its auto-(in)correct feature.

Seth Johnson

unread,
Mar 28, 2013, 12:26:48 PM3/28/13
to ra...@googlegroups.com
Sorry for my ignorance, do I then have to copy the client crt files into a directory on the server somewhere?  I'm on Ubuntu 12.04 and Railo 4.

Thanks!

Seth


You received this message because you are subscribed to a topic in the Google Groups "Railo" group.

Chris Blackwell

unread,
Mar 28, 2013, 12:43:06 PM3/28/13
to ra...@googlegroups.com
Nope, because you use the NonValidatingFactory
This doesn't check the validity of the ssl certificate that the postgres server presents, making it really easy to setup, at the expense of complete security

The alternative is to install the certificate on your railo server, to that see the docs here

Chris

Chris Blackwell

unread,
Mar 28, 2013, 12:51:51 PM3/28/13
to ra...@googlegroups.com

Igal @ getRailo.org

unread,
Mar 28, 2013, 12:52:55 PM3/28/13
to ra...@googlegroups.com
thank you :)

Seth Johnson

unread,
Mar 28, 2013, 12:53:42 PM3/28/13
to ra...@googlegroups.com
Great Chris, thank you for the information.

Seth

Seth Johnson

unread,
Mar 28, 2013, 3:20:17 PM3/28/13
to ra...@googlegroups.com
That worked perfectly, for my next trick I need to programmatically create these "other" datasources on the fly.  Looking at the documentation for Railo's cfadmin tag it looks like I can update and verify datasources, but not necessarily create datasources.  Do anyone know if that is the case?  I also read somewhere that there is a newDatasource() function you can use to create per app datasources, but I could not find any documentation on that function.

Thanks,

Seth


Jochem van Dieten

unread,
Apr 1, 2013, 12:53:50 PM4/1/13
to ra...@googlegroups.com
cfadmin action="updateDatasource" works for creating a new datasource as well. Just give name and newname both the value of the datasource you want to create.

Jochem

Seth Johnson

unread,
Apr 1, 2013, 12:54:49 PM4/1/13
to ra...@googlegroups.com

Perfect, thank you!

Seth

Chris Blackwell

unread,
Apr 1, 2013, 2:10:32 PM4/1/13
to railo
Seth, if you're using Railo 4.1 you can actually specify the datasource directly in Application.cfc.

I've been using this for a little project i'm working on that uses heroku and parses the db connection string from an environment variable.

You can see an example here, The example is for MySQL but you should get the idea

Chris

Seth Johnson

unread,
Apr 1, 2013, 4:11:48 PM4/1/13
to ra...@googlegroups.com

Nice, this should work well.  I don't necessarily want to create hundreds of datasources if I don't have to, so if this works dynamically it will be perfect.

to...@3lll.asia

unread,
Sep 26, 2014, 2:29:07 PM9/26/14
to ra...@googlegroups.com
Hi Chris

Thanks for the info on postgresql...

I'm trying to do the same with MySQL using railo-server.xml

<data-source allow="511" blob="false" class="org.gjt.mm.mysql.Driver" clob="false" connectionTimeout="1" custom="useUnicode=true&amp;characterEncoding=UTF-8&amp;useLegacyDatetimeCode=true" database="food13" dbdriver="MySQL" dsn="jdbc:mysql://{host}:{port}/{database}" host="xxx.xxx.xxx.xxx" metaCacheTimeout="60000" name="xxxxx" password="encrypted:xxxxxxx" port="3306" storage="false" username="root" validate="false"/></data-sources>

How would I incorporate the NonValidatingFactory and other SSL parameters within this file?

TIA

Chris Blackwell

unread,
Sep 27, 2014, 3:36:15 AM9/27/14
to railo

NonValidatingFactory is a postgres class, it doesn't apply to mysql. 

are you trying to connect to a mysql database that is using an ssl secured connection?

--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki

---
You received this message because you are subscribed to the Google Groups "Railo" group.

to...@3lll.asia

unread,
Sep 28, 2014, 1:26:40 PM9/28/14
to ra...@googlegroups.com
Hi Chris

Yes I am and need to put the ssl information into the railo-server.xml file...
Reply all
Reply to author
Forward
0 new messages