mirror of
https://github.com/libp2p/go-openssl.git
synced 2024-12-27 23:40:18 +08:00
use CString with SetTlsExtHostName
i guess we can't rely on there being a null byte after the memory for a byte array. in retrospect it seems really stupid to think there would be. go me Change-Id: I35ab6704cefbfbde064906aa682985574cb7e034
This commit is contained in:
parent
1738273569
commit
8db626a560
5
conn.go
5
conn.go
@ -16,6 +16,7 @@
|
||||
|
||||
package openssl
|
||||
|
||||
// #include <stdlib.h>
|
||||
// #include <openssl/ssl.h>
|
||||
// #include <openssl/conf.h>
|
||||
// #include <openssl/err.h>
|
||||
@ -490,8 +491,8 @@ func (c *Conn) UnderlyingConn() net.Conn {
|
||||
}
|
||||
|
||||
func (c *Conn) SetTlsExtHostName(name string) error {
|
||||
bname := []byte(name)
|
||||
cname := (*C.char)(unsafe.Pointer(&bname[0]))
|
||||
cname := C.CString(name)
|
||||
defer C.free(unsafe.Pointer(cname))
|
||||
runtime.LockOSThread()
|
||||
defer runtime.UnlockOSThread()
|
||||
if C.SSL_set_tlsext_host_name_not_a_macro(c.ssl, cname) == 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user