diff options
Diffstat (limited to 'src/libwaitress/waitress.c')
-rw-r--r-- | src/libwaitress/waitress.c | 14 |
1 files changed, 11 insertions, 3 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; |