5252import okhttp3 .Request .Builder ;
5353import okhttp3 .Response ;
5454
55+ import javax .net .ssl .SSLHandshakeException ;
56+
5557/**
5658 * Abstracts common functionality of various IBM Cloud services.
5759 */
@@ -62,6 +64,10 @@ public abstract class BaseService {
6264 private static final Logger LOG = Logger .getLogger (BaseService .class .getName ());
6365
6466 private static final String ERRORMSG_NO_AUTHENTICATOR = "Authentication information was not properly configured." ;
67+ private static final String ERRORMSG_SSL = "If you're trying to call a service on ICP or Cloud Pak for Data, you "
68+ + "may not have a valid SSL certificate. If you need to access the service without setting that up, try using "
69+ + "the disableSsl option in your authentication configuration and/or the disableSslVerification option in the "
70+ + "HttpConfigOptions." ;
6571
6672 private String serviceUrl ;
6773 private final String name ;
@@ -407,6 +413,9 @@ public com.ibm.cloud.sdk.core.http.Response<T> execute() {
407413 T responseModel = processServiceCall (converter , response );
408414 return new com .ibm .cloud .sdk .core .http .Response <>(responseModel , response );
409415 } catch (IOException e ) {
416+ if (e instanceof SSLHandshakeException ) {
417+ LOG .warning (ERRORMSG_SSL );
418+ }
410419 throw new RuntimeException (e );
411420 }
412421 }
@@ -416,6 +425,9 @@ public void enqueue(final ServiceCallback<T> callback) {
416425 call .enqueue (new Callback () {
417426 @ Override
418427 public void onFailure (Call call , IOException e ) {
428+ if (e instanceof SSLHandshakeException ) {
429+ LOG .warning (ERRORMSG_SSL );
430+ }
419431 callback .onFailure (e );
420432 }
421433
@@ -435,10 +447,17 @@ public void onResponse(Call call, Response response) {
435447 public Single <com .ibm .cloud .sdk .core .http .Response <T >> reactiveRequest () {
436448 return Single .fromCallable (new Callable <com .ibm .cloud .sdk .core .http .Response <T >>() {
437449 @ Override
438- public com .ibm .cloud .sdk .core .http .Response <T > call () throws Exception {
439- Response response = call .execute ();
440- T responseModel = processServiceCall (converter , response );
441- return new com .ibm .cloud .sdk .core .http .Response <>(responseModel , response );
450+ public com .ibm .cloud .sdk .core .http .Response <T > call () {
451+ try {
452+ Response response = call .execute ();
453+ T responseModel = processServiceCall (converter , response );
454+ return new com .ibm .cloud .sdk .core .http .Response <>(responseModel , response );
455+ } catch (IOException e ) {
456+ if (e instanceof SSLHandshakeException ) {
457+ LOG .warning (ERRORMSG_SSL );
458+ }
459+ throw new RuntimeException (e );
460+ }
442461 }
443462 });
444463 }
0 commit comments