private void testConnection(URL url) throws IOException { try { URLConnection connection = (URLConnection) ProxyConfiguration.open(url); if(connection instanceof HttpURLConnection) { int responseCode = ((HttpURLConnection)connection).getResponseCode(); if(HttpURLConnection.HTTP_OK != responseCode) { throw new HttpRetryException("Invalid response code (" + responseCode + ") from URL: " + url, responseCode); } } else { try (InputStream is = connection.getInputStream()) { IOUtils.copy(is, new NullOutputStream()); } } } catch (SSLHandshakeException e) { if (e.getMessage().contains("PKIX path building failed")) // fix up this crappy error message from JDK throw new IOException("Failed to validate the SSL certificate of "+url,e); } } }
} catch (SSLHandshakeException e){ request.reset(); throw new IOException("client connection handshake error for domain " + request.getURI().getHost() + ": " + e.getMessage()); } catch (Throwable e) { request.reset();
} catch (SSLHandshakeException e){ this.request.releaseConnection(); throw new IOException("client connection handshake error for domain " + this.request.getURI().getHost() + ": " + e.getMessage());
protected void handleSSLException(SSLHandshakeException e) { logger.error("SSL handshake error: " + e.getMessage()); }
/** * This intializes a new jersey restclient for http call with elasticenter */ public static ElastiCenterClient getElastistorRestClient() { ElastiCenterClient restclient = null; try { String ip = getConfigurationDao().getValue("cloudbyte.management.ip"); String apikey = getConfigurationDao().getValue("cloudbyte.management.apikey"); if (ip == null) { throw new CloudRuntimeException("set the value of cloudbyte.management.ip in global settings"); } if (apikey == null) { throw new CloudRuntimeException("set the value of cloudbyte.management.apikey in global settings"); } restclient = new ElastiCenterClient(ip, apikey); } catch (InvalidCredentialsException e) { throw new CloudRuntimeException("InvalidCredentialsException:" + e.getMessage(), e); } catch (InvalidParameterException e) { throw new CloudRuntimeException("InvalidParameterException:" + e.getMessage(), e); } catch (SSLHandshakeException e) { throw new CloudRuntimeException("SSLHandshakeException:" + e.getMessage(), e); } catch (ServiceUnavailableException e) { throw new CloudRuntimeException("ServiceUnavailableException:" + e.getMessage(), e); } return restclient; }
public SSLSocket connectSSL() { SSLSocket sslSocket1=null; if (sf == null) { try { sf = trustAllSocketFactory(); } catch (Exception e1) { e1.printStackTrace(); } } try { sslSocket1 = (SSLSocket) sf.createSocket(this.serveraddr, this.serverport); } catch (UnknownHostException e) { log.debug("Error with UnknownHostException {}",e.getMessage()); } catch (IOException e) { log.debug("Error with IOException {}",e.getMessage()); } try { sslSocket1.startHandshake(); } catch (SSLHandshakeException e) { log.debug("Error with SSLHandshakeException {}",e.getMessage()); } catch (IOException e) { log.debug("Error with IOException {}",e.getMessage()); } sslSocket=sslSocket1; return sslSocket; }
private void parseZip(ResourcesRepository repo, URI jar, File go) throws IOException, MalformedURLException, URISyntaxException, ZipException { String base = jar.toString() + "!/"; IO.copy(jar.toURL(), go); try (ZipFile zip = new ZipFile(go)) { for (ZipEntry entry : Iterables.iterable(zip.entries())) { String entryName = entry.getName(); if (entryName.endsWith(".jar")) { parse(repo, new URI(base + entryName)); } } } catch (javax.net.ssl.SSLHandshakeException e) { error("Failed to open URL due to ssl verification shit: %s %s", jar, e.getMessage()); } }
private void parseZip(ResourcesRepository repo, URI jar, File go) throws IOException, MalformedURLException, URISyntaxException, ZipException { String base = jar.toString() + "!/"; IO.copy(jar.toURL(), go); try (ZipFile zip = new ZipFile(go)) { for (ZipEntry entry : Iterables.iterable(zip.entries())) { String entryName = entry.getName(); if (entryName.endsWith(".jar")) { parse(repo, new URI(base + entryName)); } } } catch (javax.net.ssl.SSLHandshakeException e) { error("Failed to open URL due to ssl verification shit: %s %s", jar, e.getMessage()); } }
private void testConnection(URL url) throws IOException { try { URLConnection connection = (URLConnection) ProxyConfiguration.open(url); if(connection instanceof HttpURLConnection) { int responseCode = ((HttpURLConnection)connection).getResponseCode(); if(HttpURLConnection.HTTP_OK != responseCode) { throw new HttpRetryException("Invalid response code (" + responseCode + ") from URL: " + url, responseCode); } } else { try (InputStream is = connection.getInputStream()) { IOUtils.copy(is, new NullOutputStream()); } } } catch (SSLHandshakeException e) { if (e.getMessage().contains("PKIX path building failed")) // fix up this crappy error message from JDK throw new IOException("Failed to validate the SSL certificate of "+url,e); } } }
/** * Assign the certificate chain to this certificate. * @throws DVException Thrown on problems */ private void assignCertificateChain() throws DVException { try { chain = CipherSuiteUtil.getServerCertificateChain(eng.getDVSession().getURL()); } catch (SSLHandshakeException e ) { if( e.getMessage().indexOf("PKIX") > 0 ) { String msg = "Certificate chain failed validation. err=" + e.getMessage(); logger.error(msg,e); throw new DVException(msg,e); }else{ String msg = "SSLHandshakeException. err=" + e.getMessage(); logger.error(msg,e); throw new DVException(msg,e); } } catch (Exception e) { String msg = "Problem fetching certificates. err=" + e.getMessage(); logger.error(msg,e); throw new DVException(msg,e); } }
private void testConnection(URL url) throws IOException { try { Util.copyStreamAndClose(ProxyConfiguration.open(url).getInputStream(),new NullOutputStream()); } 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); } } }
private void testConnection(URL url) throws IOException { try { Util.copyStreamAndClose(ProxyConfiguration.open(url).getInputStream(), new NullOutputStream()); } catch (SSLHandshakeException e) { if (e.getMessage().contains("PKIX path building failed")) // fix up this illegible error message from JDK { throw new IOException2("Failed to validate the SSL certificate of " + url, e); } } } }
private void testConnection(URL url) throws IOException { try { Util.copyStreamAndClose(ProxyConfiguration.open(url).getInputStream(),new NullOutputStream()); } catch (SSLHandshakeException e) { if (e.getMessage().contains("PKIX path building failed")) // fix up this illegible error message from JDK throw new IOException2("Failed to validate the SSL certificate of "+url,e); } } }
private void testConnection(URL url) throws IOException { try { Util.copyStreamAndClose(ProxyConfiguration.open(url).getInputStream(),new NullOutputStream()); } 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); } } }
@Override public NextAction handleRead(FilterChainContext ctx) throws IOException { try { ctx.getAttributes().setAttribute(HTTPS.getScheme(), true); NextAction nextAction = super.handleRead(ctx); ctx.getAttributes().setAttribute(SSL_SESSION_ATTRIBUTE_KEY, getSslSession(ctx)); return nextAction; } catch (SSLHandshakeException e) { logger.error("SSL handshake error: " + e.getMessage()); throw e; } }
private void parse(ResourcesRepository repo, URI jar) { if (!isInteresting(jar.getPath())) return; try { File go = client.build() .get() .useCache() .go(jar); if (jar.getPath() .endsWith(".jar")) { parseJar(repo, jar, go); } else { parseZip(repo, jar, go); } } catch (javax.net.ssl.SSLHandshakeException e) { error("Failed to open URL due to ssl verification shit: %s %s", jar, e.getMessage()); } catch (Exception e) { exception(e, "failed to parse file %s", jar); } }
private void parse(ResourcesRepository repo, URI jar) { if (!isInteresting(jar.getPath())) return; try { File go = client.build() .get() .useCache() .go(jar); if (jar.getPath() .endsWith(".jar")) { parseJar(repo, jar, go); } else { parseZip(repo, jar, go); } } catch (javax.net.ssl.SSLHandshakeException e) { error("Failed to open URL due to ssl verification shit: %s %s", jar, e.getMessage()); } catch (Exception e) { exception(e, "failed to parse file %s", jar); } }
/** * log me in with the configured user * * @throws Exception */ public void login() throws Exception { WikiUser wuser = WikiUser.getUser(getWikiid(), getSiteurl()); if (wuser == null) { throw new Exception( "user for " + getWikiid() + "(" + getSiteurl() + ") not configured"); } // wiki.setDebug(true); try { Login login = login(wuser.getUsername(), wuser.getPassword()); LOGGER.log(Level.INFO, this.siteurl + this.scriptPath + this.apiPath + ":" + login.getResult()); if (!"Success".equals(login.getResult())) { throw new Exception("login for '" + wuser.getUsername() + "' at '" + getWikiid() + "(" + this.getSiteurl() + this.getScriptPath() + ")' failed: " + login.getResult()); } } catch (javax.net.ssl.SSLHandshakeException she) { String msg = "login via SSL to " + this.getSiteurl() + " failed\n"; msg += "Exception: " + she.getMessage(); throw new Exception(msg); } }
protected TransmissionResponse sendHttpRequest(HttpPost httpPost) throws OxalisTransmissionException { Span span = tracer.buildSpan("execute").asChildOf(root).start(); try (CloseableHttpClient httpClient = httpClientProvider.get()) { BasicHttpContext basicHttpContext = new BasicHttpContext(); basicHttpContext.setAttribute(Constants.PARENT_CONTEXT, span.context()); CloseableHttpResponse response = httpClient.execute(httpPost, basicHttpContext); span.finish(); return handleResponse(response); } catch (HttpHostConnectException e) { span.setTag("exception", e.getMessage()); throw new OxalisTransmissionException("Receiving server does not seem to be running.", transmissionRequest.getEndpoint().getAddress(), e); } catch (SSLHandshakeException e) { span.setTag("exception", e.getMessage()); throw new OxalisTransmissionException("Possible invalid SSL Certificate at the other end.", transmissionRequest.getEndpoint().getAddress(), e); } catch (IOException e) { span.setTag("exception", String.valueOf(e.getMessage())); throw new OxalisTransmissionException(transmissionRequest.getEndpoint().getAddress(), e); } finally { span.finish(); } }
protected TransmissionResponse sendHttpRequest(HttpPost httpPost) throws OxalisTransmissionException { Span span = tracer.buildSpan("execute").asChildOf(root).start(); try (CloseableHttpClient httpClient = httpClientProvider.get()) { BasicHttpContext basicHttpContext = new BasicHttpContext(); basicHttpContext.setAttribute(Constants.PARENT_CONTEXT, span.context()); CloseableHttpResponse response = httpClient.execute(httpPost, basicHttpContext); span.finish(); return handleResponse(response); } catch (SocketTimeoutException e) { span.setTag("exception", String.valueOf(e.getMessage())); throw new OxalisTransmissionException("Receiving server has not sent anything back within SOCKET_TIMEOUT", transmissionRequest.getEndpoint().getAddress(), e); } catch (HttpHostConnectException e) { span.setTag("exception", e.getMessage()); throw new OxalisTransmissionException("Receiving server does not seem to be running.", transmissionRequest.getEndpoint().getAddress(), e); } catch (SSLHandshakeException e) { span.setTag("exception", e.getMessage()); throw new OxalisTransmissionException("Possible invalid SSL Certificate at the other end.", transmissionRequest.getEndpoint().getAddress(), e); } catch (IOException e) { span.setTag("exception", String.valueOf(e.getMessage())); throw new OxalisTransmissionException(transmissionRequest.getEndpoint().getAddress(), e); } finally { span.finish(); } }