diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2011-11-10 10:07:40 +0100 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2011-11-10 10:07:40 +0100 |
commit | 852e10d59bb6262de04593903981dec1e7ca85dc (patch) | |
tree | d5d31549a0d4cca8698e20fed2aa8f3cf1c53575 /src/libwaitress/waitress.c | |
parent | bf397e4019acb60d90261247fd2850b849052ede (diff) | |
download | pianobar-852e10d59bb6262de04593903981dec1e7ca85dc.tar.gz pianobar-852e10d59bb6262de04593903981dec1e7ca85dc.tar.bz2 pianobar-852e10d59bb6262de04593903981dec1e7ca85dc.zip |
Die if trust file load fails
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; |