本文整理汇总了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());
}
}
}
示例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();
}
示例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;
}
示例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());
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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());
}
示例13: provideSslProvider
import io.netty.handler.ssl.OpenSsl; //导入方法依赖的package包/类
@Provides
static SslProvider provideSslProvider() {
// Prefer OpenSSL.
return OpenSsl.isAvailable() ? SslProvider.OPENSSL : SslProvider.JDK;
}
示例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;
}
示例15: isOpenSslAvailable
import io.netty.handler.ssl.OpenSsl; //导入方法依赖的package包/类
static boolean isOpenSslAvailable() {
return PlatformDependent.bitMode() != 32 && OpenSsl.isAvailable();
}