当前位置: 首页>>代码示例>>Java>>正文


Java OpenSsl.isAvailable方法代码示例

本文整理汇总了Java中io.netty.handler.ssl.OpenSsl.isAvailable方法的典型用法代码示例。如果您正苦于以下问题:Java OpenSsl.isAvailable方法的具体用法?Java OpenSsl.isAvailable怎么用?Java OpenSsl.isAvailable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.netty.handler.ssl.OpenSsl的用法示例。


在下文中一共展示了OpenSsl.isAvailable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: provider

import io.netty.handler.ssl.OpenSsl; //导入方法依赖的package包/类
private static SslProvider provider(NetworkSslConfig cfg) {
    switch (cfg.getProvider()) {
        case AUTO: {
            return OpenSsl.isAvailable() ? SslProvider.OPENSSL : SslProvider.JDK;
        }
        case JDK: {
            return SslProvider.JDK;
        }
        case OPEN_SSL: {
            return SslProvider.OPENSSL;
        }
        default: {
            throw new IllegalArgumentException("Unexpected SSL provider: " + cfg.getProvider());
        }
    }
}
 
开发者ID:hekate-io,项目名称:hekate,代码行数:17,代码来源:NettySslUtils.java

示例2: createSslContext

import io.netty.handler.ssl.OpenSsl; //导入方法依赖的package包/类
private synchronized static SslContext createSslContext() throws SSLException {
  if (sslBuilder == null) {
    sslBuilder = GrpcSslContexts.forClient().ciphers(null);
    // gRPC uses tcnative / OpenSsl by default, if it's available. It defaults to alpn-boot
    // if tcnative is not in the classpath.
    if (OpenSsl.isAvailable()) {
      LOG.info(
          "SslContext: gRPC is using the OpenSSL provider (tcnactive jar - Open Ssl version: {})",
          OpenSsl.versionString());
    } else {
      if (isJettyAlpnConfigured()) {
        // gRPC uses jetty ALPN as a backup to tcnative.
        LOG.info("SslContext: gRPC is using the JDK provider (alpn-boot jar)");
      } else {
        LOG.info("SslContext: gRPC cannot be configured.  Neither OpenSsl nor Alpn are available.");
      }
    }
  }
  return sslBuilder.build();
}
 
开发者ID:benson-git,项目名称:ibole-microservice,代码行数:21,代码来源:GrpcClientInitializer.java

示例3: get

import io.netty.handler.ssl.OpenSsl; //导入方法依赖的package包/类
@Override
public List<String> get() {
    List<String> ciphers;
    if (OpenSsl.isAvailable()) {
        // TODO: consider switching to the list of all available ciphers using OpenSsl.availableCipherSuites()
        ciphers = getBuiltInCipherList();
    } else {
        ciphers = getEnabledJdkCipherSuites();

        if (ciphers.isEmpty()) {
            // could not retrieve the list of enabled ciphers from the JDK SSLContext, so use the hard-coded list
            ciphers = getBuiltInCipherList();
        }
    }

    return ciphers;
}
 
开发者ID:misakuo,项目名称:Dream-Catcher,代码行数:18,代码来源:SslUtil.java

示例4: logOpenSSLInfos

import io.netty.handler.ssl.OpenSsl; //导入方法依赖的package包/类
private void logOpenSSLInfos() {
    if (OpenSsl.isAvailable()) {
        log.info("Open SSL " + OpenSsl.versionString() + " ("+OpenSsl.version()+") available");
        
        if(OpenSsl.version() < 0x10002000L) {
            log.warn("Outdated OpenSSL version detected. You should update to 1.0.2k or later. Currently installed: "+OpenSsl.versionString());
        }

        if(!OpenSsl.supportsHostnameValidation()) {
            log.warn("Your OpenSSL version "+OpenSsl.versionString()+" does not support hostname verification. You should update to 1.0.2k or later.");
        }

        log.debug("Open SSL available ciphers " + OpenSsl.availableOpenSslCipherSuites());
    } else {
        log.info("Open SSL not available (this is not an error, we simply fallback to built-in JDK SSL) because of " + OpenSsl.unavailabilityCause());
    }
}
 
开发者ID:floragunncom,项目名称:search-guard-ssl,代码行数:18,代码来源:DefaultSearchGuardKeyStore.java

示例5: data

import io.netty.handler.ssl.OpenSsl; //导入方法依赖的package包/类
@Parameters(name = "{index}: serverEngine = {0}, clientEngine = {1}")
public static Collection<Object[]> data() throws Exception {
    List<SslContext> serverContexts = new ArrayList<SslContext>();
    serverContexts.add(new JdkSslServerContext(CERT_FILE, KEY_FILE));

    List<SslContext> clientContexts = new ArrayList<SslContext>();
    clientContexts.add(new JdkSslClientContext(CERT_FILE));

    boolean hasOpenSsl = OpenSsl.isAvailable();
    if (hasOpenSsl) {
        serverContexts.add(new OpenSslServerContext(CERT_FILE, KEY_FILE));
        clientContexts.add(new OpenSslClientContext(CERT_FILE));
    } else {
        logger.warn("OpenSSL is unavailable and thus will not be tested.", OpenSsl.unavailabilityCause());
    }

    List<Object[]> params = new ArrayList<Object[]>();
    for (SslContext sc: serverContexts) {
        for (SslContext cc: clientContexts) {
            params.add(new Object[] { sc, cc });
        }
    }
    return params;
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:25,代码来源:SocketSslGreetingTest.java

示例6: getSslContext

import io.netty.handler.ssl.OpenSsl; //导入方法依赖的package包/类
public SslContext getSslContext() throws UnRetriableException{


        try {

            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);
        }
    }
 
