Ejemplo n.º 1
0
func (self *SSL) Shutdown() error {
	//shutdown should happen in 2 steps
	//see http://www.openssl.org/docs/ssl/SSL_shutdown.html
	defer self.Free()
	ret := C.SSL_shutdown(self.SSL)
	if int(ret) == 0 {
		ret = C.SSL_shutdown(self.SSL)
		if int(ret) != 1 {
			return self.getError(ret)
		}

	}
	return nil

}
Ejemplo n.º 2
0
func (c *Conn) shutdown() func() error {
	c.mtx.Lock()
	defer c.mtx.Unlock()
	runtime.LockOSThread()
	defer runtime.UnlockOSThread()
	rv, errno := C.SSL_shutdown(c.ssl)
	if rv > 0 {
		return nil
	}
	if rv == 0 {
		// The OpenSSL docs say that in this case, the shutdown is not
		// finished, and we should call SSL_shutdown() a second time, if a
		// bidirectional shutdown is going to be performed. Further, the
		// output of SSL_get_error may be misleading, as an erroneous
		// SSL_ERROR_SYSCALL may be flagged even though no error occurred.
		// So, TODO: revisit bidrectional shutdown, possibly trying again.
		// Note: some broken clients won't engage in bidirectional shutdown
		// without tickling them to close by sending a TCP_FIN packet, or
		// shutting down the write-side of the connection.
		return nil
	} else {
		return c.getErrorHandler(rv, errno)
	}
}