1

I'm trying to access Google Maps from my Java code as follows:

GeoApiContext context = new GeoApiContext.Builder().apiKey("API_KEY_HERE").build();
//Setting variables...
DistanceMatrix matrix = DistanceMatrixApi.newRequest(context).origins(origins).destinations(destinations).await();

Calling await() throws an exception:

java.net.UnknownServiceException: Unable to find acceptable protocols. isFallback=false, modes=[ConnectionSpec(cipherSuites=[TLS_AES_128_GCM_SHA256, TLS_AES_256_GCM_SHA384, TLS_CHACHA20_POLY1305_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256, TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA], tlsVersions=[TLS_1_3, TLS_1_2], supportsTlsExtensions=true), ConnectionSpec()], supported protocols=[TLSv1]

I gather this is coming from the OkHttp library used by Google Maps and that it has something to do with the TLS version, but I have no idea what to do to address it. All of the test cases in the source code use a mock web server and there are no examples of specifying a real server, leading me to believe that it was done under the hood.

Does anyone have example code for using the Google Maps Java API with a real web server?

2
  • Which Java version are you using? Commented Dec 8, 2019 at 10:17
  • My JVM (from System.getProperty("java.version")) is 1.8.0_221. Commented Dec 8, 2019 at 13:46

2 Answers 2

2

Your JVM isn't configured to use a new-enough version of TLS.

supported protocols=[TLSv1]

Make sure your JVM is 8 or newer and up-to-date. Also make sure any custom security providers (bouncycastle) are up to date.

Sign up to request clarification or add additional context in comments.

5 Comments

My JVM (from System.getProperty("java.version")) is 1.8.0_221. I have not been able to find anything that might be overriding this. jdk.tls.client.protocols is null, which I understand should default Java 8 to TLS 1.2. Is there another way to check what's affecting the choice of TLS versions?
Does it connect okay in a test case, or a main method with no other libraries? Looks like something is changing defaults on you.
I"ve confirmed that the minimal example works in a new project in the same Eclipse workspace.
(The exact same code fails with the TLS error in the existing project.)
Furthermore, if I manually create an SSLSocket and call getEnabledProtocols(), I see TLS 1, 1.1, and 1.2. Something is affecting specifically the protocols visible to the Google Maps code.
0

This error is might be because of the version of okhttp3 library try to use different version of okhttp3.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.