开发者ID:caricah,项目名称:iotracah,代码行数:24,代码来源:SSLHandler.java

示例7: getSslProvider

import io.netty.handler.ssl.OpenSsl; //导入方法依赖的package包/类
/**
 * Selects an SSL provider based on the availability of of an ALPN-capable native provider.
 *
 * @return an ALPN-capable native SSL provider if available, or else the JDK SSL provider
 */
public static SslProvider getSslProvider() {
    final SslProvider sslProvider;

    if (OpenSsl.isAvailable()) {
        if (OpenSsl.isAlpnSupported()) {
            log.info("Native SSL provider is available and supports ALPN; will use native provider.");
            sslProvider = SslProvider.OPENSSL_REFCNT;
        } else {
            log.info("Native SSL provider is available, but does not support ALPN; will use JDK SSL provider.");
            sslProvider = SslProvider.JDK;
        }
    } else {
        log.info("Native SSL provider not available; will use JDK SSL provider.");
        sslProvider = SslProvider.JDK;
    }

    return sslProvider;
}
 
开发者ID:relayrides,项目名称:pushy,代码行数:24,代码来源:SslUtil.java

示例8: isAlpnProviderEnabled

import io.netty.handler.ssl.OpenSsl; //导入方法依赖的package包/类
/**
 * <p>
 * isAlpnProviderEnabled.
 * </p>
 *
 * @return a boolean.
 */
public static boolean isAlpnProviderEnabled() {
  final boolean openSslAvailable = OpenSsl.isAvailable();
  final boolean jettyAlpnConfigured = isJettyAlpnConfigured();
  LOG.debug("OpenSSL available: '{}'", openSslAvailable);
  LOG.debug("Jetty ALPN available: '{}'", jettyAlpnConfigured);
  return openSslAvailable || jettyAlpnConfigured;
}
 
开发者ID:benson-git,项目名称:ibole-microservice,代码行数:15,代码来源:GrpcClientInitializer.java

示例9: isOpenSslAvailable

import io.netty.handler.ssl.OpenSsl; //导入方法依赖的package包/类
public static boolean isOpenSslAvailable() {
    if (openSslAvailable != null) {
        return openSslAvailable;
    }
    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;
}
 
开发者ID:diennea,项目名称:majordodo,代码行数:15,代码来源:NetworkUtils.java

示例10: getSslProvider

import io.netty.handler.ssl.OpenSsl; //导入方法依赖的package包/类
public SslProvider getSslProvider() {
  if (useOpenSsl) {
    if (!OpenSsl.isAvailable()) {
      throw new IllegalStateException("useOpenSsl = true and OpenSSL is not available");
    }
    return SslProvider.OPENSSL;
  }
  return SslProvider.JDK;
}
 
开发者ID:xjdr,项目名称:xio,代码行数:10,代码来源:TlsConfig.java

示例11: selectApplicationProtocolConfig

import io.netty.handler.ssl.OpenSsl; //导入方法依赖的package包/类
/**
 * Attempts to select the best {@link ApplicationProtocolConfig} for the given
 * {@link SslProvider}.
 */
