diff options
Diffstat (limited to 'src/microhttpd/daemon.c')
-rw-r--r-- | src/microhttpd/daemon.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index 301186f7..f43f071f 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c | |||
@@ -471,6 +471,13 @@ MHD_init_daemon_certificate (struct MHD_Daemon *daemon) | |||
471 | gnutls_datum_t key; | 471 | gnutls_datum_t key; |
472 | gnutls_datum_t cert; | 472 | gnutls_datum_t cert; |
473 | 473 | ||
474 | #if GNUTLS_VERSION_MAJOR >= 3 | ||
475 | if (NULL != daemon->cert_callback) | ||
476 | { | ||
477 | gnutls_certificate_set_retrieve_function2 (daemon->x509_cred, | ||
478 | daemon->cert_callback); | ||
479 | } | ||
480 | #endif | ||
474 | if (NULL != daemon->https_mem_trust) | 481 | if (NULL != daemon->https_mem_trust) |
475 | { | 482 | { |
476 | cert.data = (unsigned char *) daemon->https_mem_trust; | 483 | cert.data = (unsigned char *) daemon->https_mem_trust; |
@@ -499,6 +506,10 @@ MHD_init_daemon_certificate (struct MHD_Daemon *daemon) | |||
499 | &cert, &key, | 506 | &cert, &key, |
500 | GNUTLS_X509_FMT_PEM); | 507 | GNUTLS_X509_FMT_PEM); |
501 | } | 508 | } |
509 | #if GNUTLS_VERSION_MAJOR >= 3 | ||
510 | if (NULL != daemon->cert_callback) | ||
511 | return 0; | ||
512 | #endif | ||
502 | #if HAVE_MESSAGES | 513 | #if HAVE_MESSAGES |
503 | MHD_DLOG (daemon, "You need to specify a certificate and key location\n"); | 514 | MHD_DLOG (daemon, "You need to specify a certificate and key location\n"); |
504 | #endif | 515 | #endif |
@@ -2900,6 +2911,18 @@ parse_options_va (struct MHD_Daemon *daemon, | |||
2900 | } | 2911 | } |
2901 | } | 2912 | } |
2902 | break; | 2913 | break; |
2914 | case MHD_OPTION_HTTPS_CERT_CALLBACK: | ||
2915 | #if GNUTLS_VERSION_MAJOR < 3 | ||
2916 | #if HAVE_MESSAGES | ||
2917 | MHD_DLOG (daemon, | ||
2918 | "MHD_OPTION_HTTPS_CERT_CALLBACK requires building MHD with GnuTLS >= 3.0\n"); | ||
2919 | #endif | ||
2920 | return MHD_NO; | ||
2921 | #else | ||
2922 | if (0 != (daemon->options & MHD_USE_SSL)) | ||
2923 | daemon->cert_callback = va_arg (ap, gnutls_certificate_retrieve_function2 *); | ||
2924 | break; | ||
2925 | #endif | ||
2903 | #endif | 2926 | #endif |
2904 | #ifdef DAUTH_SUPPORT | 2927 | #ifdef DAUTH_SUPPORT |
2905 | case MHD_OPTION_DIGEST_AUTH_RANDOM: | 2928 | case MHD_OPTION_DIGEST_AUTH_RANDOM: |
@@ -2974,6 +2997,7 @@ parse_options_va (struct MHD_Daemon *daemon, | |||
2974 | case MHD_OPTION_HTTPS_MEM_TRUST: | 2997 | case MHD_OPTION_HTTPS_MEM_TRUST: |
2975 | case MHD_OPTION_HTTPS_PRIORITIES: | 2998 | case MHD_OPTION_HTTPS_PRIORITIES: |
2976 | case MHD_OPTION_ARRAY: | 2999 | case MHD_OPTION_ARRAY: |
3000 | case MHD_OPTION_HTTPS_CERT_CALLBACK: | ||
2977 | if (MHD_YES != parse_options (daemon, | 3001 | if (MHD_YES != parse_options (daemon, |
2978 | servaddr, | 3002 | servaddr, |
2979 | opt, | 3003 | opt, |