TLS Server Name Indication(SNI) support (reworked)

This patch added support for SNI detection. Now your Netty server could host multiple certificates and serve client with proper one. 

Usage:

``` java

// application wide
SniHandler.Builder builder = new SniHandler.Builder();

builder.addContext("*.avoscloud.com", sslcontext1)
  .addContext("*.leancloud.cn", sslcontext2)
  .defaultContext(sslcontext1);

// in the ChannelInitializer

pipeline.addLast(builder.build());

```

This handler detects SNI extension, then adds proper SslHandler to the pipeline. 

In Java 8 SNI is supported in JDK, but this handler is going to enable SNI support for all Java versions.

You may check #3020 for previous discussions.
Yes

> Am 03.12.2014 um 03:52 schrieb Ning Sun <notifications@github.com>:
> 
> In handler/src/main/java/io/netty/handler/ssl/SniHandler.java:
> 
> > +                this.hostname = DomainNameMapping.normalizeHostname(hostname);
> > +            }
> > +
> > +            // the mapping will return default context when this.hostname is null
> > +            selectedContext = mapping.map(this.hostname);
> > +        }
> > +
> > +        if (handshaken) {
> > +            SslHandler sslHandler = selectedContext.newHandler(ctx.alloc());
> > +            ctx.pipeline().replace(this, SslHandler.class.getName(), sslHandler);
> > +        }
> > +    }
> > +
> > +    private String getSNIHostNameFromHandshakeInfo(ByteBuf in) {
> > +        try {
> > +            int command = in.getUnsignedByte(0);
> Counting from in.readerIndex() is definitely better practice. But since SSL handshake happens on very beginning of a connection, is there chance that it doesn't start at 0?
> 
> —
> Reply to this email directly or view it on GitHub.
>