private static ApplicationProtocolConfig selectApplicationProtocolConfig(SslProvider provider) {
  switch (provider) {
    case JDK: {
      if (JettyTlsUtil.isJettyAlpnConfigured()) {
        return ALPN;
      }
      if (JettyTlsUtil.isJettyNpnConfigured()) {
        return NPN;
      }
      if (JettyTlsUtil.isJava9AlpnAvailable()) {
        return ALPN;
      }
      // Use the ALPN cause since it is prefered.
      throw new IllegalArgumentException(
          "ALPN is not configured properly. See https://github.com/grpc/grpc-java/blob/master/SECURITY.md#troubleshooting"
              + " for more information.",
          JettyTlsUtil.getJettyAlpnUnavailabilityCause());
    }
    case OPENSSL: {
      if (!OpenSsl.isAvailable()) {
        throw new IllegalArgumentException(
            "OpenSSL is not installed on the system.", OpenSsl.unavailabilityCause());
      }
      return OpenSsl.isAlpnSupported() ? NPN_AND_ALPN : NPN;
    }
    default:
      throw new IllegalArgumentException("Unsupported provider: " + provider);
  }
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:34,代码来源:GrpcSslContexts.java

示例12: all

import io.netty.handler.ssl.OpenSsl; //导入方法依赖的package包/类
public static Collection<HekateTestContext> all() {
    List<NetworkSslConfig> sslProvider = new ArrayList<>();

    // SSL disabled.
    if (HekateTestProps.is("NO_SSL_ENABLED")) {
        sslProvider.add(null);
    }

    // JDK SSL provider.
    if (HekateTestProps.is("SSL_JDK_ENABLED")) {
        sslProvider.add(new NetworkSslConfig()
            .withProvider(NetworkSslConfig.Provider.JDK)
            .withKeyStorePath(KEY_STORE_PATH)
            .withKeyStorePassword(KEY_STORE_PASSWORD)
            .withSslSessionCacheSize(1024)
            .withSslSessionCacheTimeout(10)
        );
    }

    // OpenSSL provider.
    if (HekateTestProps.is("SSL_OPENSSL_ENABLED") && OpenSsl.isAvailable()) {
        sslProvider.add(new NetworkSslConfig()
            .withProvider(NetworkSslConfig.Provider.OPEN_SSL)
            .withKeyStorePath(KEY_STORE_PATH)
            .withKeyStorePassword(KEY_STORE_PASSWORD)
            .withSslSessionCacheSize(1024)
            .withSslSessionCacheTimeout(10)
        );
    }

    List<NetworkTransportType> transports = new ArrayList<>();

    if (HekateTestProps.is("NIO_ENABLED")) {
        transports.add(NetworkTransportType.NIO);
    }

    if (HekateTestProps.is("EPOLL_ENABLED") && Epoll.isAvailable()) {
        transports.add(NetworkTransportType.EPOLL);
    }

    assertFalse("Network transports are not configured", transports.isEmpty());
    assertFalse("SSL transports are not configured", sslProvider.isEmpty());

    return transports.stream()
        .flatMap(transport ->
            sslProvider.stream().flatMap(ssl ->
                Stream.of(
                    new HekateTestContext(transport, Optional.ofNullable(ssl))
                )
            )
        ).collect(toList());
}
 
开发者ID:hekate-io,项目名称:hekate,代码行数:53,代码来源:HekateTestContext.java

示例13: provideSslProvider

import io.netty.handler.ssl.OpenSsl; //导入方法依赖的package包/类
@Provides
static SslProvider provideSslProvider() {
  // Prefer OpenSSL.
  return OpenSsl.isAvailable() ? SslProvider.OPENSSL : SslProvider.JDK;
}
 
开发者ID:google,项目名称:nomulus,代码行数:6,代码来源:ProxyModule.java

示例14: data

import io.netty.handler.ssl.OpenSsl; //导入方法依赖的package包/类
@Parameters(name =
        "{index}: serverEngine = {0}, clientEngine = {1}, renegotiation = {2}, " +
        "serverUsesDelegatedTaskExecutor = {3}, clientUsesDelegatedTaskExecutor = {4}, " +
        "autoRead = {5}, useChunkedWriteHandler = {6}, useCompositeByteBuf = {7}")
public static Collection<Object[]> data() throws Exception {
    List<SslContext> serverContexts = new ArrayList<SslContext>();
    serverContexts.add(new JdkSslServerContext(CERT_FILE, KEY_FILE));

    List<SslContext> clientContexts = new ArrayList<SslContext>();
    clientContexts.add(new JdkSslClientContext(CERT_FILE));

    boolean hasOpenSsl = OpenSsl.isAvailable();
    if (hasOpenSsl) {
        serverContexts.add(new OpenSslServerContext(CERT_FILE, KEY_FILE));
        clientContexts.add(new OpenSslClientContext(CERT_FILE));
    } else {
        logger.warn("OpenSSL is unavailable and thus will not be tested.", OpenSsl.unavailabilityCause());
    }

    List<Object[]> params = new ArrayList<Object[]>();
    for (SslContext sc: serverContexts) {
        for (SslContext cc: clientContexts) {
            for (RenegotiationType rt: RenegotiationType.values()) {
                if (rt != RenegotiationType.NONE &&
                    (sc instanceof OpenSslContext || cc instanceof OpenSslContext)) {
                    // TODO: OpenSslEngine does not support renegotiation yet.
                    continue;
                }

                Renegotiation r;
                if (rt == RenegotiationType.NONE) {
                    r = Renegotiation.NONE;
                } else {
                    r = new Renegotiation(rt, "SSL_RSA_WITH_RC4_128_SHA");
                }

                for (int i = 0; i < 32; i++) {
                    params.add(new Object[] {
                            sc, cc, r,
                            (i & 16) != 0, (i & 8) != 0, (i & 4) != 0, (i & 2) != 0, (i & 1) != 0 });
                }
            }
        }
    }

    return params;
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:48,代码来源:SocketSslEchoTest.java

示例15: isOpenSslAvailable

import io.netty.handler.ssl.OpenSsl; //导入方法依赖的package包/类
static boolean isOpenSslAvailable() {
    return PlatformDependent.bitMode() != 32 && OpenSsl.isAvailable();
}
 
开发者ID:blynkkk,项目名称:blynk-server,代码行数:4,代码来源:SslContextHolder.java


注:本文中的io.netty.handler.ssl.OpenSsl.isAvailable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。