summaryrefslogtreecommitdiff
path: root/src/libwaitress
diff options
context:
space:
mode:
Diffstat (limited to 'src/libwaitress')
-rw-r--r--src/libwaitress/waitress.c14
-rw-r--r--src/libwaitress/waitress.h3
2 files changed, 13 insertions, 4 deletions
diff --git a/src/libwaitress/waitress.c b/src/libwaitress/waitress.c
index f6d4d03..ebf254b 100644
--- a/src/libwaitress/waitress.c
+++ b/src/libwaitress/waitress.c
@@ -53,17 +53,21 @@ typedef struct {
size_t pos;
} WaitressFetchBufCbBuffer_t;
-void WaitressInit (WaitressHandle_t *waith, const char *caPath) {
+WaitressReturn_t WaitressInit (WaitressHandle_t *waith, const char *caPath) {
assert (waith != NULL);
memset (waith, 0, sizeof (*waith));
waith->timeout = 30000;
if (caPath != NULL) {
gnutls_certificate_allocate_credentials (&waith->tlsCred);
- gnutls_certificate_set_x509_trust_file (waith->tlsCred, caPath,
- GNUTLS_X509_FMT_PEM);
+ if (gnutls_certificate_set_x509_trust_file (waith->tlsCred, caPath,
+ GNUTLS_X509_FMT_PEM) <= 0) {
+ return WAITRESS_RET_TLS_TRUSTFILE_ERR;
+ }
waith->tlsInitialized = true;
}
+
+ return WAITRESS_RET_OK;
}
void WaitressFree (WaitressHandle_t *waith) {
@@ -1162,6 +1166,10 @@ const char *WaitressErrorToStr (WaitressReturn_t wRet) {
return "TLS handshake failed.";
break;
+ case WAITRESS_RET_TLS_TRUSTFILE_ERR:
+ return "Loading root certificates failed.";
+ break;
+
default:
return "No error message available.";
break;
diff --git a/src/libwaitress/waitress.h b/src/libwaitress/waitress.h
index 8d4e5a4..e1cf303 100644
--- a/src/libwaitress/waitress.h
+++ b/src/libwaitress/waitress.h
@@ -77,6 +77,7 @@ typedef enum {
WAITRESS_RET_TLS_WRITE_ERR,
WAITRESS_RET_TLS_READ_ERR,
WAITRESS_RET_TLS_HANDSHAKE_ERR,
+ WAITRESS_RET_TLS_TRUSTFILE_ERR,
} WaitressReturn_t;
/* reusable handle
@@ -109,7 +110,7 @@ typedef struct {
} request;
} WaitressHandle_t;
-void WaitressInit (WaitressHandle_t *, const char *);
+WaitressReturn_t WaitressInit (WaitressHandle_t *, const char *);
void WaitressFree (WaitressHandle_t *);
bool WaitressSetProxy (WaitressHandle_t *, const char *);
char *WaitressUrlEncode (const char *);