diff options
Diffstat (limited to 'src/gnutls/setup_connection.c')
-rw-r--r-- | src/gnutls/setup_connection.c | 83 |
1 files changed, 42 insertions, 41 deletions
diff --git a/src/gnutls/setup_connection.c b/src/gnutls/setup_connection.c index c789613d..64082952 100644 --- a/src/gnutls/setup_connection.c +++ b/src/gnutls/setup_connection.c | |||
@@ -1,57 +1,58 @@ | |||
1 | |||
2 | |||
3 | setup_connection () | 1 | setup_connection () |
4 | { | 2 | { |
5 | connection->tls_state = MHD_TLS_CONN_INIT; | 3 | connection->tls_state = MHD_TLS_CONN_INIT; |
6 | MHD_set_https_callbacks (connection); | 4 | MHD_set_https_callbacks (connection); |
7 | gnutls_init (&connection->tls_session, | 5 | gnutls_init (&connection->tls_session, |
8 | GNUTLS_SERVER | 6 | GNUTLS_SERVER |
9 | #if (GNUTLS_VERSION_NUMBER+0 >= 0x030402) | 7 | #if (GNUTLS_VERSION_NUMBER + 0 >= 0x030402) |
10 | | GNUTLS_NO_SIGNAL | 8 | | GNUTLS_NO_SIGNAL |
11 | #endif /* GNUTLS_VERSION_NUMBER >= 0x030402 */ | 9 | #endif /* GNUTLS_VERSION_NUMBER >= 0x030402 */ |
12 | #if GNUTLS_VERSION_MAJOR >= 3 | 10 | #if GNUTLS_VERSION_MAJOR >= 3 |
13 | | GNUTLS_NONBLOCK | 11 | | GNUTLS_NONBLOCK |
14 | #endif /* GNUTLS_VERSION_MAJOR >= 3*/ | 12 | #endif /* GNUTLS_VERSION_MAJOR >= 3*/ |
15 | ); | 13 | ); |
16 | gnutls_priority_set (connection->tls_session, | 14 | gnutls_priority_set (connection->tls_session, |
17 | daemon->priority_cache); | 15 | daemon->priority_cache); |
18 | switch (daemon->cred_type) | 16 | switch (daemon->cred_type) |
19 | { | 17 | { |
20 | /* set needed credentials for certificate authentication. */ | 18 | /* set needed credentials for certificate authentication. */ |
21 | case GNUTLS_CRD_CERTIFICATE: | 19 | case GNUTLS_CRD_CERTIFICATE: |
22 | gnutls_credentials_set (connection->tls_session, | 20 | gnutls_credentials_set (connection->tls_session, |
23 | GNUTLS_CRD_CERTIFICATE, | 21 | GNUTLS_CRD_CERTIFICATE, |
24 | daemon->x509_cred); | 22 | daemon->x509_cred); |
25 | break; | 23 | break; |
26 | default: | 24 | default: |
27 | #ifdef HAVE_MESSAGES | 25 | #ifdef HAVE_MESSAGES |
28 | MHD_DLOG (connection->daemon, | 26 | MHD_DLOG (connection->daemon, |
29 | _("Failed to setup TLS credentials: unknown credential type %d\n"), | 27 | _ ( |
30 | daemon->cred_type); | 28 | "Failed to setup TLS credentials: unknown credential type %d\n"), |
29 | daemon->cred_type); | ||
31 | #endif | 30 | #endif |
32 | MHD_socket_close_chk_ (client_socket); | 31 | MHD_socket_close_chk_ (client_socket); |
33 | MHD_ip_limit_del (daemon, | 32 | MHD_ip_limit_del (daemon, |
34 | addr, | 33 | addr, |
35 | addrlen); | 34 | addrlen); |
36 | free (connection); | 35 | free (connection); |
37 | MHD_PANIC (_("Unknown credential type")); | 36 | MHD_PANIC (_ ("Unknown credential type")); |
38 | #if EINVAL | 37 | #if EINVAL |
39 | errno = EINVAL; | 38 | errno = EINVAL; |
40 | #endif | 39 | #endif |
41 | return MHD_NO; | 40 | return MHD_NO; |
42 | } | 41 | } |
43 | #if (GNUTLS_VERSION_NUMBER+0 >= 0x030109) && !defined(_WIN64) | 42 | #if (GNUTLS_VERSION_NUMBER + 0 >= 0x030109) && ! defined(_WIN64) |
44 | gnutls_transport_set_int (connection->tls_session, (int)(client_socket)); | 43 | gnutls_transport_set_int (connection->tls_session, (int) (client_socket)); |
45 | #else /* GnuTLS before 3.1.9 or Win x64 */ | 44 | #else /* GnuTLS before 3.1.9 or Win x64 */ |
46 | gnutls_transport_set_ptr (connection->tls_session, (gnutls_transport_ptr_t)(intptr_t)(client_socket)); | 45 | gnutls_transport_set_ptr (connection->tls_session, |
46 | (gnutls_transport_ptr_t) (intptr_t) (client_socket)); | ||
47 | #endif /* GnuTLS before 3.1.9 */ | 47 | #endif /* GnuTLS before 3.1.9 */ |
48 | #ifdef MHD_TLSLIB_NEED_PUSH_FUNC | 48 | #ifdef MHD_TLSLIB_NEED_PUSH_FUNC |
49 | gnutls_transport_set_push_function (connection->tls_session, MHD_tls_push_func_); | 49 | gnutls_transport_set_push_function (connection->tls_session, |
50 | MHD_tls_push_func_); | ||
50 | #endif /* MHD_TLSLIB_NEED_PUSH_FUNC */ | 51 | #endif /* MHD_TLSLIB_NEED_PUSH_FUNC */ |
51 | if (daemon->https_mem_trust) | 52 | if (daemon->https_mem_trust) |
52 | gnutls_certificate_server_set_request (connection->tls_session, | 53 | gnutls_certificate_server_set_request (connection->tls_session, |
53 | GNUTLS_CERT_REQUEST); | 54 | GNUTLS_CERT_REQUEST); |
54 | #else /* ! HTTPS_SUPPORT */ | 55 | #else /* ! HTTPS_SUPPORT */ |
55 | return NULL; | 56 | return NULL; |
56 | 57 | ||
57 | } | 58 | } |