@Override public boolean isStarted() { SSLStarter sslfactory = getLevel().find(SSLStarter.class); // if no sslfactory, don't check if it's started return client != null && (sslfactory != null ? sslfactory.isStarted() : true); } }
private Socket connect() throws NoSuchAlgorithmException, KeyManagementException, IOException { if(port == 23) { SocketFactory ss = find(SocketFactory.class); return ss.createSocket(iloHost, port); } else { return find(SSLStarter.class).connect(iloHost, port); } }
public Socket connect(String host, int port) throws NoSuchAlgorithmException, KeyManagementException, IOException { SocketFactory ss = getLevel().find(SocketFactory.class); Socket s = ss.createSocket(host, port); SSLSocketFactory ssf = getContext().getSocketFactory(); s = ssf.createSocket(s, host, port, true); log(Level.DEBUG, "done SSL handshake for %s", host); return s; }
@Test public void testConnectSSL() throws Exception { MockHttpServer server = new MockHttpServer(true); server.addResourceHandler(staticFiles); server.start(); HttpClientStarter cnx = new HttpClientStarter(); HostStarter localhost = addConnection(cnx); localhost.find(Resolver.class).doStart(); localhost.find(SSLStarter.class).doStart(); cnx.doStart(); TestHttpProbe p = new TestHttpProbe(); p.setMainStore(new RrdDbStoreFactory(), empty); p.setHost(localhost); p.setPort(server.getURI().toURL().getPort()); p.setScheme("https"); p.configure(); p.checkStore(); localhost.addProbe(p); localhost.getParent().startCollect(); Assert.assertTrue(p.find(SSLStarter.class).isStarted()); shouldFail = false; localhost.collectAll(); Assert.assertTrue("Didn't try to collect", p.collected); server.stop(); }
private SSLConnectionSocketFactory getSSLSocketFactory() { SSLStarter sslstarter = getLevel().find(SSLStarter.class); if (sslstarter == null) { return null; } else { SSLContext sc = sslstarter.getContext(); return new SSLConnectionSocketFactory(sc); } }
private HostStarter addConnection(Starter cnx) throws IOException { String truststore = getClass().getClassLoader().getResource("localhost.jks").getFile(); PropertiesManager pm = Tools.makePm(testFolder, "timeout=1", "collectorThreads=1", "ssl.protocol=TLS", "ssl.strict=true", "ssl.truststore=" + truststore, "ssl.trustpassword=123456"); HostStarter localhost = new HostStarter(new HostInfo("localhost")); Timer t = Tools.getDefaultTimer(); localhost.setParent(t); localhost.getHost().setHostDir(testFolder.getRoot()); t.registerStarter(new SSLStarter()); t.registerStarter(new SocketFactory()); t.configureStarters(pm); localhost.registerStarter(cnx); cnx.configure(pm); return localhost; }
@Test public void testStart() throws Exception { MockHttpServer server = new MockHttpServer(false); server.addResourceHandler(staticFiles); server.start(); HttpClientStarter cnx = new HttpClientStarter(); HostStarter localhost = addConnection(cnx); localhost.find(SSLStarter.class).doStart(); localhost.find(Resolver.class).doStart(); logger.debug("resolver started for localhost:" + localhost.find(Resolver.class).isStarted()); cnx.doStart(); Assert.assertTrue("Apache HttpClient failed to start", cnx.isStarted()); cnx.stop(); server.stop(); }