|
|
@ -15,26 +15,27 @@ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
package io.netty.handler.ssl; |
|
|
|
package io.netty.handler.ssl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static io.netty.handler.ssl.SslUtils.toSSLHandshakeException; |
|
|
|
|
|
|
|
import static io.netty.util.internal.ObjectUtil.checkNotNull; |
|
|
|
|
|
|
|
import static java.lang.Math.min; |
|
|
|
|
|
|
|
|
|
|
|
import io.netty.buffer.ByteBuf; |
|
|
|
import io.netty.buffer.ByteBuf; |
|
|
|
import io.netty.buffer.ByteBufAllocator; |
|
|
|
import io.netty.buffer.ByteBufAllocator; |
|
|
|
import io.netty.handler.ssl.JdkApplicationProtocolNegotiator.ProtocolSelectionListener; |
|
|
|
import io.netty.handler.ssl.JdkApplicationProtocolNegotiator.ProtocolSelectionListener; |
|
|
|
import io.netty.handler.ssl.JdkApplicationProtocolNegotiator.ProtocolSelector; |
|
|
|
import io.netty.handler.ssl.JdkApplicationProtocolNegotiator.ProtocolSelector; |
|
|
|
import io.netty.util.internal.SystemPropertyUtil; |
|
|
|
|
|
|
|
import org.conscrypt.AllocatedBuffer; |
|
|
|
|
|
|
|
import org.conscrypt.BufferAllocator; |
|
|
|
|
|
|
|
import org.conscrypt.HandshakeListener; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.net.ssl.SSLEngine; |
|
|
|
|
|
|
|
import javax.net.ssl.SSLEngineResult; |
|
|
|
|
|
|
|
import javax.net.ssl.SSLException; |
|
|
|
|
|
|
|
import java.nio.ByteBuffer; |
|
|
|
import java.nio.ByteBuffer; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.LinkedHashSet; |
|
|
|
import java.util.LinkedHashSet; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import javax.net.ssl.SSLEngine; |
|
|
|
|
|
|
|
import javax.net.ssl.SSLEngineResult; |
|
|
|
|
|
|
|
import javax.net.ssl.SSLException; |
|
|
|
|
|
|
|
|
|
|
|
import static io.netty.handler.ssl.SslUtils.toSSLHandshakeException; |
|
|
|
import io.netty.util.internal.SystemPropertyUtil; |
|
|
|
import static io.netty.util.internal.ObjectUtil.checkNotNull; |
|
|
|
import org.conscrypt.AllocatedBuffer; |
|
|
|
import static java.lang.Math.min; |
|
|
|
import org.conscrypt.BufferAllocator; |
|
|
|
|
|
|
|
import org.conscrypt.Conscrypt; |
|
|
|
|
|
|
|
import org.conscrypt.HandshakeListener; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* A {@link JdkSslEngine} that uses the Conscrypt provider or SSL with ALPN. |
|
|
|
* A {@link JdkSslEngine} that uses the Conscrypt provider or SSL with ALPN. |
|
|
@ -44,12 +45,12 @@ abstract class ConscryptAlpnSslEngine extends JdkSslEngine { |
|
|
|
"io.netty.handler.ssl.conscrypt.useBufferAllocator", true); |
|
|
|
"io.netty.handler.ssl.conscrypt.useBufferAllocator", true); |
|
|
|
|
|
|
|
|
|
|
|
static ConscryptAlpnSslEngine newClientEngine(SSLEngine engine, ByteBufAllocator alloc, |
|
|
|
static ConscryptAlpnSslEngine newClientEngine(SSLEngine engine, ByteBufAllocator alloc, |
|
|
|
JdkApplicationProtocolNegotiator applicationNegotiator) { |
|
|
|
JdkApplicationProtocolNegotiator applicationNegotiator) { |
|
|
|
return new ClientEngine(engine, alloc, applicationNegotiator); |
|
|
|
return new ClientEngine(engine, alloc, applicationNegotiator); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static ConscryptAlpnSslEngine newServerEngine(SSLEngine engine, ByteBufAllocator alloc, |
|
|
|
static ConscryptAlpnSslEngine newServerEngine(SSLEngine engine, ByteBufAllocator alloc, |
|
|
|
JdkApplicationProtocolNegotiator applicationNegotiator) { |
|
|
|
JdkApplicationProtocolNegotiator applicationNegotiator) { |
|
|
|
return new ServerEngine(engine, alloc, applicationNegotiator); |
|
|
|
return new ServerEngine(engine, alloc, applicationNegotiator); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -96,7 +97,7 @@ abstract class ConscryptAlpnSslEngine extends JdkSslEngine { |
|
|
|
private final ProtocolSelectionListener protocolListener; |
|
|
|
private final ProtocolSelectionListener protocolListener; |
|
|
|
|
|
|
|
|
|
|
|
ClientEngine(SSLEngine engine, ByteBufAllocator alloc, |
|
|
|
ClientEngine(SSLEngine engine, ByteBufAllocator alloc, |
|
|
|
JdkApplicationProtocolNegotiator applicationNegotiator) { |
|
|
|
JdkApplicationProtocolNegotiator applicationNegotiator) { |
|
|
|
super(engine, alloc, applicationNegotiator.protocols()); |
|
|
|
super(engine, alloc, applicationNegotiator.protocols()); |
|
|
|
// Register for completion of the handshake.
|
|
|
|
// Register for completion of the handshake.
|
|
|
|
Conscrypt.setHandshakeListener(engine, new HandshakeListener() { |
|
|
|
Conscrypt.setHandshakeListener(engine, new HandshakeListener() { |
|
|
|