r25033: Fix include
[kai/samba.git] / source4 / lib / tls / tls.c
index 5679b5096d589cf0780a376c0f58bf1e3ecb96a6..71b120dc3c42a7d331e664309be415a950cbb6e8 100644 (file)
@@ -9,7 +9,7 @@
  
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "includes.h"
 #include "lib/events/events.h"
 #include "lib/socket/socket.h"
+#include "lib/tls/tls.h"
+#include "param/param.h"
 
-#if HAVE_LIBGNUTLS
+#if ENABLE_GNUTLS
 #include "gnutls/gnutls.h"
 
 #define DH_BITS 1024
 
 #if defined(HAVE_GNUTLS_DATUM) && !defined(HAVE_GNUTLS_DATUM_T)
-typedef gnutls_datum gnutls_datum_t
+typedef gnutls_datum gnutls_datum_t;
 #endif
 
 /* hold persistent tls data */
@@ -48,7 +49,7 @@ struct tls_context {
        struct socket_context *socket;
        struct fd_event *fde;
        BOOL tls_enabled;
-#if HAVE_LIBGNUTLS
+#if ENABLE_GNUTLS
        gnutls_session session;
        BOOL done_handshake;
        BOOL have_first_byte;
@@ -78,7 +79,7 @@ BOOL tls_enabled(struct socket_context *sock)
 }
 
 
-#if HAVE_LIBGNUTLS
+#if ENABLE_GNUTLS
 
 static const struct socket_ops tls_socket_ops;
 
@@ -339,7 +340,7 @@ static NTSTATUS tls_socket_send(struct socket_context *sock,
                return STATUS_MORE_ENTRIES;
        }
        if (ret < 0) {
-               DEBUG(0,("gnutls_record_send of %d failed - %s\n", blob->length, gnutls_strerror(ret)));
+               DEBUG(0,("gnutls_record_send of %d failed - %s\n", (int)blob->length, gnutls_strerror(ret)));
                return NT_STATUS_UNEXPECTED_NETWORK_ERROR;
        }
        *sendlen = ret;
@@ -417,13 +418,16 @@ struct tls_params *tls_initialise(TALLOC_CTX *mem_ctx)
        ret = gnutls_dh_params_init(&params->dh_params);
        if (ret < 0) goto init_failed;
 
-       if (dhpfile) {
+       if (dhpfile && *dhpfile) {
                gnutls_datum_t dhparms;
-               dhparms.data = (uint8_t *)file_load(dhpfile, &dhparms.size, mem_ctx);
+               size_t size;
+               dhparms.data = (uint8_t *)file_load(dhpfile, &size, mem_ctx);
 
                if (!dhparms.data) {
+                       DEBUG(0,("Failed to read DH Parms from %s\n", dhpfile));
                        goto init_failed;
                }
+               dhparms.size = size;
                        
                ret = gnutls_dh_params_import_pkcs3(params->dh_params, &dhparms, GNUTLS_X509_FMT_PEM);
                if (ret < 0) goto init_failed;