Adding a HostnameVerifier to Postgres database properties

Short form:  How do I use the "sslhostnameverifier" option in the "Data Sources and Dialogs" dialog for databases?

Longer form:

I switched from Java 8b121 to build 152 this morning.  About then my postgres database connections starting returning completely unhelpful errors such as 

Connection to <database> refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.

and Host is down (connect failed)

Connecting via psql still works just fine.

In reading the change logs for the Java versions I skipped over, I noted that in build 141:

Earlier releases of JDK 8 Updates didn't always send the Server Name Indication (SNI) extension in the TLS ClientHello phase if a custom hostname verifier was used. This verifier is set via the setHostnameVerifier(HostnameVerifier v) method in HttpsURLConnection. The fix ensures the Server Name is now sent in the ClientHello body

I'm told that the database server I'm connecting to has something wonky with the certificate such that the name doesn't match or is missing.  I also note that the "advanced" tab on the "Data Sources and Drivers" properties dialog has a field for "sslhostnameverifier".  Based on experience with the sslfactory, I assume that I need to put a classname there.  I can write that Java class, but I don't know where to put it or how to get IntelliJ to load it.  Suggestions?


Please sign in to leave a comment.