users@grizzly.java.net

Re: SSL Layer

From: Oleksiy Stashok <Oleksiy.Stashok_at_Sun.COM>
Date: Fri, 14 Aug 2009 16:12:59 +0200

Hi Alaska,

pls. try to set setSkipRead(true); on your ParserProtocolFilters.
Please let me know if it helped.

WBR,
Alexey.

On Aug 14, 2009, at 15:57 , Alaska wrote:

>
> Dear Alexey,
>
> I"ve just found the mistake with the controller.
> I removed the SSLConnectorHandler, the SSLCallbackHandler and the
> line
> sslConnector.connect(new InetSocketAddress("localhost", PORT),
> callbackSSL);
>
> Now it seems that the connection was etablished...
>
> But I have a problem that I cannot get the request... The
> ParserFilter is
> not being invoked.
>
> The browser message is: Data Transfer Interrupted
> The connection to localhost:1080 was interrupted while the page was
> loading.
> The browser connected successfully, but the connection was
> interrupted while
> transferring information.
>
> Do you have an idea what is still wrong?
>
> thank you!
> alaska
>
>
> ++++++++++++++++++++++++++++++++++++++++
> The SSLConnectionTest.java looks like:
>
> package Grizzly2httpSSL;
>
>
> import
> Grizzly2httpSSL.Protocols.Http.AsciiCommandProtocolParserFilter;
> import com.sun.grizzly.Context;
> import com.sun.grizzly.Controller;
> import com.sun.grizzly.DefaultProtocolChain;
> import com.sun.grizzly.DefaultProtocolChainInstanceHandler;
> import com.sun.grizzly.IOEvent;
> import com.sun.grizzly.ProtocolChain;
> import com.sun.grizzly.ProtocolChainInstanceHandler;
> import com.sun.grizzly.ProtocolFilter;
> import com.sun.grizzly.SSLCallbackHandler;
> import com.sun.grizzly.SSLConfig;
> import com.sun.grizzly.SSLConnectorHandler;
> import com.sun.grizzly.SSLSelectorHandler;
> import com.sun.grizzly.filter.SSLReadFilter;
> import com.sun.grizzly.filter.SSLEchoFilter;
> import java.io.File;
> import java.io.IOException;
> import java.net.InetSocketAddress;
> import java.net.URL;
> import java.nio.ByteBuffer;
> import java.nio.channels.SelectionKey;
> import java.util.Arrays;
> import java.util.concurrent.CountDownLatch;
> import java.util.concurrent.TimeUnit;
> import java.util.logging.Level;
> import java.util.logging.Logger;
> import javax.net.ssl.SSLContext;
>
>
> public class SSLConnectionTest {
>
>
> String TRUST_STORE_PROP = "truststoreSSLtest.jks";
> String KEY_STORE_PROP = "serverkey.jks";
> public static final int PORT = 1080;
> public static final int PACKETS_COUNT = 10;
> public static final int CLIENTS_COUNT = 10;
> /**
> * A <code>SSLCallbackHandler</code> handler invoked by the
> TCPSelectorHandler
> * when a non blocking operation is ready to be processed.
> */
> private SSLCallbackHandler callbackHandler;
> private SSLConfig sslConfig;
>
> public void setUp() {
> sslConfig = new SSLConfig();
>
> File file = new File(TRUST_STORE_PROP);
>
> if (file != null) {
> sslConfig.setTrustStoreFile(file.getAbsolutePath());
> System.out.println("truststore file has been set");
>
> } else {
> System.out.println("Couldn't find the truststore file");
>
> }
>
> File file1 = new File(KEY_STORE_PROP);
>
>
> //the keystore will be used for encrypting/signing some thing
> with
> your private key
> // URL keystoreUrl =
> getClass().getClassLoader().getResource("serverkey.jks");
> if (file1 != null) {
> sslConfig.setKeyStoreFile(file1.getAbsolutePath());
> System.out.println("keystoreUrl file has been set");
>
> } else {
> System.out.println("Couldn't find the keystore");
>
> }
> SSLConfig.DEFAULT_CONFIG = sslConfig;
> final Controller controller =
> createSSLController(SSLConfig.DEFAULT_CONFIG.createSSLContext());
> try {
> controller.start();
> } catch (IOException ex) {
>
> Logger
> .getLogger(SSLConnectionTest.class.getName()).log(Level.SEVERE, "the
> SSL controller couldn't not been started", ex);
> }
> }
>
>
>
> private Controller createSSLController(SSLContext sslContext) {
>
>
> final SSLReadFilter readFilter = new SSLReadFilter();
> readFilter.setSSLContext(sslContext);
> readFilter.isNeedClientAuth();
>
> final ProtocolFilter asciiCommandParser = new
> AsciiCommandProtocolParserFilter();
>
> final ProtocolFilter genericProtocolFilter = new
> RequestControllerFilter();
>
> final ProtocolFilter genericDoor = new GenericDoor();
>
> SSLSelectorHandler selectorHandler = new SSLSelectorHandler();
> selectorHandler.setPort(PORT);
>
> final Controller controller = new Controller();
>
> controller.setSelectorHandler(selectorHandler);
> controller.setHandleReadWriteConcurrently(false);
>
> final ProtocolChain protocolChain = new DefaultProtocolChain();
>
> protocolChain.addFilter(readFilter);
> protocolChain.addFilter(asciiCommandParser);
> protocolChain.addFilter(genericProtocolFilter);
> protocolChain.addFilter(genericDoor);
>
> ((DefaultProtocolChain)
> protocolChain).setContinuousExecution(true);
>
>
> ProtocolChainInstanceHandler pciHandler = new
> DefaultProtocolChainInstanceHandler() {
>
> @Override
> public ProtocolChain poll() {
> return protocolChain;
> }
>
> @Override
> public boolean offer(ProtocolChain pc) {
> return false;
> }
> };
>
> controller.setProtocolChainInstanceHandler(pciHandler);
>
> controller.setReadThreadsCount(5); //
>
> return controller;
> }
>
>
> }
>
> --
> View this message in context: http://www.nabble.com/SSL-Layer-tp24954939p24972156.html
> Sent from the Grizzly - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>