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


Java InsecureTrustManagerFactory类代码示例

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


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

示例1: initChannel

import io.netty.handler.ssl.util.InsecureTrustManagerFactory; //导入依赖的package包/类
@Override
protected void initChannel(SocketChannel ch) throws Exception {
    if (enableTLS) {
        File tlsCert = new File(serviceConfig.getTlsCertificateFilePath());
        File tlsKey = new File(serviceConfig.getTlsKeyFilePath());
        SslContextBuilder builder = SslContextBuilder.forServer(tlsCert, tlsKey);
        if (serviceConfig.isTlsAllowInsecureConnection()) {
            builder.trustManager(InsecureTrustManagerFactory.INSTANCE);
        } else {
            if (serviceConfig.getTlsTrustCertsFilePath().isEmpty()) {
                // Use system default
                builder.trustManager((File) null);
            } else {
                File trustCertCollection = new File(serviceConfig.getTlsTrustCertsFilePath());
                builder.trustManager(trustCertCollection);
            }
        }
        SslContext sslCtx = builder.clientAuth(ClientAuth.OPTIONAL).build();
        ch.pipeline().addLast(TLS_HANDLER, sslCtx.newHandler(ch.alloc()));
    }
    ch.pipeline().addLast("frameDecoder", new LengthFieldBasedFrameDecoder(PulsarDecoder.MaxFrameSize, 0, 4, 0, 4));
    ch.pipeline().addLast("handler", new ServerConnection(discoveryService));
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:24,代码来源:ServiceChannelInitializer.java

示例2: NettyHttpClient

import io.netty.handler.ssl.util.InsecureTrustManagerFactory; //导入依赖的package包/类
public NettyHttpClient(String authCode, HttpProxy proxy, ClientConfig config) {
    _maxRetryTimes = config.getMaxRetryTimes();
    _readTimeout = config.getReadTimeout();
    String message = MessageFormat.format("Created instance with "
                    + "connectionTimeout {0}, readTimeout {1}, maxRetryTimes {2}, SSL Version {3}",
            config.getConnectionTimeout(), _readTimeout, _maxRetryTimes, config.getSSLVersion());
    LOG.debug(message);
    _authCode = authCode;

    try {
        _sslCtx = SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build();
        _workerGroup = new NioEventLoopGroup();
        b = new Bootstrap(); // (1)
        b.group(_workerGroup); // (2)
        b.channel(NioSocketChannel.class); // (3)
        b.option(ChannelOption.SO_KEEPALIVE, true); // (4)
    } catch (SSLException e) {
        e.printStackTrace();
    }
}
 
开发者ID:jpush,项目名称:jiguang-java-client-common,代码行数:21,代码来源:NettyHttpClient.java

示例3: start

import io.netty.handler.ssl.util.InsecureTrustManagerFactory; //导入依赖的package包/类
public void start(String ip, int port) throws Exception {
	// Configure SSL.
	final SslContext sslCtx;
	if (SSL) {
		sslCtx = SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build();
	} else {
		sslCtx = null;
	}
	EventLoopGroup group = new NioEventLoopGroup();
	try {
		Bootstrap b = new Bootstrap();
		b.group(group).channel(NioSocketChannel.class).handler(new FileClientInitializer(sslCtx));
		Channel ch = b.connect(ip, port).sync().channel();
		ConfigurationContext.propMap.putIfAbsent(SOCKET_CHANNEL, ch);			
	}catch(Exception e){
		e.printStackTrace();
	}
}
 
开发者ID:polarcoral,项目名称:monica,代码行数:19,代码来源:SocketClient.java

示例4: buildSslCtx

import io.netty.handler.ssl.util.InsecureTrustManagerFactory; //导入依赖的package包/类
private SslContext buildSslCtx() {
  SslProvider provider = OpenSsl.isAlpnSupported() ? SslProvider.OPENSSL : SslProvider.JDK;
  try {
    return SslContextBuilder.forClient()
        .sslProvider(provider)
        .ciphers(Http2SecurityUtil.CIPHERS, SupportedCipherSuiteFilter.INSTANCE)
        .trustManager(InsecureTrustManagerFactory.INSTANCE)
        // TODO(JR): Make a seperate Handler Class for http2 as opposed to autoneg
        //        .applicationProtocolConfig(new ApplicationProtocolConfig(
        //          ApplicationProtocolConfig.Protocol.ALPN,
        //          // NO_ADVERTISE is currently the only mode supported by both OpenSsl and JDK providers.
        //          ApplicationProtocolConfig.SelectorFailureBehavior.NO_ADVERTISE,
        //          // ACCEPT is currently the only mode supported by both OpenSsl and JDK providers.
        //          ApplicationProtocolConfig.SelectedListenerFailureBehavior.ACCEPT,
        //          ApplicationProtocolNames.HTTP_2,
        //          ApplicationProtocolNames.HTTP_1_1))
        .build();
  } catch (SSLException e) {
    e.printStackTrace();
  }

  return null;
}
 
开发者ID:Nordstrom,项目名称:xrpc,代码行数:24,代码来源:XrpcClient.java

示例5: trustManager

import io.netty.handler.ssl.util.InsecureTrustManagerFactory; //导入依赖的package包/类
private static TrustManagerFactory trustManager(NetworkSslConfig cfg, ResourceService resources) throws GeneralSecurityException,
    IOException, ResourceLoadingException {
    if (cfg.getTrustStorePath() == null || cfg.getTrustStorePath().isEmpty()) {
        return InsecureTrustManagerFactory.INSTANCE;
    } else {
        TrustManagerFactory factory;

        if (cfg.getTrustStoreAlgorithm() == null || cfg.getTrustStoreAlgorithm().isEmpty()) {
            factory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
        } else {
            factory = TrustManagerFactory.getInstance(cfg.getTrustStoreAlgorithm());
        }

        KeyStore store = keyStore(cfg.getTrustStorePath(), cfg.getTrustStorePassword(), cfg.getTrustStoreType(), resources);

        factory.init(store);

        return factory;
    }
}
 
开发者ID:hekate-io,项目名称:hekate,代码行数:21,代码来源:NettySslUtils.java

示例6: shoot

import io.netty.handler.ssl.util.InsecureTrustManagerFactory; //导入依赖的package包/类
public void shoot(ShootComplete shootComplete) {

        Bootstrap b = new Bootstrap();

        SslContext sslContext = null;
        if (ssl) {
            try {
                sslContext = SslContextBuilder.forClient()
                        .trustManager(InsecureTrustManagerFactory.INSTANCE).build();
            } catch (SSLException e) {
                e.printStackTrace();
            }
        }

        b.group(group)
                .channel(NioSocketChannel.class)
                .handler(new HttpClientInitializer(sslContext));

        // Make the connection attempt.
        b.connect(host, port).addListener(
                (ChannelFutureListener) channelFuture -> {
                    sendHttpRequest(channelFuture, shootComplete);
                });
    }
 
开发者ID:Sammers21,项目名称:Ashbringer-load,代码行数:25,代码来源:NettyShooter.java

示例7: initChannel

import io.netty.handler.ssl.util.InsecureTrustManagerFactory; //导入依赖的package包/类
@Override
protected void initChannel(SocketChannel channel) throws SSLException {
    URI uri = config.getConnectionWebsocketUri();

    DefaultHttpHeaders headers = new DefaultHttpHeaders();
    headers.add(USER_ID_HEADER, config.getConnectionUserId().toString());
    headers.add(USER_PASSWORD_HEADER, config.getConnectionUserPassword());
    headers.add(SUPPLIER_ID_HEADER, config.getConnectionServerId());

    WebSocketClientHandshaker handshaker = WebSocketClientHandshakerFactory.newHandshaker(uri, WS_VERSION, null, false, headers);

    ChannelPipeline pipeline = channel.pipeline();
    if (config.isConnectionSecure()) {
        try {
            SslContext sslContext = SslContext.newClientContext(InsecureTrustManagerFactory.INSTANCE);
            pipeline.addLast(sslContext.newHandler(channel.alloc()));
        } catch (SSLException e) {
            logger.log(Level.SEVERE, "Shutting down client due to unexpected failure to create SSL context", e);
            throw e;
        }
    }
    pipeline.addLast(new HttpClientCodec());
    pipeline.addLast(new HttpObjectAggregator(8192));
    pipeline.addLast(new AudioConnectClientHandler(handshaker));
}
 
开发者ID:DeadmanDungeons,项目名称:AudioConnect,代码行数:26,代码来源:AudioConnectClient.java

示例8: initChannel

import io.netty.handler.ssl.util.InsecureTrustManagerFactory; //导入依赖的package包/类
@Override
protected void initChannel(SocketChannel ch) throws Exception {
    if (enableTLS) {
        File tlsCert = new File(serviceConfig.getTlsCertificateFilePath());
        File tlsKey = new File(serviceConfig.getTlsKeyFilePath());
        SslContextBuilder builder = SslContextBuilder.forServer(tlsCert, tlsKey);
        if (serviceConfig.isTlsAllowInsecureConnection()) {
            builder.trustManager(InsecureTrustManagerFactory.INSTANCE);
        } else {
            if (serviceConfig.getTlsTrustCertsFilePath().isEmpty()) {
                // Use system default
                builder.trustManager((File) null);
            } else {
                File trustCertCollection = new File(serviceConfig.getTlsTrustCertsFilePath());
                builder.trustManager(trustCertCollection);
            }
        }
        SslContext sslCtx = builder.clientAuth(ClientAuth.OPTIONAL).build();
        ch.pipeline().addLast(TLS_HANDLER, sslCtx.newHandler(ch.alloc()));
    }
    ch.pipeline().addLast("frameDecoder", new LengthFieldBasedFrameDecoder(PulsarDecoder.MaxFrameSize, 0, 4, 0, 4));
    ch.pipeline().addLast("handler", new ServerCnx(brokerService));
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:24,代码来源:PulsarChannelInitializer.java

示例9: shouldEnableSslWithSslContextProgrammaticallySpecified

import io.netty.handler.ssl.util.InsecureTrustManagerFactory; //导入依赖的package包/类
@Test
public void shouldEnableSslWithSslContextProgrammaticallySpecified() throws Exception {
    // just for testing - this is not good for production use
    final SslContextBuilder builder = SslContextBuilder.forClient();
    builder.trustManager(InsecureTrustManagerFactory.INSTANCE);
    builder.sslProvider(SslProvider.JDK);

    final Cluster cluster = Cluster.build().enableSsl(true).sslContext(builder.build()).create();
    final Client client = cluster.connect();

    try {
        // this should return "nothing" - there should be no exception
        assertEquals("test", client.submit("'test'").one().getString());
    } finally {
        cluster.close();
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:18,代码来源:GremlinServerIntegrateTest.java

示例10: WebSocketClient

import io.netty.handler.ssl.util.InsecureTrustManagerFactory; //导入依赖的package包/类
public WebSocketClient(WebSocketConfig config) throws URISyntaxException, SSLException, InterruptedException {
    final int port = config.serverUri.getPort();
    final String scheme = config.serverUri.getScheme().endsWith("s") ? "wss" : "ws";
    final boolean isWss = "wss".equalsIgnoreCase(scheme);

    this.headers = new DefaultHttpHeaders();
    if (config.apiKey != null) headers.add("X-Samebug-ApiKey", config.apiKey);
    if (config.workspaceId != null) headers.add("X-Samebug-WorkspaceId", config.workspaceId);

    this.port = port == -1 ? (isWss ? 443 : 80) : port;
    this.host = config.serverUri.getHost();
    this.wsEndpoint = new URI(scheme, null, host, port, "/sockets/websocket", null, null);
    this.eventHandler = config.eventHandler;
    this.group = config.group;
    this.sslContext = isWss ? SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build() : null;
    // IMPROVE the constructor blocks the thread with networking!
    this.channel = connect();
}
 
开发者ID:samebug,项目名称:samebug-idea-plugin,代码行数:19,代码来源:WebSocketClient.java

示例11: getSslContext

import io.netty.handler.ssl.util.InsecureTrustManagerFactory; //导入依赖的package包/类
private SslContext getSslContext() {
    SslContext sslCtx = null;

    final SslProvider provider = OpenSsl.isAlpnSupported() ? SslProvider.OPENSSL : SslProvider.JDK;

    try {
        sslCtx = SslContextBuilder.forClient()
            .sslProvider(provider)
            .ciphers(Http2SecurityUtil.CIPHERS, SupportedCipherSuiteFilter.INSTANCE)
            .trustManager(InsecureTrustManagerFactory.INSTANCE)
            .applicationProtocolConfig(new ApplicationProtocolConfig(
                Protocol.ALPN,
                SelectorFailureBehavior.NO_ADVERTISE,
                SelectedListenerFailureBehavior.ACCEPT,
                ApplicationProtocolNames.HTTP_2))
            .build();
    } catch(SSLException exception) {
        return null;
    }

    return sslCtx;
}
 
开发者ID:syucream,项目名称:jmeter-http2-plugin,代码行数:23,代码来源:NettyHttp2Client.java

示例12: https

import io.netty.handler.ssl.util.InsecureTrustManagerFactory; //导入依赖的package包/类
@Test
public void https() throws Exception {
    ClientFactory clientFactory = new ClientFactoryBuilder()
            .sslContextCustomizer(b -> b.trustManager(InsecureTrustManagerFactory.INSTANCE))
            .build();
    HttpClient client = HttpClient.of(clientFactory, server().httpsUri("/"));
    AggregatedHttpMessage response = client.get("/jsp/index.jsp").aggregate().get();
    final String actualContent = CR_OR_LF.matcher(response.content().toStringUtf8())
                                         .replaceAll("");
    assertThat(actualContent).isEqualTo(
            "<html><body>" +
            "<p>Hello, Armerian World!</p>" +
            "<p>Have you heard about the class 'io.netty.buffer.ByteBuf'?</p>" +
            "<p>Context path: </p>" + // ROOT context path
            "<p>Request URI: /index.jsp</p>" +
            "<p>Scheme: https</p>" +
            "</body></html>");
}
 
开发者ID:line,项目名称:armeria,代码行数:19,代码来源:WebAppContainerTest.java

示例13: WebSocketClient

import io.netty.handler.ssl.util.InsecureTrustManagerFactory; //导入依赖的package包/类
public WebSocketClient(String host, int port, String path, boolean isSSL) throws Exception {
    super(host, port, new Random());

    String scheme = isSSL ? "wss://" : "ws://";
    URI uri = new URI(scheme + host + ":" + port + path);

    if (isSSL) {
        sslCtx = SslContextBuilder.forClient().sslProvider(SslProvider.JDK).trustManager(InsecureTrustManagerFactory.INSTANCE).build();
    } else {
        sslCtx = null;
    }

    this.handler = new WebSocketClientHandler(
                    WebSocketClientHandshakerFactory.newHandshaker(
                            uri, WebSocketVersion.V13, null, false, new DefaultHttpHeaders()));
}
 
开发者ID:blynkkk,项目名称:blynk-server,代码行数:17,代码来源:WebSocketClient.java

示例14: shouldEnableSslWithSslContextProgrammaticallySpecified

import io.netty.handler.ssl.util.InsecureTrustManagerFactory; //导入依赖的package包/类
@Test
public void shouldEnableSslWithSslContextProgrammaticallySpecified() throws Exception {
    // just for testing - this is not good for production use
    final SslContextBuilder builder = SslContextBuilder.forClient();
    builder.trustManager(InsecureTrustManagerFactory.INSTANCE);
    builder.sslProvider(SslProvider.JDK);

    final Cluster cluster = TestClientFactory.build().enableSsl(true).sslContext(builder.build()).create();
    final Client client = cluster.connect();

    try {
        // this should return "nothing" - there should be no exception
        assertEquals("test", client.submit("'test'").one().getString());
    } finally {
        cluster.close();
    }
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:18,代码来源:GremlinServerIntegrateTest.java

示例15: initialize

import io.netty.handler.ssl.util.InsecureTrustManagerFactory; //导入依赖的package包/类
public ExtractorClient initialize() throws DeepExtractorInitializationException {
    try {
        // Configure SSL.
        final SslContext sslCtx;
        if (SSL) {

            sslCtx = SslContext.newClientContext(InsecureTrustManagerFactory.INSTANCE);

        } else {
            sslCtx = null;
        }

        Bootstrap b = new Bootstrap();
        b.group(group).channel(NioSocketChannel.class).handler(new ExtractorClientInitializer<T>(sslCtx));

        // Make a new connection.
        this.ch = b.connect(HOST, PORT).sync().channel();

        // Get the handler instance to initiate the request.
        this.handler = ch.pipeline().get(ExtractorClientHandler.class);
    } catch (SSLException | InterruptedException e) {
        throw new DeepExtractorInitializationException(e);

    }
    return this;
}
 
开发者ID:Stratio,项目名称:deep-spark,代码行数:27,代码来源:ExtractorClient.java


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