]> git.sesse.net Git - cubemap/blobdiff - log.cpp
Add server-side TLS support, through kTLS.
[cubemap] / log.cpp
diff --git a/log.cpp b/log.cpp
index 409639fed7fa02e913b7024db82c6a92a8ca9f3a..417b544974d30754103bcb2640d0dce6c600f116 100644 (file)
--- a/log.cpp
+++ b/log.cpp
@@ -9,6 +9,8 @@
 #include <string>
 #include <vector>
 
+#include "tlse.h"
+
 #include "log.h"
 
 using namespace std;
@@ -126,3 +128,66 @@ void log_perror(const char *msg)
        char errbuf[4096];
        log(ERROR, "%s: %s", msg, strerror_r(errno, errbuf, sizeof(errbuf)));
 }
+
+void log_tls_error(const char *msg, int tls_err)
+{
+       switch (tls_err) {
+       case TLS_NEED_MORE_DATA:
+               log(ERROR, "%s: Need more data (TLS)", msg);
+               break;
+       case TLS_GENERIC_ERROR:
+               log(ERROR, "%s: Generic TLS error", msg);
+               break;
+       case TLS_BROKEN_PACKET:
+               log(ERROR, "%s: Broken TLS packet", msg);
+               break;
+       case TLS_NOT_UNDERSTOOD:
+               log(ERROR, "%s: Not understood (TLS)", msg);
+               break;
+       case TLS_NOT_SAFE:
+               log(ERROR, "%s: Not safe (TLS)", msg);
+               break;
+       case TLS_NO_COMMON_CIPHER:
+               log(ERROR, "%s: No common TLS cipher", msg);
+               break;
+       case TLS_UNEXPECTED_MESSAGE:
+               log(ERROR, "%s: Unexpected TLS message", msg);
+               break;
+       case TLS_CLOSE_CONNECTION:
+               log(ERROR, "%s: Close TLS connection", msg);
+               break;
+       case TLS_COMPRESSION_NOT_SUPPORTED:
+               log(ERROR, "%s: TLS compression not supported", msg);
+               break;
+       case TLS_NO_MEMORY:
+               log(ERROR, "%s: No TLS memory", msg);
+               break;
+       case TLS_NOT_VERIFIED:
+               log(ERROR, "%s: Not verified (TLS)", msg);
+               break;
+       case TLS_INTEGRITY_FAILED:
+               log(ERROR, "%s: TLS integrity failed", msg);
+               break;
+       case TLS_ERROR_ALERT:
+               log(ERROR, "%s: TLS alert", msg);
+               break;
+       case TLS_BROKEN_CONNECTION:
+               log(ERROR, "%s: Broken TLS connection", msg);
+               break;
+       case TLS_BAD_CERTIFICATE:
+               log(ERROR, "%s: Bad TLS certificate", msg);
+               break;
+       case TLS_UNSUPPORTED_CERTIFICATE:
+               log(ERROR, "%s: Unsupported TLS certificate", msg);
+               break;
+       case TLS_NO_RENEGOTIATION:
+               log(ERROR, "%s: No TLS renegotiation", msg);
+               break;
+       case TLS_FEATURE_NOT_SUPPORTED:
+               log(ERROR, "%s: TLS feature not supported", msg);
+               break;
+       default:
+               log(ERROR, "%s: Unknown TLS error %d", msg, tls_err);
+               break;
+       }
+}