summaryrefslogtreecommitdiffstats
path: root/nanohttp
diff options
context:
space:
mode:
authorGravatar mrcsys2006-01-18 16:28:24 +0000
committerGravatar mrcsys2006-01-18 16:28:24 +0000
commit3e17cfa6f481ef56b412e9d31c67c3ee8ab7bfb9 (patch)
treef910c2932c798280c2509c818628dd596e04d34d /nanohttp
parentdf494ade428ddb4cb6a9a6f8b3885cf1b2478f06 (diff)
downloadcsoap-3e17cfa6f481ef56b412e9d31c67c3ee8ab7bfb9.tar.gz
csoap-3e17cfa6f481ef56b412e9d31c67c3ee8ab7bfb9.tar.bz2
Tweaking to integrate.
Diffstat (limited to 'nanohttp')
-rw-r--r--nanohttp/nanohttp-common.c14
-rw-r--r--nanohttp/nanohttp-common.h5
-rw-r--r--nanohttp/nanohttp-server.c23
3 files changed, 30 insertions, 12 deletions
diff --git a/nanohttp/nanohttp-common.c b/nanohttp/nanohttp-common.c
index 0b7661b..062c66c 100644
--- a/nanohttp/nanohttp-common.c
+++ b/nanohttp/nanohttp-common.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: nanohttp-common.c,v 1.23 2006/01/11 10:54:43 snowdrop Exp $
+* $Id: nanohttp-common.c,v 1.24 2006/01/18 16:28:24 mrcsys Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -82,6 +82,9 @@ hoption_init_args(int argc, char *argv[])
int i;
hoption_set(HOPTION_TMP_DIR, "."); /* default value */
+ hoption_set(HOPTION_SSL_CERT, "");
+ hoption_set(HOPTION_SSL_PASS, "");
+ hoption_set(HOPTION_SSL_CA, "");
/* initialize from arguments */
for (i = 0; i < argc; i++)
@@ -101,8 +104,7 @@ hoption_init_args(int argc, char *argv[])
"WARNING: csoap compiled without '--with-ssl' flag. Parameter '%s' is disabled",
NHTTP_ARG_CERT);
#else
- /* TODO (#1#) handle ssl arguments */
- /* SSLCert = argv[i + 1];*/
+ hoption_set(HOPTION_SSL_CERT, argv[i + 1]);
#endif
}
else if (!strcmp(argv[i], NHTTP_ARG_CERTPASS) && i < argc - 1)
@@ -112,8 +114,7 @@ hoption_init_args(int argc, char *argv[])
"WARNING: csoap compiled without '--with-ssl' flag. Parameter '%s' is disabled",
NHTTP_ARG_CERTPASS);
#else
- /* TODO (#1#) handle ssl arguments */
- /* SSLPass = argv[i + 1];*/
+ hoption_set(HOPTION_SSL_PASS, argv[i + 1]);
#endif
}
else if (!strcmp(argv[i], NHTTP_ARG_CA) && i < argc - 1)
@@ -123,8 +124,7 @@ hoption_init_args(int argc, char *argv[])
"WARNING: csoap compiled without '--with-ssl' flag. Parameter '%s' is disabled",
NHTTP_ARG_CA);
#else
- /* TODO (#1#) handle ssl arguments */
- /*SSLCA = argv[i + 1];*/
+ hoption_set(HOPTION_SSL_CA, argv[i + 1]);
#endif
}
else if (!strcmp(argv[i], NHTTP_ARG_HTTPS))
diff --git a/nanohttp/nanohttp-common.h b/nanohttp/nanohttp-common.h
index eb2c426..607fc2b 100644
--- a/nanohttp/nanohttp-common.h
+++ b/nanohttp/nanohttp-common.h
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: nanohttp-common.h,v 1.23 2006/01/11 10:54:43 snowdrop Exp $
+ * $Id: nanohttp-common.h,v 1.24 2006/01/18 16:28:24 mrcsys Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003-2004 Ferhat Ayaz
@@ -466,6 +466,9 @@ void attachments_add_part(attachments_t * attachments, part_t * part);
/* tmp directory for multipart/related stuff */
#define HOPTION_TMP_DIR 2
+#define HOPTION_SSL_CERT 3
+#define HOPTION_SSL_PASS 4
+#define HOPTION_SSL_CA 5
void hoption_init_args(int argc, char *argv[]);
void hoption_set(int opt, const char *value);
char *hoption_get(int opt);
diff --git a/nanohttp/nanohttp-server.c b/nanohttp/nanohttp-server.c
index 2da65b7..0e6832e 100644
--- a/nanohttp/nanohttp-server.c
+++ b/nanohttp/nanohttp-server.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: nanohttp-server.c,v 1.44 2006/01/18 14:53:13 mrcsys Exp $
+* $Id: nanohttp-server.c,v 1.45 2006/01/18 16:28:24 mrcsys Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -118,6 +118,9 @@ httpd_init (int argc, char *argv[])
{
int i;
herror_t status;
+#ifdef HAVE_SSL
+ char *SSLCert = NULL, *SSLPass = NULL, *SSLCA = NULL;
+#endif
hoption_init_args (argc, argv);
@@ -172,7 +175,19 @@ httpd_init (int argc, char *argv[])
#endif
/* create socket */
- status = hsocket_init (&_httpd_socket);
+#ifdef HAVE_SSL
+ SSLCert = hoption_get(HOPTION_SSL_CERT);
+ SSLPass = hoption_get(HOPTION_SSL_PASS);
+ SSLCA = hoption_get(HOPTION_SSL_CA);
+ log_verbose3("SSL: %s %s", SSLCert, SSLCA);
+ if(SSLCert[0] != NULL){
+ status = hsocket_init_ssl(&_httpd_socket, SSLCert, SSLPass, SSLCA);
+ } else
+#endif
+ {
+ status = hsocket_init (&_httpd_socket);
+ }
+
if (status != H_OK)
{
return status;
@@ -457,14 +472,14 @@ httpd_session_main (void *data)
log_verbose1 ("starting httpd_session_main()");
#ifdef HAVE_SSL
- if (!conn->sock.sslCtx)
+ if (!_httpd_socket.sslCtx)
{
log_verbose1 ("Using HTTP");
}
else
{
log_verbose1 ("Using HTTPS");
- conn->sock.ssl = init_ssl (conn->sock.sslCtx, conn->sock.sock, SSL_SERVER);
+ conn->sock.ssl = init_ssl (_httpd_socket.sslCtx, conn->sock.sock, SSL_SERVER);
hsocket_block (conn->sock, 0);
if (conn->sock.ssl == NULL)
{