Skip to content

Commit

Permalink
Support session reuse
Browse files Browse the repository at this point in the history
  • Loading branch information
ZBCccc authored and dongbeiouba committed Sep 30, 2024
1 parent 948175b commit 0142839
Show file tree
Hide file tree
Showing 2 changed files with 215 additions and 134 deletions.
11 changes: 9 additions & 2 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -615,8 +615,15 @@ func (c *Conn) setSession(session []byte) error {
runtime.LockOSThread()
defer runtime.UnlockOSThread()

ptr := (*C.uchar)(&session[0])
s := C.d2i_SSL_SESSION(nil, &ptr, C.long(len(session)))
if len(session) == 0 {
return fmt.Errorf("session is empty")
}

cSession := C.CBytes(session)
defer C.free(unsafe.Pointer(cSession))

ptr := (*C.uchar)(cSession)
s := C.d2i_SSL_SESSION(nil, (**C.uchar)(&ptr), C.long(len(session)))
if s == nil {
return fmt.Errorf("unable to load session: %s", crypto.ErrorFromErrorQueue())
}
Expand Down
Loading

0 comments on commit 0142839

Please sign in to comment.