Re: SSL connections to postgresql in Azure

Michael Gentry <[email protected]>
Newsgroups gmane.comp.java.cayenne.user
Message-ID <CAOy5kzO4F=JUkyDFdEZNWVC6TSQP=BJDUxxF3xQHtKeDswNngA@mail.gmail.com>
I almost suggested adding parameters to the jdbc: URL to see if that might
work. Looks like it does and you found it.

Cheers!

mrg


On Wed, Jun 9, 2021 at 2:53 PM Rick Bonnett <[email protected]>
wrote:

> Since I didn't have to worry about cert validations, it was dead simple.
> Pretty much just copied my psql connection string into my java code:
>
>
> Module m1 = new Module() {
> public void configure(Binder binder) {
> binder.bindMap(Constants.PROPERTIES_MAP).put(Constants.JDBC_DRIVER_PROPERTY,
> "org.postgresql.Driver")
> .put(Constants.JDBC_URL_PROPERTY,
>  "jdbc:postgresql://<>:5432/are?user=<>&password=<>&ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory");
> }
> };
>
> *Rick Bonnett*
>
> *Programmer Analyst*
>
> Ascent Global Logistics
>
> PO Box 1039, Augusta, ME, 04332
>
> Office: 207.620.8670
>
> *ascentgl.com* <http://ascentgl.com/>
>
>
>
>
> ------------------------------
> *From:* Michael Gentry <[email protected]>
> *Sent:* Wednesday, June 9, 2021 1:37 PM
> *To:* Cayenne Users <[email protected]>
> *Subject:* Re: SSL connections to postgresql in Azure
>
>
> *EXTERNAL EMAIL:* Be extra careful around links and attachments.
> Sweet! What was the solution (in case anyone else searches for it)?
>
>
> On Wed, Jun 9, 2021 at 12:49 PM Rick Bonnett <[email protected]
> >
> wrote:
>
> > Thanks. That got me on the path to success
> >
> > *Rick Bonnett*
> >
> > *Programmer Analyst*
> >
> > Ascent Global Logistics
> >
> > PO Box 1039, Augusta, ME, 04332
> >
> > Office: 207.620.8670
> >
> > *ascentgl.com* <http://ascentgl.com/>
> >
> >
> >
> >
> > ------------------------------
> > *From:* Michael Gentry <[email protected]>
> > *Sent:* Wednesday, June 9, 2021 12:26 PM
> > *To:* Cayenne Users <[email protected]>
> > *Subject:* Re: SSL connections to postgresql in Azure
> >
> >
> > *EXTERNAL EMAIL:* Be extra careful around links and attachments.
> > Hi Rick,
> >
> > Are you connecting:
> >
> > a) local development system -> Azure Postgres
> > b) Azure server -> Azure Postgres?
> >
> > If "a", are there SSL certificates from Azure you need to load into your
> > local Java environment. Or you could try turning off SSL verification.
> See
> > more (for both options) here:
> >
> > https://jdbc.postgresql.org/documentation/head/ssl-client.html
> >
> > Also, maybe try adding:
> >
> > .put("ssl", "true"); // Or some other combo from above link...
> >
> >
> > On Wed, Jun 9, 2021 at 10:59 AM Rick Bonnett <
> [email protected]
> > >
> > wrote:
> >
> > >
> > > Having issues connecting to postgres in Azure - because by default SSL
> > > connections are required. I am using:
> > >
> > > - cayenne 3.1 - yes I know it's old but it's what I'm stuck with
> > > - latest postgres JDBC driver
> > >
> > > Code snippets below.
> > >
> > > On the JDBC_URLPROPERTY I have tried every flavor of ssslmode=required
> or
> > > usessl=true that I've been able to dredge up, but consistenyly getting:
> > >
> > > Unable to connect to server: FATAL: SSL connection is required. Please
> > > specify SSL options and retry.
> > >
> > > Hopefully I am just overlooking something simple and obvious. Any
> > insights?
> > >
> > > Module m1 = new Module() {
> > > public void configure(Binder binder) {
> > >
> >
> binder.bindMap(Constants.PROPERTIES_MAP).put(Constants.JDBC_DRIVER_PROPERTY,
> > > "org.postgresql.Driver")
> > > .put(Constants.JDBC_URL_PROPERTY, "jdbc:postgresql://
> > > http://mypostgres.postgres.database.azure.com:5432/are")
> > > .put(Constants.JDBC_USERNAME_PROPERTY, "<username>")
> > > .put(Constants.JDBC_PASSWORD_PROPERTY, "<password>");
> > > }
> > > };
> > >
> > > cayenneRuntime = new ServerRuntime("cayenne-ARETariffDomain.xml", m1);
> > > DataDomain dd = cayenneRuntime.getDataDomain();
> > > Collection<DataMap> dmaps = dd.getDataMaps();
> > > for (DataMap dm: dmaps) {
> > > for (DbEntity entity: dm.getDbEntities()) {
> > > entity.setSchema("p");
> > > }
> > > }
> > > ObjectContext ORMContext = cayenneRuntime.getContext();
> > >
> > >
> > >
> > > *Rick Bonnett*
> > >
> > > *Programmer Analyst*
> > >
> > > Ascent Global Logistics
> > >
> > > PO Box 1039, Augusta, ME, 04332
> > >
> > > Office: 207.620.8670
> > >
> > > *ascentgl.com* <http://ascentgl.com/>
> > >
> > >
> > >
> > >
> > > The information transmitted is intended only for the person or entity
> to
> > > which it is addressed and may contain proprietary,
> business-confidential
> > > and/or privileged material. If you are not the intended recipient of
> this
> > > message you are hereby notified that any use, review, retransmission,
> > > dissemination, distribution, reproduction or any action taken in
> reliance
> > > upon this message is prohibited. If you received this in error, please
> > > contact the sender and delete the material from any computer.
> > >
> >
> > The information transmitted is intended only for the person or entity to
> > which it is addressed and may contain proprietary, business-confidential
> > and/or privileged material. If you are not the intended recipient of this
> > message you are hereby notified that any use, review, retransmission,
> > dissemination, distribution, reproduction or any action taken in reliance
> > upon this message is prohibited. If you received this in error, please
> > contact the sender and delete the material from any computer.
> >
>
> The information transmitted is intended only for the person or entity to
> which it is addressed and may contain proprietary, business-confidential
> and/or privileged material. If you are not the intended recipient of this
> message you are hereby notified that any use, review, retransmission,
> dissemination, distribution, reproduction or any action taken in reliance
> upon this message is prohibited. If you received this in error, please
> contact the sender and delete the material from any computer.
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.