File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -113,11 +113,36 @@ connection_closure_free(struct connection_closure *closure)
113113 relay_closure_free (closure -> relay_closure );
114114#if defined(HAVE_OPENSSL )
115115 if (closure -> ssl != NULL ) {
116+ const char * errstr ;
117+ int result ;
118+
116119 /* Must call SSL_shutdown() before closing closure->sock. */
117120 sudo_debug_printf (SUDO_DEBUG_INFO |SUDO_DEBUG_LINENO ,
118121 "closing down TLS connection from %s" , closure -> ipaddr );
119- if (SSL_shutdown (closure -> ssl ) == 0 )
122+ result = SSL_shutdown (closure -> ssl );
123+ switch (result ) {
124+ case 0 :
125+ /* SSL_shutdown did not finish, must call it again */
126+ sudo_debug_printf (SUDO_DEBUG_NOTICE |SUDO_DEBUG_LINENO ,
127+ "retrying SSL_shutdown" );
120128 SSL_shutdown (closure -> ssl );
129+ break ;
130+ case 1 :
131+ /* success */
132+ break ;
133+ default :
134+ /* error */
135+ switch (SSL_get_error (closure -> ssl , result )) {
136+ case SSL_ERROR_SYSCALL :
137+ sudo_warn ("%s: SSL_shutdown" , closure -> ipaddr );
138+ break ;
139+ default :
140+ errstr = ERR_reason_error_string (ERR_get_error ());
141+ sudo_warnx ("%s: SSL_shutdown: %s" , closure -> ipaddr ,
142+ errstr ? errstr : strerror (errno ));
143+ break ;
144+ }
145+ }
121146 SSL_free (closure -> ssl );
122147 }
123148 free (closure -> name );
You can’t perform that action at this time.
0 commit comments