private boolean establishConnectTunnel(final ProxyServer proxy, final HttpTransactionContext httpCtx, final Uri uri, final FilterChainContext ctx) throws IOException { final Connection connection = ctx.getConnection(); final HttpRequestPacket requestPacket = HttpRequestPacket.builder() .protocol(Protocol.HTTP_1_0) .method(Method.CONNECT) .uri(AsyncHttpProviderUtils.getAuthority(uri)) .build(); setupKeepAlive(requestPacket, connection); httpCtx.establishingTunnel = true; final Request request = httpCtx.getAhcRequest(); addHostHeaderIfNeeded(request, uri, requestPacket); addServiceHeaders(requestPacket); final Realm realm = getRealm(request); addAuthorizationHeader(request, requestPacket, realm, uri, proxy, false); addProxyHeaders(request, requestPacket, realm, proxy, false, true); // turn off SSL, because CONNECT will be sent in plain mode ctx.notifyDownstream(new SSLSwitchingEvent(connection, false)); return sendRequest(httpCtx, ctx, requestPacket, null); }
@Override public NextAction handleEvent(final FilterChainContext ctx, final FilterChainEvent event) throws IOException { if (event.type() == SSLSwitchingEvent.class) { final SSLSwitchingEvent se = (SSLSwitchingEvent) event; final boolean isSecure = se.isSecure(); CONNECTION_IS_SECURE.set(se.getConnection(), isSecure); // if enabling security - create SSLEngine here, because default // Grizzly SSLFilter will use host/port info from the Connection, rather // than request URL. Specifically this doesn't work with CONNECT tunnels. if (isSecure && SSLUtils.getSSLEngine(ctx.getConnection()) == null) { // if SSLEngine is not yet set for the connection - initialize it final SSLEngine sslEngine = getClientSSLEngineConfigurator() .createSSLEngine(se.getHost(), se.getPort() == -1 ? 443 : se.getPort() ); sslEngine.beginHandshake(); SSLUtils.setSSLEngine(ctx.getConnection(), sslEngine); } return ctx.getStopAction(); } return ctx.getInvokeAction(); }
@Override public NextAction handleEvent(final FilterChainContext ctx, final FilterChainEvent event) throws IOException { if (event.type() == SSLSwitchingEvent.class) { final SSLSwitchingEvent se = (SSLSwitchingEvent) event; final boolean isSecure = se.isSecure(); CONNECTION_IS_SECURE.set(se.getConnection(), isSecure); // if enabling security - create SSLEngine here, because default // Grizzly SSLFilter will use host/port info from the Connection, rather // than request URL. Specifically this doesn't work with CONNECT tunnels. if (isSecure && SSLUtils.getSSLEngine(ctx.getConnection()) == null) { // if SSLEngine is not yet set for the connection - initialize it final SSLEngine sslEngine = getClientSSLEngineConfigurator() .createSSLEngine(se.getHost(), se.getPort() == -1 ? 443 : se.getPort() ); sslEngine.beginHandshake(); SSLUtils.setSSLEngine(ctx.getConnection(), sslEngine); } return ctx.getStopAction(); } return ctx.getInvokeAction(); }
ctx.notifyDownstream(new SSLSwitchingEvent(connection, secure, uri.getHost(), uri.getPort()));
@Override public NextAction handleEvent(final FilterChainContext ctx, final FilterChainEvent event) throws IOException { if (event.type() == SSLSwitchingEvent.class) { final SSLSwitchingEvent se = (SSLSwitchingEvent) event; final boolean isSecure = se.isSecure(); CONNECTION_IS_SECURE.set(se.getConnection(), isSecure); // if enabling security - create SSLEngine here, because default // Grizzly SSLFilter will use host/port info from the Connection, rather // than request URL. Specifically this doesn't work with CONNECT tunnels. if (isSecure && SSLUtils.getSSLEngine(ctx.getConnection()) == null) { // if SSLEngine is not yet set for the connection - initialize it final SSLEngine sslEngine = getClientSSLEngineConfigurator() .createSSLEngine(se.getHost(), se.getPort() == -1 ? 443 : se.getPort() ); sslEngine.beginHandshake(); SSLUtils.setSSLEngine(ctx.getConnection(), sslEngine); } return ctx.getStopAction(); } return ctx.getInvokeAction(); }
private boolean establishConnectTunnel(final ProxyServer proxy, final HttpTransactionContext httpCtx, final Uri uri, final FilterChainContext ctx) throws IOException { final Connection connection = ctx.getConnection(); final HttpRequestPacket requestPacket = HttpRequestPacket.builder() .protocol(Protocol.HTTP_1_0) .method(Method.CONNECT) .uri(AsyncHttpProviderUtils.getAuthority(uri)) .build(); setupKeepAlive(requestPacket, connection); httpCtx.establishingTunnel = true; final Request request = httpCtx.getAhcRequest(); addHostHeaderIfNeeded(request, uri, requestPacket); addServiceHeaders(requestPacket); final Realm realm = getRealm(request); addProxyHeaders(request, requestPacket, realm, proxy, false, true); // turn off SSL, because CONNECT will be sent in plain mode ctx.notifyDownstream(new SSLSwitchingEvent(connection, false)); return sendRequest(httpCtx, ctx, requestPacket, null); }
private boolean establishConnectTunnel(final ProxyServer proxy, final HttpTransactionContext httpCtx, final Uri uri, final FilterChainContext ctx) throws IOException { final Connection connection = ctx.getConnection(); final HttpRequestPacket requestPacket = HttpRequestPacket.builder() .protocol(Protocol.HTTP_1_0) .method(Method.CONNECT) .uri(AsyncHttpProviderUtils.getAuthority(uri)) .build(); setupKeepAlive(requestPacket, connection); httpCtx.establishingTunnel = true; final Request request = httpCtx.getAhcRequest(); addHostHeaderIfNeeded(request, uri, requestPacket); addServiceHeaders(requestPacket); final Realm realm = getRealm(request); addProxyHeaders(request, requestPacket, realm, proxy, false, true); // turn off SSL, because CONNECT will be sent in plain mode ctx.notifyDownstream(new SSLSwitchingEvent(connection, false)); return sendRequest(httpCtx, ctx, requestPacket, null); }
ctx.notifyDownstream(new SSLSwitchingEvent(connection, secure, uri.getHost(), uri.getPort()));
ctx.notifyDownstream(new SSLSwitchingEvent(connection, secure, uri.getHost(), uri.getPort()));