spacemonkeygo/openssl — pull request #9 by Sov1et (2014-08-19 15:08:39+00:00)
Title: SNI support  rfc-6066

Add SNI support rfc-6066.
Example of usage (you need need to implement tlsCtxStorage object):

```
// callback
func sniCallback(ssl *openssl.SSL) openssl.SSLTLSExtErr {
host := ssl.GetServername()

if len(host) == 0 {
return openssl.SSLTLSEXTErrNoAck
}

// check if we are already in default host
if defaulHost, err := tlsCtxStorage.GetDefaultHost(); host == defaulHost &&
err == nil {
return openssl.SSLTLSExtErrOK
}

// get ctx
ctx, err := tlsCtxStorage.GetCtx(host);
if err != nil || ctx == nil {
return openssl.SSLTLSEXTErrNoAck
}
logger.Debugf("Changed context for: %s.", host)

// set proper ctx
ssl.SetSSLCtx(ctx)

/*
* SSL_set_SSL_CTX() only changes certs as of 1.0.0d
* adjust other things we care about
*/

ssl.SetVerify(ctx.VerifyMode(), ctx.GetVerifyCallback())
ssl.SetVerifyDepth(ctx.GetVerifyDepth())

ssl.ClearOptions(ssl.GetOptions() &^ ctx.GetOptions())
ssl.SetOptions(ctx.GetOptions())

return openssl.SSLTLSExtErrOK
}
```