From 56d0e7adfebba0edb36dabf207b15dbcd798d89f Mon Sep 17 00:00:00 2001 From: mguessan Date: Wed, 1 Sep 2010 20:15:55 +0000 Subject: [PATCH] workaround for TLS Renegotiation issue, see http://java.sun.com/javase/javaseforbusiness/docs/TLSReadme.html git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1409 3d1905a2-6b24-0410-a738-b14d5a86fcbd --- .../http/DavGatewayHttpClientFacade.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/java/davmail/http/DavGatewayHttpClientFacade.java b/src/java/davmail/http/DavGatewayHttpClientFacade.java index 6c4b1dca..ea79ab84 100644 --- a/src/java/davmail/http/DavGatewayHttpClientFacade.java +++ b/src/java/davmail/http/DavGatewayHttpClientFacade.java @@ -66,11 +66,12 @@ public final class DavGatewayHttpClientFacade { private static IdleConnectionTimeoutThread httpConnectionManagerThread; static { - DavGatewayHttpClientFacade.start(); - } + // workaround for TLS Renegotiation issue see http://java.sun.com/javase/javaseforbusiness/docs/TLSReadme.html + System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true"); - // register custom cookie policy - static { + DavGatewayHttpClientFacade.start(); + + // register custom cookie policy CookiePolicy.registerCookieSpec("DavMailCookieSpec", DavMailCookieSpec.class); } @@ -321,8 +322,6 @@ public final class DavGatewayHttpClientFacade { addNTLM(httpClient); status = httpClient.executeMethod(method); } - } catch (IOException e) { - throw e; } finally { method.releaseConnection(); } @@ -486,11 +485,11 @@ public final class DavGatewayHttpClientFacade { NTCredentials credentials = (NTCredentials) httpClient.getState().getCredentials(authScope); String userName = credentials.getUserName(); int backSlashIndex = userName.indexOf('\\'); - if (backSlashIndex >=0) { + if (backSlashIndex >= 0) { String domain = userName.substring(0, backSlashIndex); - userName = userName.substring(backSlashIndex+1); + userName = userName.substring(backSlashIndex + 1); credentials = new NTCredentials(userName, credentials.getPassword(), "", domain); - httpClient.getState().setCredentials(authScope, credentials); + httpClient.getState().setCredentials(authScope, credentials); } // make sure NTLM is always active