mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-10 17:35:59 +00:00
dtls: Properly display all errors/warnings from ERR queue
Print out all errors from the OpenSSL error queue instead of just looking at the topmost error. Using the callback interface also removes the need for formatting using a buffer on the stack.
This commit is contained in:
parent
7bb6ce352b
commit
51f0307900
2 changed files with 32 additions and 9 deletions
|
@ -164,6 +164,14 @@ gst_dtls_agent_class_init (GstDtlsAgentClass * klass)
|
|||
_gst_dtls_init_openssl ();
|
||||
}
|
||||
|
||||
static int
|
||||
ssl_warn_cb (const char *str, size_t len, void *u)
|
||||
{
|
||||
GstDtlsAgent *self = u;
|
||||
GST_WARNING_OBJECT (self, "ssl error: %s", str);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_dtls_agent_init (GstDtlsAgent * self)
|
||||
{
|
||||
|
@ -178,12 +186,10 @@ gst_dtls_agent_init (GstDtlsAgent * self)
|
|||
priv->ssl_context = SSL_CTX_new (DTLSv1_method ());
|
||||
#endif
|
||||
if (ERR_peek_error () || !priv->ssl_context) {
|
||||
char buf[512];
|
||||
|
||||
priv->ssl_context = NULL;
|
||||
|
||||
GST_WARNING_OBJECT (self, "Error creating SSL Context: %s",
|
||||
ERR_error_string (ERR_get_error (), buf));
|
||||
GST_WARNING_OBJECT (self, "Error creating SSL Context");
|
||||
ERR_print_errors_cb (ssl_warn_cb, self);
|
||||
|
||||
g_return_if_reached ();
|
||||
}
|
||||
|
|
|
@ -707,11 +707,26 @@ beach:
|
|||
self->priv->keys_exported = TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
ssl_warn_cb (const char *str, size_t len, void *u)
|
||||
{
|
||||
GstDtlsConnection *self = u;
|
||||
GST_WARNING_OBJECT (self, "ssl error: %s", str);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
ssl_err_cb (const char *str, size_t len, void *u)
|
||||
{
|
||||
GstDtlsConnection *self = u;
|
||||
GST_ERROR_OBJECT (self, "ssl error: %s", str);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
openssl_poll (GstDtlsConnection * self)
|
||||
{
|
||||
int ret;
|
||||
char buf[512];
|
||||
int error;
|
||||
|
||||
log_state (self, "poll: before handshake");
|
||||
|
@ -748,9 +763,9 @@ openssl_poll (GstDtlsConnection * self)
|
|||
GST_WARNING_OBJECT (self, "no error, handshake should be done");
|
||||
break;
|
||||
case SSL_ERROR_SSL:
|
||||
GST_LOG_OBJECT (self, "SSL error %d: %s", error,
|
||||
ERR_error_string (ERR_get_error (), buf));
|
||||
break;
|
||||
GST_ERROR_OBJECT (self, "SSL error");
|
||||
ERR_print_errors_cb (ssl_err_cb, self);
|
||||
return;
|
||||
case SSL_ERROR_WANT_READ:
|
||||
GST_LOG_OBJECT (self, "SSL wants read");
|
||||
break;
|
||||
|
@ -758,12 +773,14 @@ openssl_poll (GstDtlsConnection * self)
|
|||
GST_LOG_OBJECT (self, "SSL wants write");
|
||||
break;
|
||||
case SSL_ERROR_SYSCALL:{
|
||||
GST_LOG_OBJECT (self, "SSL syscall (error) : %lu", ERR_get_error ());
|
||||
GST_LOG_OBJECT (self, "SSL syscall error");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
GST_WARNING_OBJECT (self, "Unknown SSL error: %d, ret: %d", error, ret);
|
||||
}
|
||||
|
||||
ERR_print_errors_cb (ssl_warn_cb, self);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
Loading…
Reference in a new issue