From 7cdd9ee0422f89d315c430730e68c745f833d920 Mon Sep 17 00:00:00 2001 From: kohsuke Date: Wed, 22 Jul 2009 00:47:47 +0000 Subject: [PATCH] improved error diagnosis. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@20043 71c3de6d-444a-0410-be80-ed276b4c234a --- .../src/main/java/hudson/model/UpdateCenter.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/hudson/model/UpdateCenter.java b/core/src/main/java/hudson/model/UpdateCenter.java index cb04807a93..cce3b14479 100644 --- a/core/src/main/java/hudson/model/UpdateCenter.java +++ b/core/src/main/java/hudson/model/UpdateCenter.java @@ -40,11 +40,13 @@ import net.sf.json.JSONObject; import org.acegisecurity.Authentication; import org.apache.commons.io.input.CountingInputStream; import org.apache.commons.io.IOUtils; +import org.apache.commons.io.output.NullOutputStream; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerResponse; import javax.servlet.ServletException; +import javax.net.ssl.SSLHandshakeException; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -69,6 +71,8 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.logging.Level; import java.util.logging.Logger; +import sun.security.validator.ValidatorException; + /** * Controls update center capability. * @@ -637,9 +641,15 @@ public class UpdateCenter extends AbstractModelObject { private void testConnection(URL url) throws IOException { - InputStream in = ProxyConfiguration.open(url).getInputStream(); - IOUtils.copy(in,new ByteArrayOutputStream()); - in.close(); + try { + InputStream in = ProxyConfiguration.open(url).getInputStream(); + IOUtils.copy(in,new NullOutputStream()); + in.close(); + } catch (SSLHandshakeException e) { + if (e.getMessage().contains("PKIX path building failed")) + // fix up this crappy error message from JDK + throw new IOException2("Failed to validate the SSL certificate of "+url,e); + } } } -- GitLab