public static Buffer allocateInputBuffer(final SSLConnectionContext sslCtx) { final SSLEngine sslEngine = sslCtx.getSslEngine(); if (sslEngine == null) { return null; } // Direct buffer input // final InputBufferWrapper buffer = sslCtx.useInputBuffer(); // return buffer.prepare(sslCtx.getNetBufferSize() * 2); // Heap buffer input return allocateOutputBuffer(sslCtx.getNetBufferSize() * 2); }
public static void setSSLEngine(final Connection connection, final SSLEngine sslEngine) { SSLConnectionContext ctx = getSslConnectionContext(connection); if (ctx == null) { // set first time outside of standard SSLFilter ctx = new SSLConnectionContext(connection); SSL_CTX_ATTR.set(connection, ctx); } ctx.configure(sslEngine); }
final Connection connection = ctx.getConnection(); final SSLConnectionContext sslCtx = obtainSslConnectionContext(connection); SSLEngine sslEngine = sslCtx.getSslEngine(); sslEngine = serverSSLEngineConfigurator.createSSLEngine(); sslEngine.beginHandshake(); sslCtx.configure(sslEngine); notifyHandshakeStart(connection); if (!isHandshaking) { notifyHandshakeComplete(connection, sslEngine); final FilterChain connectionFilterChain = sslCtx.getNewConnectionFilterChain(); sslCtx.setNewConnectionFilterChain(null); if (connectionFilterChain != null) { if (LOGGER.isLoggable(Level.FINE)) {
final Allocator allocator) { output = ensureBufferSize(output, netBufferSize, allocator); updateBufferSizes(); output = ensureBufferSize(output, netBufferSize, allocator); return wrap(input, inputArray, inputArraySize, output, null); } else if (isOverflow || status == Status.BUFFER_UNDERFLOW) { return new SslResult(output, new SSLException("SSL wrap error: " + status));
final SSLEngine sslEngine = sslCtx.getSslEngine(); final Buffer tmpAppBuffer = allocateOutputBuffer(sslCtx.getAppBufferSize());
@Override public NextAction handleWrite(final FilterChainContext ctx) throws IOException { final Connection connection = ctx.getConnection(); if (ctx.getMessage() instanceof FileTransfer) { throw new IllegalStateException("TLS operations not supported with SendFile messages"); } //noinspection SynchronizationOnLocalVariableOrMethodParameter synchronized (connection) { final SSLConnectionContext sslCtx = obtainSslConnectionContext(connection); final SSLEngine sslEngine = sslCtx.getSslEngine(); if (sslEngine != null && !isHandshaking(sslEngine)) { return sslCtx.isServerMode() ? super.handleWrite(ctx) : accurateWrite(ctx, true); } else { if (sslEngine == null || !handshakeContextAttr.isSet(connection)) { handshake(connection, null, null, clientSSLEngineConfigurator, ctx, false); } return accurateWrite(ctx, false); } } }
protected SSLEngine createClientSSLEngine( final SSLConnectionContext sslCtx, final SSLEngineConfigurator sslEngineConfigurator) { return IS_JDK7_OR_HIGHER ? sslEngineConfigurator.createSSLEngine( HostNameResolver.getPeerHostName(sslCtx.getConnection()), -1) : sslEngineConfigurator.createSSLEngine(); }
static Buffer makeInputRemainder( final SSLConnectionContext sslCtx, final FilterChainContext context, final Buffer buffer) { if (buffer == null) { return null; } if (!buffer.hasRemaining()) { buffer.tryDispose(); return null; } final Buffer inputBuffer = sslCtx.resetLastInputBuffer(); if (inputBuffer == null) { // SSLTransportWrapper hasn't been used final Buffer remainder = buffer.split(buffer.position()); buffer.tryDispose(); return remainder; } else { return move(context.getMemoryManager(), buffer); } }
@SuppressWarnings("MethodMayBeStatic") protected SSLConnectionContext createSslConnectionContext( final Connection connection) { return new SSLConnectionContext(connection); }
private static Certificate[] getPeerCertificates(final SSLConnectionContext sslCtx) { try { return sslCtx.getSslEngine().getSession().getPeerCertificates(); } catch( Throwable t ) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE,"Error getting client certs", t); } return null; } }
final Connection connection = ctx.getConnection(); final SSLConnectionContext sslCtx = obtainSslConnectionContext(connection); SSLEngine sslEngine = sslCtx.getSslEngine(); sslEngine = serverSSLEngineConfigurator.createSSLEngine(); sslEngine.beginHandshake(); sslCtx.configure(sslEngine); notifyHandshakeStart(connection); if (!isHandshaking) { notifyHandshakeComplete(connection, sslEngine); final FilterChain connectionFilterChain = sslCtx.getNewConnectionFilterChain(); sslCtx.setNewConnectionFilterChain(null); if (connectionFilterChain != null) { if (LOGGER.isLoggable(Level.FINE)) {
final Allocator allocator) { output = ensureBufferSize(output, netBufferSize, allocator); updateBufferSizes(); output = ensureBufferSize(output, netBufferSize, allocator); return wrap(input, inputArray, inputArraySize, output, null); } else if (isOverflow || status == Status.BUFFER_UNDERFLOW) { return new SslResult(output, new SSLException("SSL wrap error: " + status));
final SSLEngine sslEngine = sslCtx.getSslEngine(); final Buffer tmpAppBuffer = allocateOutputBuffer(sslCtx.getAppBufferSize());
@Override public NextAction handleWrite(final FilterChainContext ctx) throws IOException { final Connection connection = ctx.getConnection(); if (ctx.getMessage() instanceof FileTransfer) { throw new IllegalStateException("TLS operations not supported with SendFile messages"); } //noinspection SynchronizationOnLocalVariableOrMethodParameter synchronized (connection) { final SSLConnectionContext sslCtx = obtainSslConnectionContext(connection); final SSLEngine sslEngine = sslCtx.getSslEngine(); if (sslEngine != null && !isHandshaking(sslEngine)) { return sslCtx.isServerMode() ? super.handleWrite(ctx) : accurateWrite(ctx, true); } else { if (sslEngine == null || !handshakeContextAttr.isSet(connection)) { handshake(connection, null, null, clientSSLEngineConfigurator, ctx, false); } return accurateWrite(ctx, false); } } }
@Override @SuppressWarnings("unchecked") public Buffer grow(final SSLConnectionContext sslCtx, final Buffer oldBuffer, final int newSize) { final MemoryManager mm = sslCtx.getConnection().getMemoryManager(); return oldBuffer == null ? mm.allocate(newSize) : mm.reallocate(oldBuffer, newSize); } };
static Buffer makeInputRemainder( final SSLConnectionContext sslCtx, final FilterChainContext context, final Buffer buffer) { if (buffer == null) { return null; } if (!buffer.hasRemaining()) { buffer.tryDispose(); return null; } final Buffer inputBuffer = sslCtx.resetLastInputBuffer(); if (inputBuffer == null) { // SSLTransportWrapper hasn't been used final Buffer remainder = buffer.split(buffer.position()); buffer.tryDispose(); return remainder; } else { return move(context.getMemoryManager(), buffer); } }
@SuppressWarnings("MethodMayBeStatic") protected SSLConnectionContext createSslConnectionContext( final Connection connection) { return new SSLConnectionContext(connection); }
private SSLSession getSslSession(FilterChainContext ctx) throws SSLPeerUnverifiedException { SSLConnectionContext sslConnectionContext = obtainSslConnectionContext(ctx.getConnection()); if (sslConnectionContext == null) { return null; } return sslConnectionContext.getSslEngine().getSession(); }
final Connection connection = ctx.getConnection(); final SSLConnectionContext sslCtx = obtainSslConnectionContext(connection); SSLEngine sslEngine = sslCtx.getSslEngine(); sslEngine = serverSSLEngineConfigurator.createSSLEngine(); sslEngine.beginHandshake(); sslCtx.configure(sslEngine); notifyHandshakeStart(connection); if (!isHandshaking) { notifyHandshakeComplete(connection, sslEngine); final FilterChain connectionFilterChain = sslCtx.getNewConnectionFilterChain(); sslCtx.setNewConnectionFilterChain(null); if (connectionFilterChain != null) { if (LOGGER.isLoggable(Level.FINE)) {
final Allocator allocator) { output = ensureBufferSize(output, netBufferSize, allocator); updateBufferSizes(); output = ensureBufferSize(output, netBufferSize, allocator); return wrap(input, inputArray, inputArraySize, output, null); } else if (isOverflow || status == Status.BUFFER_UNDERFLOW) { return new SslResult(output, new SSLException("SSL wrap error: " + status));