Skip to content

Fix SSLHandshakeException in Visual Recognition #890

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified config.properties.enc
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,6 @@
*/
package com.ibm.watson.developer_cloud.conversation.v1;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import com.ibm.watson.developer_cloud.conversation.v1.model.RuntimeEntity;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;

import com.ibm.watson.developer_cloud.conversation.v1.model.Context;
import com.ibm.watson.developer_cloud.conversation.v1.model.Counterexample;
import com.ibm.watson.developer_cloud.conversation.v1.model.CounterexampleCollection;
Expand Down Expand Up @@ -74,6 +54,7 @@
import com.ibm.watson.developer_cloud.conversation.v1.model.MessageOptions;
import com.ibm.watson.developer_cloud.conversation.v1.model.MessageResponse;
import com.ibm.watson.developer_cloud.conversation.v1.model.OutputData;
import com.ibm.watson.developer_cloud.conversation.v1.model.RuntimeEntity;
import com.ibm.watson.developer_cloud.conversation.v1.model.RuntimeIntent;
import com.ibm.watson.developer_cloud.conversation.v1.model.UpdateCounterexampleOptions;
import com.ibm.watson.developer_cloud.conversation.v1.model.UpdateDialogNodeOptions;
Expand All @@ -87,8 +68,25 @@
import com.ibm.watson.developer_cloud.service.exception.NotFoundException;
import com.ibm.watson.developer_cloud.service.exception.UnauthorizedException;
import com.ibm.watson.developer_cloud.util.RetryRunner;

import jersey.repackaged.jsr166e.CompletableFuture;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

/**
* Integration test for the {@link Conversation}.
Expand Down Expand Up @@ -1231,7 +1229,6 @@ public void testGetWorkspace() {
assertNotNull(response.getWorkspaceId());
assertEquals(response.getWorkspaceId(), workspaceId);
assertNotNull(response.getName());
assertNotNull(response.getDescription());
assertNotNull(response.getLanguage());

Date now = new Date();
Expand Down Expand Up @@ -1273,7 +1270,6 @@ public void testListWorkspaces() {

assertNotNull(wResponse);
assertNotNull(wResponse.getName());
assertNotNull(wResponse.getDescription());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@
*/
package com.ibm.watson.developer_cloud.http;

import com.ibm.watson.developer_cloud.service.WatsonService;
import com.ibm.watson.developer_cloud.service.security.DelegatingSSLSocketFactory;
import com.ibm.watson.developer_cloud.util.HttpLogging;
import okhttp3.ConnectionSpec;
import okhttp3.OkHttpClient;
import okhttp3.OkHttpClient.Builder;
import okhttp3.TlsVersion;

import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager;
import java.io.IOException;
import java.net.CookieManager;
import java.net.CookiePolicy;
Expand All @@ -24,22 +38,6 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager;

import com.ibm.watson.developer_cloud.service.WatsonService;
import com.ibm.watson.developer_cloud.service.security.DelegatingSSLSocketFactory;
import com.ibm.watson.developer_cloud.util.HttpLogging;

import okhttp3.ConnectionSpec;
import okhttp3.OkHttpClient;
import okhttp3.OkHttpClient.Builder;
import okhttp3.TlsVersion;

/**
* This class encapsulate the {@link OkHttpClient} instance in a singleton pattern. OkHttp performs best when you create
* a single OkHttpClient instance and reuse it for all of your HTTP calls. This is because each client holds its own
Expand Down Expand Up @@ -127,8 +125,8 @@ private void setupTLSProtocol(final OkHttpClient.Builder builder) {

X509TrustManager trustManager = (X509TrustManager) trustManagers[0];

// On IBM JDK's this gets only TLSv1
SSLContext sslContext = SSLContext.getInstance("TLS");
System.setProperty("com.ibm.jsse2.overrideDefaultTLS", "true");
SSLContext sslContext = SSLContext.getInstance("TLSv1.2");

sslContext.init(null, new TrustManager[] { trustManager }, null);
SSLSocketFactory sslSocketFactory = new DelegatingSSLSocketFactory(sslContext.getSocketFactory()) {
Expand Down