diff mbox series

[v1,7/8] channel_curl: add separate error codes for SSL

Message ID 20211015082457.6804-8-roland.gaudig-oss@weidmueller.com
State Changes Requested
Headers show
Series suricatta: ipc: add request to get hawkBit server status | expand

Commit Message

Roland Gaudig Oct. 15, 2021, 8:24 a.m. UTC
From: Roland Gaudig <roland.gaudig@weidmueller.com>

SSL connection errors were mapped to CHANNEL_ENONET error code, which
makes finding the cause of an error difficult. Therefore, errors
regarding SSL handshake or certificate problems are separated now from
other network problems.

Signed-off-by: Roland Gaudig <roland.gaudig@weidmueller.com>
---

 corelib/channel_curl.c   | 12 +++++++-----
 include/channel_op_res.h |  4 +++-
 suricatta/common.c       |  2 ++
 3 files changed, 12 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c
index fba773b..5140ef4 100644
--- a/corelib/channel_curl.c
+++ b/corelib/channel_curl.c
@@ -375,11 +375,6 @@  channel_op_res_t channel_map_curl_error(CURLcode res)
 	case CURLE_COULDNT_RESOLVE_HOST:
 	case CURLE_COULDNT_CONNECT:
 	case CURLE_INTERFACE_FAILED:
-	case CURLE_SSL_CONNECT_ERROR:
-	case CURLE_PEER_FAILED_VERIFICATION:
-#if LIBCURL_VERSION_NUM < 0x073E00
-	case CURLE_SSL_CACERT:
-#endif
 	case CURLE_USE_SSL_FAILED:
 		return CHANNEL_ENONET;
 	case CURLE_OPERATION_TIMEDOUT:
@@ -408,6 +403,13 @@  channel_op_res_t channel_map_curl_error(CURLcode res)
 	case CURLE_REMOTE_ACCESS_DENIED:
 	case CURLE_LOGIN_DENIED:
 		return CHANNEL_EACCES;
+	case CURLE_PEER_FAILED_VERIFICATION:
+#if LIBCURL_VERSION_NUM < 0x073E00
+	case CURLE_SSL_CACERT:
+#endif
+		return CHANNEL_ESSLCERT;
+	case CURLE_SSL_CONNECT_ERROR:
+		return CHANNEL_ESSLCONNECT;
 	case CURLE_OK:
 		return CHANNEL_OK;
 	default:
diff --git a/include/channel_op_res.h b/include/channel_op_res.h
index 7c883b9..104ce32 100644
--- a/include/channel_op_res.h
+++ b/include/channel_op_res.h
@@ -23,5 +23,7 @@  typedef enum {
 	CHANNEL_ELOOP,
 	CHANNEL_EBADMSG,
 	CHANNEL_ENOTFOUND,
-	CHANNEL_EREDIRECT
+	CHANNEL_EREDIRECT,
+	CHANNEL_ESSLCERT,
+	CHANNEL_ESSLCONNECT
 } channel_op_res_t;
diff --git a/suricatta/common.c b/suricatta/common.c
index 71aa2df..3a9ac60 100644
--- a/suricatta/common.c
+++ b/suricatta/common.c
@@ -56,6 +56,8 @@  server_op_res_t map_channel_retcode(channel_op_res_t response)
 	switch (response) {
 	case CHANNEL_ENONET:
 	case CHANNEL_EAGAIN:
+	case CHANNEL_ESSLCERT:
+	case CHANNEL_ESSLCONNECT:
 		return SERVER_EAGAIN;
 	case CHANNEL_EACCES:
 		return SERVER_EACCES;