From 9e67ffde41385aba33c57384cbbc19b6962ac348 Mon Sep 17 00:00:00 2001 From: fangdingjun Date: Thu, 19 Jul 2018 10:38:37 +0800 Subject: [PATCH] set TLS for server/client --- callbacks.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/callbacks.go b/callbacks.go index d09fedc..4544730 100644 --- a/callbacks.go +++ b/callbacks.go @@ -121,6 +121,10 @@ func onBeginHeaderCallback(ptr unsafe.Pointer, streamID C.int) C.int { //log.Printf("stream %d begin headers", int(streamID)) conn := (*Conn)(unsafe.Pointer(uintptr(ptr))) + var TLS tls.ConnectionState + if tlsconn, ok := conn.conn.(*tls.Conn); ok { + TLS = tlsconn.ConnectionState() + } // client if !conn.isServer { s, ok := conn.streams[int(streamID)] @@ -128,10 +132,6 @@ func onBeginHeaderCallback(ptr unsafe.Pointer, streamID C.int) C.int { //log.Println("onBeginHeaderCallback end") return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE } - var TLS tls.ConnectionState - if tlsconn, ok := conn.conn.(*tls.Conn); ok { - TLS = tlsconn.ConnectionState() - } s.response = &http.Response{ Proto: "HTTP/2", ProtoMajor: 2, @@ -156,6 +156,7 @@ func onBeginHeaderCallback(ptr unsafe.Pointer, streamID C.int) C.int { Proto: "HTTP/2", ProtoMajor: 2, ProtoMinor: 0, + TLS: &TLS, }, } s.request.Body = s.bp