com.ning.http.client.AsyncHttpClientConfig.getSSLContext()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(5.5k)|赞(0)|评价(0)|浏览(71)

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

AsyncHttpClientConfig.getSSLContext介绍

[英]Return an instance of SSLContext used for SSL connection.
[中]返回用于SSL连接的SSLContext实例。

代码示例

代码示例来源:origin: com.ning/async-http-client

public SSLContext getSSLContext(AsyncHttpClientConfig config) throws GeneralSecurityException {
    SSLContext sslContext = config.getSSLContext();

    if (sslContext == null) {
      sslContext = config.isAcceptAnyCertificate() ? looseTrustManagerSSLContext : SSLContext.getDefault();
      if (config.getSslSessionCacheSize() != null)
        sslContext.getClientSessionContext().setSessionCacheSize(config.getSslSessionCacheSize());
      if (config.getSslSessionTimeout() != null)
        sslContext.getClientSessionContext().setSessionTimeout(config.getSslSessionTimeout());
    }
    return sslContext;
  }
}

代码示例来源:origin: com.ning/async-http-client

realm = prototype.getRealm();
requestTimeout = prototype.getRequestTimeout();
sslContext = prototype.getSSLContext();
userAgent = prototype.getUserAgent();
followRedirect = prototype.isFollowRedirect();

代码示例来源:origin: com.ning/async-http-client

final boolean defaultSecState = (clientConfig.getSSLContext() != null);
final SSLEngineConfigurator configurator
    = new AhcSSLEngineConfigurator(

代码示例来源:origin: io.gatling/async-http-client

private HttpURLConnection createUrlConnection(Request request) throws IOException, URISyntaxException {
  ProxyServer proxyServer = ProxyUtils.getProxyServer(config, request);
  Realm realm = request.getRealm() != null ? request.getRealm() : config.getRealm();
  Proxy proxy = null;
  if (proxyServer != null || realm != null) {
    try {
      proxy = configureProxyAndAuth(proxyServer, realm);
    } catch (AuthenticationException e) {
      throw new IOException(e.getMessage());
    }
  }
  HttpURLConnection urlConnection = (HttpURLConnection)
    request.getURI().toURI().toURL().openConnection(proxy == null ? Proxy.NO_PROXY : proxy);
  if (request.getURI().getScheme().equals("https")) {
    HttpsURLConnection secure = (HttpsURLConnection) urlConnection;
    SSLContext sslContext = config.getSSLContext();
    if (sslContext == null) {
      try {
        sslContext = SslUtils.getInstance().getSSLContext(config.isAcceptAnyCertificate());
      } catch (NoSuchAlgorithmException e) {
        throw new IOException(e.getMessage());
      } catch (GeneralSecurityException e) {
        throw new IOException(e.getMessage());
      }
    }
    secure.setSSLSocketFactory(sslContext.getSocketFactory());
    secure.setHostnameVerifier(config.getHostnameVerifier());
  }
  return urlConnection;
}

代码示例来源:origin: io.gatling/async-http-client

public SslHandler createSslHandler(String peerHost, int peerPort) throws GeneralSecurityException, IOException {
  SSLEngine sslEngine = null;
  if (nettyConfig.getSslEngineFactory() != null) {
    sslEngine = nettyConfig.getSslEngineFactory().newSSLEngine();
  } else {
    SSLContext sslContext = config.getSSLContext();
    if (sslContext == null)
      sslContext = SslUtils.getInstance().getSSLContext(config.isAcceptAnyCertificate());
    sslEngine = sslContext.createSSLEngine(peerHost, peerPort);
    sslEngine.setUseClientMode(true);
  }
  return handshakeTimeout > 0 ? new SslHandler(sslEngine, getDefaultBufferPool(), false, nettyTimer, handshakeTimeout)
      : new SslHandler(sslEngine);
}

代码示例来源:origin: org.glassfish.grizzly/grizzly-http-client

public SSLContext getSSLContext(AsyncHttpClientConfig config) throws GeneralSecurityException {
    SSLContext sslContext = config.getSSLContext();

    if (sslContext == null) {
      sslContext = config.isAcceptAnyCertificate() ? looseTrustManagerSSLContext : SSLContext.getDefault();
      if (config.getSslSessionCacheSize() != null)
        sslContext.getClientSessionContext().setSessionCacheSize(config.getSslSessionCacheSize());
      if (config.getSslSessionTimeout() != null)
        sslContext.getClientSessionContext().setSessionTimeout(config.getSslSessionTimeout());
    }
    return sslContext;
  }
}

代码示例来源:origin: javaee/grizzly-ahc

public SSLContext getSSLContext(AsyncHttpClientConfig config) throws GeneralSecurityException {
    SSLContext sslContext = config.getSSLContext();

    if (sslContext == null) {
      sslContext = config.isAcceptAnyCertificate() ? looseTrustManagerSSLContext : SSLContext.getDefault();
      if (config.getSslSessionCacheSize() != null)
        sslContext.getClientSessionContext().setSessionCacheSize(config.getSslSessionCacheSize());
      if (config.getSslSessionTimeout() != null)
        sslContext.getClientSessionContext().setSessionTimeout(config.getSslSessionTimeout());
    }
    return sslContext;
  }
}

代码示例来源:origin: org.glassfish.grizzly/grizzly-http-client

realm = prototype.getRealm();
requestTimeout = prototype.getRequestTimeout();
sslContext = prototype.getSSLContext();
userAgent = prototype.getUserAgent();
followRedirect = prototype.isFollowRedirect();

代码示例来源:origin: io.gatling/async-http-client

realm = prototype.getRealm();
requestTimeout = prototype.getRequestTimeout();
sslContext = prototype.getSSLContext();
userAgent = prototype.getUserAgent();
followRedirect = prototype.isFollowRedirect();

代码示例来源:origin: javaee/grizzly-ahc

realm = prototype.getRealm();
requestTimeout = prototype.getRequestTimeout();
sslContext = prototype.getSSLContext();
userAgent = prototype.getUserAgent();
followRedirect = prototype.isFollowRedirect();

代码示例来源:origin: io.gatling/async-http-client

SSLContext context = clientConfig.getSSLContext();
boolean defaultSecState = (context != null);
if (context == null) {

代码示例来源:origin: org.glassfish.grizzly/grizzly-http-client

final boolean defaultSecState = (clientConfig.getSSLContext() != null);
final SSLEngineConfigurator configurator
    = new AhcSSLEngineConfigurator(

代码示例来源:origin: javaee/grizzly-ahc

final boolean defaultSecState = (clientConfig.getSSLContext() != null);
final SSLEngineConfigurator configurator
    = new AhcSSLEngineConfigurator(

相关文章

微信公众号

最新文章

更多