List of usage examples for io.netty.handler.ssl OpenSsl isAvailable
public static boolean isAvailable()
From source file:blazingcache.network.netty.NetworkUtils.java
License:Apache License
public static boolean isOpenSslAvailable() { if (openSslAvailable != null) { return openSslAvailable; }//from w w w . j a va2 s. c o m if (ENABLE_OPENSSL && OpenSsl.isAvailable()) { OpenSsl.ensureAvailability(); openSslAvailable = true; } else { Throwable cause = OpenSsl.unavailabilityCause(); LOG.log(Level.INFO, "Native OpenSSL support is not available on this platform: " + cause); openSslAvailable = false; } return openSslAvailable; }
From source file:co.elastic.tealess.cli.EnvironmentCommand.java
License:Apache License
private void showNettyDetails() { if (OpenSsl.isAvailable()) { System.out.printf("Netty OpenSSL support is available.\n"); } else {/*ww w . j a va 2 s .co m*/ Throwable e = OpenSsl.unavailabilityCause(); System.out.printf("Netty's OpenSSL layer could not be loaded: %s\n", e.getMessage()); } System.out.println("Netty details:"); Map<String, Version> nettyComponents = Version.identify(); Version.identify().forEach((k, v) -> { if (k.contains("tcnative")) { System.out.printf(" %s\n", v); } }); }
From source file:com.caricah.iotracah.server.netty.SSLHandler.java
License:Apache License
public SslContext getSslContext() throws UnRetriableException { try {//w w w .j a v a2 s.c om File certificateChainFile = getCertificateChainFile(); File certificateKeyFile = getCertificateKeyFile(); String keyPassword = getKeyPassword(); SslProvider sslProvider; if (OpenSsl.isAvailable()) { sslProvider = SslProvider.OPENSSL; } else { sslProvider = SslProvider.JDK; } return SslContext.newServerContext(sslProvider, certificateChainFile, certificateKeyFile, keyPassword); } catch (Exception e) { log.error(" getSSLEngine : problems when trying to initiate secure protocals", e); throw new UnRetriableException(e); } }
From source file:com.floragunn.searchguard.SGTests.java
License:Apache License
@Test public void testEnsureOpenSSLAvailability() { if (allowOpenSSL) { Assert.assertTrue(String.valueOf(OpenSsl.unavailabilityCause()), OpenSsl.isAvailable()); } }
From source file:com.floragunn.searchguard.ssl.DefaultSearchGuardKeyStore.java
License:Apache License
private void logOpenSSLInfos() { if (OpenSsl.isAvailable()) { log.info("Open SSL " + OpenSsl.versionString() + " available"); log.debug("Open SSL available ciphers " + OpenSsl.availableCipherSuites()); } else {//ww w . j a v a 2 s . co m log.info( "Open SSL not available (this is not an error, we simply fallback to built-in JDK SSL) because of " + OpenSsl.unavailabilityCause()); } }
From source file:com.floragunn.searchguard.ssl.DefaultSearchGuardKeyStore.java
License:Apache License
private void initEnabledSSLCiphers() { List<String> secureSSLCiphers = SSLConfigConstants.getSecureSSLCiphers(settings, true); if (OpenSsl.isAvailable()) { final Set<String> openSSLSecureCiphers = new HashSet<>(); for (final String secure : secureSSLCiphers) { if (OpenSsl.isCipherSuiteAvailable(secure)) { openSSLSecureCiphers.add(secure); }/* ww w.ja va 2s . co m*/ } enabledHttpCiphersOpenSSLProvider = Collections .unmodifiableList(new ArrayList<String>(openSSLSecureCiphers)); } else { enabledHttpCiphersOpenSSLProvider = Collections.emptyList(); } SSLEngine engine = null; try { final SSLContext serverContext = SSLContext.getInstance("TLS"); serverContext.init(null, null, null); engine = serverContext.createSSLEngine(); final List<String> jdkSupportedCiphers = new ArrayList<>( Arrays.asList(engine.getSupportedCipherSuites())); log.info("JVM supports the following {} ciphers for https {}", jdkSupportedCiphers.size(), jdkSupportedCiphers); jdkSupportedCiphers.retainAll(secureSSLCiphers); engine.setEnabledCipherSuites(jdkSupportedCiphers.toArray(new String[0])); enabledHttpCiphersJDKProvider = Collections .unmodifiableList(Arrays.asList(engine.getEnabledCipherSuites())); } catch (final Throwable e) { log.error("Unable to determine supported ciphers due to " + ExceptionsHelper.stackTrace(e)); enabledHttpCiphersJDKProvider = secureSSLCiphers; } finally { if (engine != null) { try { engine.closeInbound(); } catch (SSLException e) { // TODO Auto-generated catch block e.printStackTrace(); } engine.closeOutbound(); } } secureSSLCiphers = SSLConfigConstants.getSecureSSLCiphers(settings, false); if (OpenSsl.isAvailable()) { final Set<String> openSSLSecureCiphers = new HashSet<>(); for (final String secure : secureSSLCiphers) { if (OpenSsl.isCipherSuiteAvailable(secure)) { openSSLSecureCiphers.add(secure); } } enabledTransportCiphersOpenSSLProvider = Collections .unmodifiableList(new ArrayList<String>(openSSLSecureCiphers)); } else { enabledTransportCiphersOpenSSLProvider = Collections.emptyList(); } try { final SSLContext serverContext = SSLContext.getInstance("TLS"); serverContext.init(null, null, null); engine = serverContext.createSSLEngine(); final List<String> jdkSupportedCiphers = new ArrayList<>( Arrays.asList(engine.getSupportedCipherSuites())); log.info("JVM supports the following {} ciphers for transport {}", jdkSupportedCiphers.size(), jdkSupportedCiphers); jdkSupportedCiphers.retainAll(secureSSLCiphers); engine.setEnabledCipherSuites(jdkSupportedCiphers.toArray(new String[0])); enabledTransportCiphersJDKProvider = Collections .unmodifiableList(Arrays.asList(engine.getEnabledCipherSuites())); } catch (final Throwable e) { log.error("Unable to determine supported ciphers due to " + ExceptionsHelper.stackTrace(e)); enabledTransportCiphersJDKProvider = secureSSLCiphers; } finally { if (engine != null) { try { engine.closeInbound(); } catch (SSLException e) { // TODO Auto-generated catch block e.printStackTrace(); } engine.closeOutbound(); } } }
From source file:com.floragunn.searchguard.ssl.OpenSSLTest.java
License:Apache License
@Test public void testEnsureOpenSSLAvailability() { Assert.assertTrue("OpenSSL not available: " + String.valueOf(OpenSsl.unavailabilityCause()), OpenSsl.isAvailable()); /*String allowOpenSSLProperty = System.getenv("SG_ALLOW_OPENSSL"); System.out.println("SG_ALLOW_OPENSSL "+allowOpenSSLProperty); if(Boolean.parseBoolean(allowOpenSSLProperty)) { System.out.println("OpenSSL must be available"); Assert.assertTrue(String.valueOf(OpenSsl.unavailabilityCause()), OpenSsl.isAvailable()); } else {/*www . j av a 2s . c o m*/ System.out.println("OpenSSL can be available"); }*/ }
From source file:com.floragunn.searchguard.ssl.OpenSSLTest.java
License:Apache License
@Override @Test public void testHttps() throws Exception { Assume.assumeTrue(OpenSsl.isAvailable()); super.testHttps(); }
From source file:com.floragunn.searchguard.ssl.OpenSSLTest.java
License:Apache License
@Override @Test public void testHttpsAndNodeSSL() throws Exception { Assume.assumeTrue(OpenSsl.isAvailable()); super.testHttpsAndNodeSSL(); }
From source file:com.floragunn.searchguard.ssl.OpenSSLTest.java
License:Apache License
@Override @Test public void testHttpPlainFail() throws Exception { Assume.assumeTrue(OpenSsl.isAvailable()); super.testHttpPlainFail(); }