本文整理汇总了Java中io.netty.handler.ssl.SslHandler.handshakeFuture方法的典型用法代码示例。如果您正苦于以下问题:Java SslHandler.handshakeFuture方法的具体用法?Java SslHandler.handshakeFuture怎么用?Java SslHandler.handshakeFuture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.netty.handler.ssl.SslHandler
的用法示例。
在下文中一共展示了SslHandler.handshakeFuture方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: encrypt
import io.netty.handler.ssl.SslHandler; //导入方法依赖的package包/类
/**
* Encrypts traffic on this connection with SSL/TLS.
*
* @param pipeline
* the ChannelPipeline on which to enable encryption
* @param sslEngine
* the {@link SSLEngine} for doing the encryption
* @param authenticateClients
* determines whether to authenticate clients or not
* @return a Future for when the SSL handshake has completed
*/
protected Future<Channel> encrypt(ChannelPipeline pipeline,
SSLEngine sslEngine,
boolean authenticateClients) {
LOG.debug("Enabling encryption with SSLEngine: {}",
sslEngine);
this.sslEngine = sslEngine;
sslEngine.setUseClientMode(runsAsSslClient);
sslEngine.setNeedClientAuth(authenticateClients);
if (null != channel) {
channel.config().setAutoRead(true);
}
SslHandler handler = new SslHandler(sslEngine);
if(pipeline.get("ssl") == null) {
pipeline.addFirst("ssl", handler);
} else {
// The second SSL handler is added to handle the case
// where the proxy (running as MITM) has to chain with
// another SSL enabled proxy. The second SSL handler
// is to perform SSL with the server.
pipeline.addAfter("ssl", "sslWithServer", handler);
}
return handler.handshakeFuture();
}
示例2: encrypt
import io.netty.handler.ssl.SslHandler; //导入方法依赖的package包/类
/**
* Encrypts traffic on this connection with SSL/TLS.
*
* @param pipeline
* the ChannelPipeline on which to enable encryption
* @param sslEngine
* the {@link SSLEngine} for doing the encryption
* @param authenticateClients
* determines whether to authenticate clients or not
* @return a Future for when the SSL handshake has completed
*/
protected Future<Channel> encrypt(ChannelPipeline pipeline,
SSLEngine sslEngine,
boolean authenticateClients) {
LOG.debug("Enabling encryption with SSLEngine: {}",
sslEngine);
this.sslEngine = sslEngine;
sslEngine.setUseClientMode(runsAsSslClient);
sslEngine.setNeedClientAuth(authenticateClients);
if (null != channel) {
channel.config().setAutoRead(true);
}
SslHandler handler = new SslHandler(sslEngine);
pipeline.addFirst("ssl", handler);
return handler.handshakeFuture();
}
示例3: handshake
import io.netty.handler.ssl.SslHandler; //导入方法依赖的package包/类
/**
* Create {@link io.netty.handler.ssl.SslHandler} and send TCP handshaking using
* {@link javax.net.ssl.SSLEngine}
* After add ssl handler to the end of {@link io.netty.channel.ChannelPipeline}, it enable
* secure communications over SSL/TLS
*
* @param isSslClient true if the channel start handshaking or false if accept handshaking
* @param channel the channel to start handshaking
* */
private Future<Channel> handshake(SSLEngine sslEngine, boolean isSslClient, Channel channel) {
sslEngine.setUseClientMode(isSslClient);
if (channel != null) {
channel.config().setAutoRead(true);
}
SslHandler handler = new SslHandler(sslEngine);
channel.pipeline().addFirst("ssl", handler);
LOG.debug("About to start handshaking...");
return handler.handshakeFuture();
}
示例4: channelRead0
import io.netty.handler.ssl.SslHandler; //导入方法依赖的package包/类
@Override
public void channelRead0(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
byte[] actual = new byte[in.readableBytes()];
in.readBytes(actual);
int lastIdx = recvCounter.get();
for (int i = 0; i < actual.length; i ++) {
assertEquals(data[i + lastIdx], actual[i]);
}
ByteBuf buf = Unpooled.wrappedBuffer(actual);
if (useCompositeByteBuf) {
buf = Unpooled.compositeBuffer().addComponent(buf).writerIndex(buf.writerIndex());
}
ctx.write(buf);
recvCounter.addAndGet(actual.length);
// Perform server-initiated renegotiation if necessary.
if (renegotiation.type == RenegotiationType.SERVER_INITIATED &&
recvCounter.get() > data.length / 2 && renegoFuture == null) {
SslHandler sslHandler = ctx.pipeline().get(SslHandler.class);
Future<Channel> hf = sslHandler.handshakeFuture();
assertThat(hf.isDone(), is(true));
sslHandler.engine().setEnabledCipherSuites(new String[] { renegotiation.cipherSuite });
logStats("SERVER RENEGOTIATES");
renegoFuture = sslHandler.renegotiate();
assertThat(renegoFuture, is(not(sameInstance(hf))));
assertThat(renegoFuture, is(sameInstance(sslHandler.handshakeFuture())));
assertThat(renegoFuture.isDone(), is(false));
}
}
示例5: encrypt
import io.netty.handler.ssl.SslHandler; //导入方法依赖的package包/类
/**
* Encrypts traffic on this connection with SSL/TLS.
*
* @param pipeline
* the ChannelPipeline on which to enable encryption
* @param sslEngine
* the {@link SSLEngine} for doing the encryption
* @param authenticateClients
* determines whether to authenticate clients or not
* @return a Future for when the SSL handshake has completed
*/
protected Future<Channel> encrypt(ChannelPipeline pipeline,
SSLEngine sslEngine,
boolean authenticateClients) {
LOG.debug("Enabling encryption with SSLEngine: {}",
sslEngine);
this.sslEngine = sslEngine;
sslEngine.setUseClientMode(runsAsSslClient);
sslEngine.setNeedClientAuth(authenticateClients);
SslHandler handler = new SslHandler(sslEngine);
pipeline.addFirst("ssl", handler);
return handler.handshakeFuture();
}