io.netty.handler.ssl.OpenSsl类的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(11.0k)|赞(0)|评价(0)|浏览(484)

本文整理了Java中io.netty.handler.ssl.OpenSsl类的一些代码示例,展示了OpenSsl类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OpenSsl类的具体详情如下:
包路径:io.netty.handler.ssl.OpenSsl
类名称:OpenSsl

OpenSsl介绍

[英]Tells if netty-tcnative and its OpenSSL support are available.
[中]告知{$0$}及其OpenSSL支持是否可用。

代码示例

代码示例来源:origin: eclipse-vertx/vert.x

  1. /**
  2. * @return when OpenSSL is available
  3. */
  4. public static boolean isAvailable() {
  5. return OpenSsl.isAvailable();
  6. }

代码示例来源:origin: Netflix/zuul

  1. public static SslProvider chooseSslProvider() {
  2. // Use openssl only if available and has ALPN support (ie. version > 1.0.2).
  3. SslProvider sslProvider;
  4. if (ALLOW_USE_OPENSSL.get() && OpenSsl.isAvailable() && OpenSsl.isAlpnSupported()) {
  5. sslProvider = SslProvider.OPENSSL;
  6. }
  7. else {
  8. sslProvider = SslProvider.JDK;
  9. }
  10. return sslProvider;
  11. }

代码示例来源:origin: floragunncom/search-guard

  1. @Test
  2. public void testEnsureOpenSSLAvailability() {
  3. Assume.assumeTrue(allowOpenSSL);
  4. Assert.assertTrue(String.valueOf(OpenSsl.unavailabilityCause()), OpenSsl.isAvailable());
  5. }

