summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2011-09-27 15:24:11 +0200
committerLars-Dominik Braun <lars@6xq.net>2011-11-09 20:10:16 +0100
commit154700e3fd9b052b5f8586470bde1f68aa82d406 (patch)
treeaab5a3bf85d1bf5e2f3946b9882f014fd391df51
parent3b149d10572392da66f57a7e2aaac53ba424e45c (diff)
downloadpianobar-154700e3fd9b052b5f8586470bde1f68aa82d406.tar.gz
pianobar-154700e3fd9b052b5f8586470bde1f68aa82d406.tar.bz2
pianobar-154700e3fd9b052b5f8586470bde1f68aa82d406.zip
waitress: Don't initialize TLS if not requested
The player does not need TLS. This saves a few bytes.
-rw-r--r--src/libwaitress/waitress.c16
-rw-r--r--src/libwaitress/waitress.h1
2 files changed, 11 insertions, 6 deletions
diff --git a/src/libwaitress/waitress.c b/src/libwaitress/waitress.c
index 8b6daa8..1a6d4cd 100644
--- a/src/libwaitress/waitress.c
+++ b/src/libwaitress/waitress.c
@@ -61,12 +61,12 @@ void WaitressInit (WaitressHandle_t *waith, const char *caPath) {
memset (waith, 0, sizeof (*waith));
waith->timeout = 30000;
#ifdef ENABLE_TLS
- gnutls_certificate_allocate_credentials (&waith->tlsCred);
- if (caPath == NULL) {
- caPath = "/etc/ssl/certs/ca-certificates.crt";
+ if (caPath != NULL) {
+ gnutls_certificate_allocate_credentials (&waith->tlsCred);
+ gnutls_certificate_set_x509_trust_file (waith->tlsCred, caPath,
+ GNUTLS_X509_FMT_PEM);
+ waith->tlsInitialized = true;
}
- gnutls_certificate_set_x509_trust_file (waith->tlsCred, caPath,
- GNUTLS_X509_FMT_PEM);
#endif
}
@@ -76,7 +76,9 @@ void WaitressFree (WaitressHandle_t *waith) {
free (waith->url.url);
free (waith->proxy.url);
#ifdef ENABLE_TLS
- gnutls_certificate_free_credentials (waith->tlsCred);
+ if (waith->tlsInitialized) {
+ gnutls_certificate_free_credentials (waith->tlsCred);
+ }
#endif
memset (waith, 0, sizeof (*waith));
}
@@ -1029,6 +1031,8 @@ WaitressReturn_t WaitressFetchCall (WaitressHandle_t *waith) {
#ifdef ENABLE_TLS
if (waith->url.tls) {
+ assert (waith->tlsInitialized);
+
waith->request.read = WaitressGnutlsRead;
waith->request.write = WaitressGnutlsWrite;
gnutls_init (&waith->request.tlsSession, GNUTLS_CLIENT);
diff --git a/src/libwaitress/waitress.h b/src/libwaitress/waitress.h
index eb79393..bc697e7 100644
--- a/src/libwaitress/waitress.h
+++ b/src/libwaitress/waitress.h
@@ -95,6 +95,7 @@ typedef struct {
int timeout;
#ifdef ENABLE_TLS
gnutls_certificate_credentials_t tlsCred;
+ bool tlsInitialized;
#endif
/* per-request data */