You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Sungwon Jung <th...@gmail.com> on 2007/09/04 12:47:36 UTC

ssl and normal socket in one server

Hello. I'm develop server with Mina 1.1.2.

I'm using normal socket but I want ssl also.

so, I opened two port.
one is normal socket port and the other is ssl port.
so I think... server make two SocketAcceptorConfig like below.

am i going well?

--below--
[Server.java]

SocketAcceptorConfig cfg = new SocketAcceptorConfig();
SocketAcceptorConfig cfg_ssl = new SocketAcceptorConfig();
cfg.setReuseAddress( true );
cfg_ssl.setReuseAddress( true );

cfg.getFilterChain().addLast( "codec", new ProtocolCodecFilter( new
ServerCodecFactory() );
cfg_ssl.getFilterChain().addLast( "codec_ssl", new
ProtocolCodecFilter( new ServerCodecFactorySSL() );

acceptor.bind( new InetSocketAddress( 9009 ), new ServerSessionHandler(), cfg );
acceptor.bind( new InetSocketAddress( 9010 ), new ServerSessionHandler(), cfg );
--end--

Re: ssl and normal socket in one server

Posted by Sungwon Jung <th...@gmail.com>.
Thanks Maarten Bosteels!

many kind of devices will connect to my server.

my company devices use normal socket with A protocol,
but other company device use ssl with B protocol.

device1 <-- A protocol --> server <-- B protocol --> other company device
device2 <-- A protocol -->
device3 <-- A protocol -->

I think, if I use one ProtocolCodecFilter, ProtocolCodecFilter code
will be big and crowded. so I make two ProtocolCodecFilter.

I refer to Echo server source in Mina site.
but I don't know how can I apply ssl in my server.
because of I don't know about ssl programming. :-(
deadline is comming.... reamin time is short. :-((

thanks Maarten Bosteels.


On 9/4/07, Maarten Bosteels <mb...@gmail.com> wrote:
> Hello Sungwon,
>
> I think that will work.
> But why don't  you use the same ProtocolCodecFilter instance for both
> acceptors ?
> And you could also share one IoHandler instance.
>
> Maarten
>
>
> On 9/4/07, Sungwon Jung <th...@gmail.com> wrote:
> >
> > Hello. I'm develop server with Mina 1.1.2.
> >
> > I'm using normal socket but I want ssl also.
> >
> > so, I opened two port.
> > one is normal socket port and the other is ssl port.
> > so I think... server make two SocketAcceptorConfig like below.
> >
> > am i going well?
> >
> > --below--
> > [Server.java]
> >
> > SocketAcceptorConfig cfg = new SocketAcceptorConfig();
> > SocketAcceptorConfig cfg_ssl = new SocketAcceptorConfig();
> > cfg.setReuseAddress( true );
> > cfg_ssl.setReuseAddress( true );
> >
> > cfg.getFilterChain().addLast( "codec", new ProtocolCodecFilter( new
> > ServerCodecFactory() );
> > cfg_ssl.getFilterChain().addLast( "codec_ssl", new
> > ProtocolCodecFilter( new ServerCodecFactorySSL() );
> >
> > acceptor.bind( new InetSocketAddress( 9009 ), new ServerSessionHandler(),
> > cfg );
> > acceptor.bind( new InetSocketAddress( 9010 ), new ServerSessionHandler(),
> > cfg );
> > --end--

Re: ssl and normal socket in one server

Posted by Maarten Bosteels <mb...@gmail.com>.
Hello Sungwon,

I think that will work.
But why don't  you use the same ProtocolCodecFilter instance for both
acceptors ?
And you could also share one IoHandler instance.

Maarten


On 9/4/07, Sungwon Jung <th...@gmail.com> wrote:
>
> Hello. I'm develop server with Mina 1.1.2.
>
> I'm using normal socket but I want ssl also.
>
> so, I opened two port.
> one is normal socket port and the other is ssl port.
> so I think... server make two SocketAcceptorConfig like below.
>
> am i going well?
>
> --below--
> [Server.java]
>
> SocketAcceptorConfig cfg = new SocketAcceptorConfig();
> SocketAcceptorConfig cfg_ssl = new SocketAcceptorConfig();
> cfg.setReuseAddress( true );
> cfg_ssl.setReuseAddress( true );
>
> cfg.getFilterChain().addLast( "codec", new ProtocolCodecFilter( new
> ServerCodecFactory() );
> cfg_ssl.getFilterChain().addLast( "codec_ssl", new
> ProtocolCodecFilter( new ServerCodecFactorySSL() );
>
> acceptor.bind( new InetSocketAddress( 9009 ), new ServerSessionHandler(),
> cfg );
> acceptor.bind( new InetSocketAddress( 9010 ), new ServerSessionHandler(),
> cfg );
> --end--
>