代码示例来源:origin: googleapis/google-cloud-java

  1. boolean openSslIsAvailable = OpenSsl.isAvailable();
  2. boolean openSslAlpnIsSupported = OpenSsl.isAlpnSupported();
  3. String javaVersion = Runtime.class.getPackage().getImplementationVersion();
  4. String javaSpecificationVersion = System.getProperty("java.specification.version");
  5. } else {
  6. System.out.println(" [FAIL] Open SSL is NOT available");
  7. if (OpenSsl.unavailabilityCause() != null) {
  8. System.out.println(" Open SSL Unavailability cause:");
  9. OpenSsl.unavailabilityCause().printStackTrace(System.out);

代码示例来源:origin: org.apache.qpid/qpid-jms-client

  1. /**
  2. * Determines if Netty OpenSSL support is available and applicable based on the configuration
  3. * in the given TransportOptions instance.
  4. *
  5. * @param options
  6. * The configuration of the Transport being created.
  7. *
  8. * @return true if OpenSSL support is available and usable given the requested configuration.
  9. */
  10. public static boolean isOpenSSLPossible(TransportOptions options) {
  11. boolean result = false;
  12. if (options.isUseOpenSSL()) {
  13. if (!OpenSsl.isAvailable()) {
  14. LOG.debug("OpenSSL could not be enabled because a suitable implementation could not be found.", OpenSsl.unavailabilityCause());
  15. } else if (options.getSslContextOverride() != null) {
  16. LOG.debug("OpenSSL could not be enabled due to user SSLContext being supplied.");
  17. } else if (!OpenSsl.supportsKeyManagerFactory()) {
  18. LOG.debug("OpenSSL could not be enabled because the version provided does not allow a KeyManagerFactory to be used.");
  19. } else if (options.isVerifyHost() && !OpenSsl.supportsHostnameValidation()) {
  20. LOG.debug("OpenSSL could not be enabled due to verifyHost being enabled but not supported by the provided OpenSSL version.");
  21. } else if (options.getKeyAlias() != null) {
  22. LOG.debug("OpenSSL could not be enabled because a keyAlias is set and that feature is not supported for OpenSSL.");
  23. } else {
  24. LOG.debug("OpenSSL Enabled: Version {} of OpenSSL will be used", OpenSsl.versionString());
  25. result = true;
  26. }
  27. }
  28. return result;
  29. }

代码示例来源:origin: wildfly/wildfly

  1. @Override
  2. public final void setEnabledCipherSuites(String[] cipherSuites) {
  3. checkNotNull(cipherSuites, "cipherSuites");
  4. if (!OpenSsl.isCipherSuiteAvailable(converted)) {
  5. throw new IllegalArgumentException("unsupported cipher suite: " + c + '(' + converted + ')');

代码示例来源:origin: floragunncom/search-guard-ssl

  1. final List<String> secureTransportSSLProtocols = Arrays.asList(SSLConfigConstants.getSecureSSLProtocols(settings, false));
  2. if (OpenSsl.isAvailable()) {
  3. final Set<String> openSSLSecureHttpCiphers = new HashSet<>();
  4. for (final String secure : secureHttpSSLCiphers) {
  5. if (OpenSsl.isCipherSuiteAvailable(secure)) {
  6. openSSLSecureHttpCiphers.add(secure);
  7. log.debug("OPENSSL "+OpenSsl.versionString()+" supports the following ciphers (java-style) {}", OpenSsl.availableJavaCipherSuites());
  8. log.debug("OPENSSL "+OpenSsl.versionString()+" supports the following ciphers (openssl-style) {}", OpenSsl.availableOpenSslCipherSuites());
  9. if (OpenSsl.isAvailable()) {
  10. final Set<String> openSSLSecureTransportCiphers = new HashSet<>();
  11. for (final String secure : secureTransportSSLCiphers) {
  12. if (OpenSsl.isCipherSuiteAvailable(secure)) {
  13. openSSLSecureTransportCiphers.add(secure);
  14. if(OpenSsl.isAvailable() && OpenSsl.version() > 0x10101009L) {
  15. enabledHttpProtocolsOpenSSLProvider = new ArrayList(Arrays.asList("TLSv1.3","TLSv1.2","TLSv1.1"));
  16. enabledHttpProtocolsOpenSSLProvider.retainAll(secureHttpSSLProtocols);
  17. } else if(OpenSsl.isAvailable()){
  18. enabledHttpProtocolsOpenSSLProvider = new ArrayList(Arrays.asList("TLSv1.2","TLSv1.1"));
  19. enabledHttpProtocolsOpenSSLProvider.retainAll(secureHttpSSLProtocols);

代码示例来源:origin: floragunncom/search-guard-ssl

  1. private void logOpenSSLInfos() {
  2. if (OpenSsl.isAvailable()) {
  3. log.info("OpenSSL " + OpenSsl.versionString() + " (" + OpenSsl.version() + ") available");
  4. if (OpenSsl.version() < 0x10002000L) {
  5. log.warn(
  6. "Outdated OpenSSL version detected. You should update to 1.0.2k or later. Currently installed: "
  7. + OpenSsl.versionString());
  8. }
  9. if (!OpenSsl.supportsHostnameValidation()) {
  10. log.warn("Your OpenSSL version " + OpenSsl.versionString()
  11. + " does not support hostname verification. You should update to 1.0.2k or later.");
  12. }
  13. log.debug("OpenSSL available ciphers " + OpenSsl.availableOpenSslCipherSuites());
  14. } else {
  15. log.info("OpenSSL not available (this is not an error, we simply fallback to built-in JDK SSL) because of "
  16. + OpenSsl.unavailabilityCause());
  17. }
  18. }

代码示例来源:origin: eclipse/hono

  1. final boolean isOpenSslAvailable = OpenSsl.isAvailable();
  2. final boolean supportsKeyManagerFactory = OpenSsl.supportsKeyManagerFactory();
  3. final boolean useOpenSsl =
  4. getConfig().isNativeTlsRequired() || (isOpenSslAvailable && supportsKeyManagerFactory);
  5. OpenSsl.versionString());
  6. serverOptions.setSslEngineOptions(new OpenSSLEngineOptions());
  7. } else {

代码示例来源:origin: com.aliyun.angelia/angelia-remoting

  1. private void buildSslContext() {
  2. SslProvider provider = OpenSsl.isAvailable() ? SslProvider.OPENSSL : SslProvider.JDK;
  3. try {
  4. sslContext = SslContextBuilder.forClient()
  5. .sslProvider(provider)
  6. /* NOTE: the cipher filter may not include all ciphers required by the HTTP/2 specification.
  7. * Please refer to the HTTP/2 specification for cipher requirements. */
  8. .ciphers(Http2SecurityUtil.CIPHERS, SupportedCipherSuiteFilter.INSTANCE)
  9. .trustManager(InsecureTrustManagerFactory.INSTANCE)
  10. .build();
  11. } catch (SSLException e) {
  12. e.printStackTrace();
  13. }
  14. }

代码示例来源:origin: eclipse-vertx/vert.x

  1. /**
  2. * @return when alpn support is available via OpenSSL engine
  3. */
  4. public static boolean isAlpnAvailable() {
  5. return OpenSsl.isAlpnSupported();
  6. }

代码示例来源:origin: blynkkk/blynk-server

  1. static boolean isOpenSslAvailable() {
  2. return PlatformDependent.bitMode() != 32 && OpenSsl.isAvailable();
  3. }

代码示例来源:origin: org.infinispan/infinispan-server-rest

  1. @Test
  2. public void shouldUpgradeUsingALPN() throws Exception {
  3. SkipTestNG.skipSinceJDK(10); // TODO: OpenSSL ALPN doesn't seem to work. Restructure the test to use internal JDK ALPN
  4. if (!OpenSsl.isAlpnSupported()) {
  5. throw new IllegalStateException("OpenSSL is not present, can not test TLS/ALPN support. Version: " + OpenSsl.versionString() + " Cause: " + OpenSsl.unavailabilityCause());
  6. }
  7. //given
  8. restServer = RestServerHelper.defaultRestServer("http2testcache")
  9. .withKeyStore(KEY_STORE_PATH, "secret", "pkcs12")
  10. .start(TestResourceTracker.getCurrentTestShortName());
  11. client = NettyHttpClient.newHttp2ClientWithALPN(KEY_STORE_PATH, "secret");
  12. client.start(restServer.getHost(), restServer.getPort());
  13. FullHttpRequest putValueInCacheRequest = new DefaultFullHttpRequest(HTTP_1_1, POST, "/rest/http2testcache/test",
  14. wrappedBuffer("test".getBytes(CharsetUtil.UTF_8)));
  15. //when
  16. client.sendRequest(putValueInCacheRequest);
  17. Queue<FullHttpResponse> responses = client.getResponses();
  18. //then
  19. Assertions.assertThat(responses).hasSize(1);
  20. Assertions.assertThat(responses.element().status().code()).isEqualTo(200);
  21. Assertions.assertThat(restServer.getCacheManager().getCache("http2testcache").size()).isEqualTo(1);
  22. }

代码示例来源:origin: floragunncom/search-guard-ssl

  1. @Test
  2. public void testAvailCiphersOpenSSL() throws Exception {
  3. Assume.assumeTrue(OpenSsl.isAvailable());
  4. // Set<String> openSSLAvailCiphers = new
  5. // HashSet<>(OpenSsl.availableCipherSuites());
  6. // System.out.println("OpenSSL available ciphers: "+openSSLAvailCiphers);
  7. // ECDHE-RSA-AES256-SHA, ECDH-ECDSA-AES256-SHA, DH-DSS-DES-CBC-SHA,
  8. // ADH-AES256-SHA256, ADH-CAMELLIA128-SHA
  9. final Set<String> openSSLSecureCiphers = new HashSet<>();
  10. for (final String secure : SSLConfigConstants.getSecureSSLCiphers(Settings.EMPTY, false)) {
  11. if (OpenSsl.isCipherSuiteAvailable(secure)) {
  12. openSSLSecureCiphers.add(secure);
  13. }
  14. }
  15. System.out.println("OpenSSL secure ciphers: " + openSSLSecureCiphers);
  16. Assert.assertTrue(openSSLSecureCiphers.size() > 0);
  17. }

代码示例来源:origin: io.netty/netty-testsuite

  1. @Test(timeout = 30000)
  2. public void testSslRenegotiationRejected() throws Throwable {
  3. // BoringSSL does not support renegotiation intentionally.
  4. Assume.assumeFalse("BoringSSL".equals(OpenSsl.versionString()));
  5. Assume.assumeTrue(OpenSsl.isAvailable());
  6. run();
  7. }

代码示例来源:origin: floragunncom/search-guard-ssl

  1. @Override
  2. public Object run() {
  3. System.setProperty("es.set.netty.runtime.available.processors", "false");
  4. PlatformDependent.newFixedMpscQueue(1);
  5. OpenSsl.isAvailable();
  6. return null;
  7. }
  8. });

代码示例来源:origin: redisson/redisson

  1. /**
  2. * @deprecated use {@link #availableOpenSslCipherSuites()}
  3. */
  4. @Deprecated
  5. public static Set<String> availableCipherSuites() {
  6. return availableOpenSslCipherSuites();
  7. }

代码示例来源:origin: redisson/redisson

  1. if (!OpenSsl.isCipherSuiteAvailable(converted)) {
  2. throw new IllegalArgumentException("unsupported cipher suite: " + c + '(' + converted + ')');

代码示例来源:origin: apache/qpid-jms

  1. /**
  2. * Determines if Netty OpenSSL support is available and applicable based on the configuration
  3. * in the given TransportOptions instance.
  4. *
  5. * @param options
  6. * The configuration of the Transport being created.
  7. *
  8. * @return true if OpenSSL support is available and usable given the requested configuration.
  9. */
  10. public static boolean isOpenSSLPossible(TransportOptions options) {
  11. boolean result = false;
  12. if (options.isUseOpenSSL()) {
  13. if (!OpenSsl.isAvailable()) {
  14. LOG.debug("OpenSSL could not be enabled because a suitable implementation could not be found.", OpenSsl.unavailabilityCause());
  15. } else if (options.getSslContextOverride() != null) {
  16. LOG.debug("OpenSSL could not be enabled due to user SSLContext being supplied.");
  17. } else if (!OpenSsl.supportsKeyManagerFactory()) {
  18. LOG.debug("OpenSSL could not be enabled because the version provided does not allow a KeyManagerFactory to be used.");
  19. } else if (options.isVerifyHost() && !OpenSsl.supportsHostnameValidation()) {
  20. LOG.debug("OpenSSL could not be enabled due to verifyHost being enabled but not supported by the provided OpenSSL version.");
  21. } else if (options.getKeyAlias() != null) {
  22. LOG.debug("OpenSSL could not be enabled because a keyAlias is set and that feature is not supported for OpenSSL.");
  23. } else {
  24. LOG.debug("OpenSSL Enabled: Version {} of OpenSSL will be used", OpenSsl.versionString());
  25. result = true;
  26. }
  27. }
  28. return result;
  29. }

代码示例来源:origin: apache/activemq-artemis

  1. @Override
  2. public final void setEnabledCipherSuites(String[] cipherSuites) {
  3. checkNotNull(cipherSuites, "cipherSuites");
  4. if (!OpenSsl.isCipherSuiteAvailable(converted)) {
  5. throw new IllegalArgumentException("unsupported cipher suite: " + c + '(' + converted + ')');

相关文章