diff --git a/ctx.go b/ctx.go old mode 100644 new mode 100755 index 6afa5374..dc800c2e --- a/ctx.go +++ b/ctx.go @@ -74,23 +74,23 @@ static long SSL_CTX_set_tlsext_servername_callback_not_a_macro(SSL_CTX* ctx, voi return SSL_CTX_set_tlsext_servername_callback(ctx, fp); } -typedef struct TlsServernameData { +typedef struct TlsExtData { void *go_ctx; SSL_CTX *ctx; void *arg; -} TlsServernameData; +} TlsExtData; -extern int callServerNameCb(SSL* ssl, int ad, void* arg); +extern int callServernameCb(SSL* ssl, int ad, void* arg); static int call_go_servername(SSL* ssl, int ad, void* arg) { - return callServerNameCb(ssl, ad, arg); + return callServernameCb(ssl, ad, arg); } -static int servername_gateway(TlsServernameData* cw) { +static int servername_gateway(TlsExtData* cw) { SSL_CTX* ctx = cw->ctx; //TODO: figure out what to do with return codes. The first isn't 0 SSL_CTX_set_tlsext_servername_callback(ctx, call_go_servername); - SSL_CTX_set_tlsext_servername_arg(ctx, cw); + SSL_CTX_set_tlsext_servername_arg(ctx, cw.arg); return 0; } @@ -141,13 +141,13 @@ var ( ) type Ctx struct { - ctx *C.SSL_CTX - cert *Certificate - chain []*Certificate - key PrivateKey - verify_cb VerifyCallback - servername_cb ServerNameCallback - ted C.TlsServernameData + ctx *C.SSL_CTX + cert *Certificate + chain []*Certificate + key PrivateKey + verify_cb VerifyCallback + //servername_cb ServerNameCallback + servername_cb func(ssl Conn, ad int, arg unsafe.Pointer) int } //export get_ssl_ctx_idx @@ -634,11 +634,11 @@ func (c *Ctx) SessGetCacheSize() int { // Set SSL_CTX_set_tlsext_servername_callback // https://www.openssl.org/docs/manmaster/ssl/??? -type ServerNameCallback func(ssl Conn, ad int, arg unsafe.Pointer) int +//type ServerNameCallback func(ssl *C.SSL, ad C.int, arg unsafe.Pointer) int -//export callServerNameCb -func callServerNameCb(ssl *C.SSL, ad C.int, arg unsafe.Pointer) C.int { - var ted *C.TlsServernameData = (*C.TlsServernameData)(arg) +//export callServernameCb +func callServernameCb(ssl *C.SSL, ad C.int, arg unsafe.Pointer) C.int { + var ted *C.TlsExtData = (*C.TlsExtData)(arg) goCtx := (*Ctx)(ted.go_ctx) //setup a dummy Conn so we can associate a SSL_CTX from user callback @@ -650,13 +650,13 @@ func callServerNameCb(ssl *C.SSL, ad C.int, arg unsafe.Pointer) C.int { return C.int(ret) } -func (c *Ctx) SetTlsExtServerNameCallback(cb func(ssl Conn, ad int, arg unsafe.Pointer) int, - arg unsafe.Pointer) int { +//func (c *Ctx) SetTlsExtServerNameCallback(cb ServerNameCallback) int { +func (c *Ctx) SetTlsExtServerNameCallback(cb func(ssl Conn, ad int, arg unsafe.Pointer) int, arg unsafe.Pointer) int { c.servername_cb = cb - c.ted = C.TlsServernameData{ + cw := C.TlsExtData{ go_ctx: unsafe.Pointer(c), ctx: c.ctx, arg: arg, } - return int(C.servername_gateway(&c.ted)) + return int(C.servername_gateway(&cw)) }