summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2011-11-11 18:49:46 +0100
committerLars-Dominik Braun <lars@6xq.net>2011-11-11 18:49:46 +0100
commitb3fcb394e5a4c927cb3e29aa9d351fa9f57c2d15 (patch)
tree8680897cb26e8b1b9af0cb2214d2767f504c9483 /src
parenta0e4f1e0f5989505f4aab10d64194b635f9af53c (diff)
downloadpianobar-windows-b3fcb394e5a4c927cb3e29aa9d351fa9f57c2d15.tar.gz
pianobar-windows-b3fcb394e5a4c927cb3e29aa9d351fa9f57c2d15.tar.bz2
pianobar-windows-b3fcb394e5a4c927cb3e29aa9d351fa9f57c2d15.zip
waitress: Support GnuTLS <= 2.10.0
Both, 1.x and 2.x are now supported. See issue #182.
Diffstat (limited to 'src')
-rw-r--r--src/libwaitress/waitress.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/src/libwaitress/waitress.c b/src/libwaitress/waitress.c
index 7082ffd..69c4d3a 100644
--- a/src/libwaitress/waitress.c
+++ b/src/libwaitress/waitress.c
@@ -687,14 +687,11 @@ static int WaitressParseStatusline (const char * const line) {
/* verify server certificate
*/
-static int WaitressTlsVerify (gnutls_session_t session) {
- unsigned int status, certListSize;
+static int WaitressTlsVerify (const WaitressHandle_t *waith) {
+ gnutls_session_t session = waith->request.tlsSession;
+ unsigned int certListSize;
const gnutls_datum_t *certList;
gnutls_x509_crt_t cert;
- const WaitressHandle_t *waith;
-
- waith = gnutls_session_get_ptr (session);
- assert (waith != NULL);
if (gnutls_certificate_type_get (session) != GNUTLS_CRT_X509) {
return GNUTLS_E_CERTIFICATE_ERROR;
@@ -807,6 +804,10 @@ static WaitressReturn_t WaitressConnect (WaitressHandle_t *waith) {
if (gnutls_handshake (waith->request.tlsSession) != GNUTLS_E_SUCCESS) {
return WAITRESS_RET_TLS_HANDSHAKE_ERR;
}
+
+ if (WaitressTlsVerify (waith) != 0) {
+ return WAITRESS_RET_TLS_HANDSHAKE_ERR;
+ }
}
return WAITRESS_RET_OK;
@@ -1020,12 +1021,10 @@ WaitressReturn_t WaitressFetchCall (WaitressHandle_t *waith) {
if (waith->url.tls) {
waith->request.read = WaitressGnutlsRead;
waith->request.write = WaitressGnutlsWrite;
+
gnutls_init (&waith->request.tlsSession, GNUTLS_CLIENT);
- const char *err;
- if (gnutls_priority_set_direct (waith->request.tlsSession,
- "PERFORMANCE", &err) != GNUTLS_E_SUCCESS) {
- return WAITRESS_RET_ERR;
- }
+ gnutls_set_default_priority (waith->request.tlsSession);
+
gnutls_certificate_allocate_credentials (&waith->tlsCred);
if (gnutls_credentials_set (waith->request.tlsSession,
GNUTLS_CRD_CERTIFICATE,
@@ -1040,12 +1039,6 @@ WaitressReturn_t WaitressFetchCall (WaitressHandle_t *waith) {
WaitressPollRead);
gnutls_transport_set_push_function (waith->request.tlsSession,
WaitressPollWrite);
-
- /* certificate verification function */
- gnutls_session_set_ptr (waith->request.tlsSession,
- (gnutls_transport_ptr_t) waith);
- gnutls_certificate_set_verify_function (waith->tlsCred,
- WaitressTlsVerify);
}
/* request */