Skip to content

Commit 64a7adc

Browse files
committed
Merge pull request #3 from thepaul/master
use CString with SetTlsExtHostName
2 parents 1738273 + 8db626a commit 64a7adc

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

conn.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package openssl
1818

19+
// #include <stdlib.h>
1920
// #include <openssl/ssl.h>
2021
// #include <openssl/conf.h>
2122
// #include <openssl/err.h>
@@ -490,8 +491,8 @@ func (c *Conn) UnderlyingConn() net.Conn {
490491
}
491492

492493
func (c *Conn) SetTlsExtHostName(name string) error {
493-
bname := []byte(name)
494-
cname := (*C.char)(unsafe.Pointer(&bname[0]))
494+
cname := C.CString(name)
495+
defer C.free(unsafe.Pointer(cname))
495496
runtime.LockOSThread()
496497
defer runtime.UnlockOSThread()
497498
if C.SSL_set_tlsext_host_name_not_a_macro(c.ssl, cname) == 0 {

0 commit comments

Comments
 (0)