Skip to content

Commit 512a61b

Browse files
committed
Report SSL error messages from serf
Add the most detailed underlying crypto library error string to the error stack when the context fails due to an SSL failure. SSL errors are no longer reduced to "an error has occurred". This relies on the serf_ssl_error_cb_t callback as provided by serf in apache/serf#9. Example: [minfrin@rocky9 subversion]$ svn info https://svn.example.com/svn/example/core/ svn: E170013: Unable to connect to a repository at URL 'https://svn.example.com/svn/example/core' svn: E120171: TLS: error:0308010C:digital envelope routines::unsupported svn: E120171: Error running context: An error occurred during SSL communication
1 parent ff9317a commit 512a61b

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

build/ac-macros/serf.m4

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@ AC_DEFUN(SVN_LIB_SERF,
8989
9090
svn_lib_serf=$serf_found
9191
92+
if test "$svn_lib_serf" = "yes"; then
93+
save_ldflags="$LDFLAGS"
94+
LDFLAGS="$LDFLAGS $SVN_SERF_LIBS"
95+
AC_CHECK_FUNCS(serf_ssl_error_cb_set)
96+
LDFLAGS="$save_ldflags"
97+
fi
98+
9299
SVN_DOT_CLANGD([$SVN_SERF_INCLUDES])
93100
AC_SUBST(SVN_SERF_INCLUDES)
94101
AC_SUBST(SVN_SERF_LIBS)

subversion/libsvn_ra_serf/ra_serf.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ struct svn_ra_serf__session_t {
113113
/* Are we using ssl */
114114
svn_boolean_t using_ssl;
115115

116+
/* What was the underlying detail of the last SSL failure, if any */
117+
const char *ssl_error;
118+
116119
/* Tristate flag that indicates if we should use compression for
117120
network transmissions. If svn_tristate_true or svn_tristate_false,
118121
the compression should be enabled and disabled, respectively.

subversion/libsvn_ra_serf/util.c

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,20 @@ ssl_server_cert_cb(void *baton, int failures,
451451
return save_error(session, err);
452452
}
453453

454+
#if defined(HAVE_SERF_SSL_ERROR_CB_SET)
455+
static apr_status_t
456+
ssl_error_cb(void *baton,
457+
const char *message)
458+
{
459+
svn_ra_serf__connection_t *conn = baton;
460+
svn_ra_serf__session_t *session = conn->session;
461+
462+
session->ssl_error = apr_pstrdup(session->pool, message);
463+
464+
return APR_SUCCESS;
465+
}
466+
#endif
467+
454468
static svn_error_t *
455469
load_authorities(svn_ra_serf__connection_t *conn, const char *authorities,
456470
apr_pool_t *pool)
@@ -567,7 +581,14 @@ conn_setup(apr_socket_t *sock,
567581
SERF_CONNECTION_FRAMING_TYPE_NONE);
568582
}
569583
#endif
570-
}
584+
585+
#if defined(HAVE_SERF_SSL_ERROR_CB_SET)
586+
serf_ssl_error_cb_set(conn->ssl_context,
587+
ssl_error_cb,
588+
conn);
589+
#endif
590+
591+
}
571592

572593
if (write_bkt)
573594
{
@@ -958,7 +979,17 @@ svn_ra_serf__context_run(svn_ra_serf__session_t *sess,
958979
_("Error running context"));
959980
}
960981

961-
return svn_ra_serf__wrap_err(status, _("Error running context"));
982+
if (sess->ssl_error)
983+
{
984+
return svn_error_createf(status,
985+
svn_ra_serf__wrap_err(status, _("Error running context")),
986+
_("TLS: %s"),
987+
sess->ssl_error);
988+
}
989+
else
990+
{
991+
return svn_ra_serf__wrap_err(status, _("Error running context"));
992+
}
962993
}
963994

964995
return SVN_NO_ERROR;

0 commit comments

Comments
 (0)