cloudant / java-cloudant

A Java client for Cloudant
Apache License 2.0
79 stars 68 forks source link

get SSLException error when trying to connect cloudant db #496

Closed congmingdexiong closed 5 years ago

congmingdexiong commented 5 years ago

The problem appears when code in linux server trying to touch cloudant db service located in IBM bluemix env, got below error: " Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is com.cloudant.client.org.lightcouch.CouchDbException: Error retrieving server response at https://xxxxxxxxxxxxxxxxxxxxx-bluemix.cloudant.com:443/server/_find.] with root cause

javax.net.ssl.SSLException: Received fatal alert: protocol_version "

Code worked fine on my local, issues only found in bluecloud server

Below is the code I used: " CloudantClient client =ClientBuilder.url(new URL(cloundantUrl)) .username(username) .password(password) .build();

    Database db = client.database("server", false);

"

rnewson commented 5 years ago

Cloudant requires TLS 1.2 or higher so it sounds like your version of Java is too low.

ricellis commented 5 years ago

As stated Cloudant requires TLSv1.2 or higher, the TLS versions available to java-cloudant are determined by the SSLSocketFactory, if you have not customized that then it will be the default socket factory provided to https protocol connections by the Java runtime. If your Java default socket factory is not providing TLSv1.2 to client https connections then you either need to configure it to do so or change to a different Java runtime.

Note that we are unable to provide support for configuring your runtime environment, but here is some information we've gathered on this topic previously that may be helpful to you:

For Java 8:

For Java 7: