axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kausha...@apache.org
Subject svn commit: r507889 - in /webservices/axis2/trunk/c: include/ modules/core/transport/http/sender/ modules/core/transport/http/sender/ssl/ test/core/transport/http/
Date Thu, 15 Feb 2007 11:07:06 GMT
Author: kaushalye
Date: Thu Feb 15 03:07:05 2007
New Revision: 507889

URL: http://svn.apache.org/viewvc?view=rev&rev=507889
Log:
Applying patch for ssl client authentication. JIRA AXIS2C-529.


Modified:
    webservices/axis2/trunk/c/include/axis2_http_client.h
    webservices/axis2/trunk/c/include/axis2_http_transport.h
    webservices/axis2/trunk/c/modules/core/transport/http/sender/http_client.c
    webservices/axis2/trunk/c/modules/core/transport/http/sender/rest_sender.c
    webservices/axis2/trunk/c/modules/core/transport/http/sender/soap_over_http_sender.c
    webservices/axis2/trunk/c/modules/core/transport/http/sender/ssl/ssl_stream.c
    webservices/axis2/trunk/c/modules/core/transport/http/sender/ssl/ssl_stream.h
    webservices/axis2/trunk/c/modules/core/transport/http/sender/ssl/ssl_utils.c
    webservices/axis2/trunk/c/modules/core/transport/http/sender/ssl/ssl_utils.h
    webservices/axis2/trunk/c/test/core/transport/http/test_http_transport.c

Modified: webservices/axis2/trunk/c/include/axis2_http_client.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/include/axis2_http_client.h?view=diff&rev=507889&r1=507888&r2=507889
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_http_client.h (original)
+++ webservices/axis2/trunk/c/include/axis2_http_client.h Thu Feb 15 03:07:05 2007
@@ -64,7 +64,9 @@
                 send)(
                     axis2_http_client_t *client,
                     const axis2_env_t *env,
-                    axis2_http_simple_request_t *request);
+                    axis2_http_simple_request_t *request,
+                    axis2_char_t *ssl_pp
+                    );
 
         /**
          * @param client pointer to client
@@ -176,6 +178,27 @@
                     const axis2_http_client_t *client,
                     const axis2_env_t *env);
 
+        /**
+         * @param client pointer to client
+         * @param env pointer to environment struct
+         * @param key_file chain file containing 
+         * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE
+         */
+        axis2_status_t (AXIS2_CALL *
+                set_key_file)(
+                    axis2_http_client_t *client,
+                    const axis2_env_t *env,
+                    axis2_char_t *key_file);
+
+        /**
+         * @param client pointer to client
+         * @param env pointer to environment struct
+         */
+        axis2_char_t *(AXIS2_CALL *
+                get_key_file)(
+                    const axis2_http_client_t *client,
+                    const axis2_env_t *env);
+
 
         /**
          * @param client pointer to client
@@ -222,8 +245,9 @@
 
 /** Send.
     @sa axis2_http_client_ops#send */
-#define AXIS2_HTTP_CLIENT_SEND(client, env, request) \
-                                ((client)->ops->send(client, env, request))
+#define AXIS2_HTTP_CLIENT_SEND(client, env, request, ssl_passphrase) \
+                                ((client)->ops->send(client, env, request, \
+                                ssl_passphrase))
 
 /** Receive header.
     @sa axis2_http_client_ops#receive_header */
@@ -272,16 +296,27 @@
 #define AXIS2_HTTP_CLIENT_SET_DUMP_INPUT_MSG(client, env, dump_input_msg) \
         ((client)->ops->set_dump_input_msg(client, env, dump_input_msg))
 
-/** Sets the proxy.
+/** Sets the server certificate.
     @sa axis2_http_client_ops#set_server_cert */
 #define AXIS2_HTTP_CLIENT_SET_SERVER_CERT(client, env, server_cert) \
                                 ((client)->ops->set_server_cert(client, env,\
                         server_cert))
 
-/** Gets the proxy.
+/** Gets the server certificate.
     @sa axis2_http_client_ops#get_server_cert */
 #define AXIS2_HTTP_CLIENT_GET_SERVER_CERT(client, env) \
                                 ((client)->ops->get_server_cert(client, env))
+
+/** Sets the client chain file containing the privat key and the public key.
+    @sa axis2_http_client_ops#set_key_file*/
+#define AXIS2_HTTP_CLIENT_SET_KEY_FILE(client, env, key_file) \
+                                ((client)->ops->set_key_file(client, env,\
+                        key_file))
+
+/** Gets the client chain file containing the privat key and the public key.
+    @sa axis2_http_client_ops#get_key_file*/
+#define AXIS2_HTTP_CLIENT_GET_KEY_FILE(client, env) \
+                                ((client)->ops->get_key_file(client, env))
 
 
 

Modified: webservices/axis2/trunk/c/include/axis2_http_transport.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/include/axis2_http_transport.h?view=diff&rev=507889&r1=507888&r2=507889
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_http_transport.h (original)
+++ webservices/axis2/trunk/c/include/axis2_http_transport.h Thu Feb 15 03:07:05 2007
@@ -420,10 +420,19 @@
 #define AXIS2_HTTP_METHOD "HTTP_METHOD"
 
 /**
- *Constant for SSL Server Certificate
+ * Constant for SSL Server Certificate
  */
 #define AXIS2_SSL_SERVER_CERT "SERVER_CERT"
 
+/**
+ * Constant for SSL Key File
+ */
+#define AXIS2_SSL_KEY_FILE "KEY_FILE"
+
+/**
+ * Constant for SSL Passphrase
+ */
+#define AXIS2_SSL_PASSPHRASE "SSL_PASSPHRASE"
 
 /**
  *Constant for HTTP headers that user specify, Those headers will

Modified: webservices/axis2/trunk/c/modules/core/transport/http/sender/http_client.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/modules/core/transport/http/sender/http_client.c?view=diff&rev=507889&r1=507888&r2=507889
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/sender/http_client.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/sender/http_client.c Thu Feb 15
03:07:05 2007
@@ -51,6 +51,7 @@
     axis2_char_t *proxy_host_port;
     axis2_bool_t dump_input_msg;
 	axis2_char_t *server_cert;
+    axis2_char_t *key_file;
 }
 axis2_http_client_impl_t;
 
@@ -63,7 +64,9 @@
 axis2_http_client_send(
     axis2_http_client_t *client,
     const axis2_env_t *env,
-    axis2_http_simple_request_t *request);
+    axis2_http_simple_request_t *request,
+    axis2_char_t *ssl_pp
+    );
 
 int AXIS2_CALL
 axis2_http_client_recieve_header(
@@ -110,6 +113,12 @@
     const axis2_env_t *env,
     axis2_char_t *server_cert);
 
+axis2_status_t AXIS2_CALL
+axis2_http_client_set_key_file(
+    axis2_http_client_t *client,
+    const axis2_env_t *env,
+    axis2_char_t *key_file);
+
 
 axis2_char_t *AXIS2_CALL
 axis2_http_client_get_proxy(
@@ -121,6 +130,11 @@
     const axis2_http_client_t *client,
     const axis2_env_t *env);
 
+axis2_char_t *AXIS2_CALL
+axis2_http_client_get_key_file(
+    const axis2_http_client_t *client,
+    const axis2_env_t *env);
+
 axis2_status_t AXIS2_CALL
 axis2_http_client_connect_ssl_host(
     axis2_http_client_t *client,
@@ -175,7 +189,7 @@
     http_client_impl->proxy_host_port = NULL;
     http_client_impl->dump_input_msg = AXIS2_FALSE;
     http_client_impl->server_cert = NULL;
-
+    http_client_impl->key_file = NULL;
 
     http_client_impl->http_client.ops = AXIS2_MALLOC(env->allocator,
             sizeof(axis2_http_client_ops_t));
@@ -205,6 +219,10 @@
         axis2_http_client_set_server_cert;
     http_client_impl->http_client.ops->get_server_cert =
         axis2_http_client_get_server_cert;
+    http_client_impl->http_client.ops->set_key_file =
+        axis2_http_client_set_key_file;
+    http_client_impl->http_client.ops->get_key_file =
+        axis2_http_client_get_key_file;
     http_client_impl->http_client.ops->set_dump_input_msg = 
         axis2_http_client_set_dump_input_msg;
     http_client_impl->http_client.ops->free = axis2_http_client_free;
@@ -261,7 +279,9 @@
 axis2_http_client_send(
     axis2_http_client_t *client,
     const axis2_env_t *env,
-    axis2_http_simple_request_t *request)
+    axis2_http_simple_request_t *request,
+    axis2_char_t *ssl_pp
+    )
 {
     axis2_http_client_impl_t *client_impl = NULL;
     char *wire_format = NULL;
@@ -340,7 +360,10 @@
             }
         }
         client_impl->data_stream = axis2_stream_create_ssl(env,
-                client_impl->sockfd, AXIS2_HTTP_CLIENT_GET_SERVER_CERT(client, env));
+                client_impl->sockfd, 
+                AXIS2_HTTP_CLIENT_GET_SERVER_CERT(client, env),
+                AXIS2_HTTP_CLIENT_GET_KEY_FILE(client, env),
+                ssl_pp);
 #else
         AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_TRANSPORT_PROTOCOL,
                 AXIS2_FAILURE);
@@ -873,4 +896,28 @@
 {
    AXIS2_ENV_CHECK(env, NULL);
    return AXIS2_INTF_TO_IMPL(client)->server_cert;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_http_client_set_key_file(
+    axis2_http_client_t *client,
+    const axis2_env_t *env,
+    axis2_char_t *key_file)
+{
+   axis2_http_client_impl_t *client_impl = NULL;
+    
+   client_impl = AXIS2_INTF_TO_IMPL(client);
+
+   client_impl->key_file = key_file;
+
+   return AXIS2_SUCCESS;
+}
+
+axis2_char_t *AXIS2_CALL
+axis2_http_client_get_key_file(
+    const axis2_http_client_t *client,
+    const axis2_env_t *env)
+{
+   AXIS2_ENV_CHECK(env, NULL);
+   return AXIS2_INTF_TO_IMPL(client)->key_file;
 }

Modified: webservices/axis2/trunk/c/modules/core/transport/http/sender/rest_sender.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/modules/core/transport/http/sender/rest_sender.c?view=diff&rev=507889&r1=507888&r2=507889
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/sender/rest_sender.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/sender/rest_sender.c Thu Feb 15
03:07:05 2007
@@ -419,7 +419,7 @@
 	}
 
 	axis2_rest_sender_configure_server_cert (sender, env, msg_ctx);
-    status_code = AXIS2_HTTP_CLIENT_SEND(sender_impl->client, env, request);
+    status_code = AXIS2_HTTP_CLIENT_SEND(sender_impl->client, env, request, NULL);
 
     AXIS2_HTTP_SIMPLE_REQUEST_FREE(request, env);
     request = NULL;

Modified: webservices/axis2/trunk/c/modules/core/transport/http/sender/soap_over_http_sender.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/modules/core/transport/http/sender/soap_over_http_sender.c?view=diff&rev=507889&r1=507888&r2=507889
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/sender/soap_over_http_sender.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/sender/soap_over_http_sender.c Thu
Feb 15 03:07:05 2007
@@ -26,6 +26,7 @@
 #include <axis2_http_client.h>
 #include <axiom_xml_writer.h>
 #include <axis2_property.h>
+#include <axis2_param.h>
 #include <axis2_types.h>
 #include <axis2_generic_obj.h>
 
@@ -110,6 +111,12 @@
     axis2_msg_ctx_t *msg_ctx);
 
 axis2_status_t AXIS2_CALL
+axis2_soap_over_http_sender_configure_key_file(
+    axis2_soap_over_http_sender_t *sender,
+    const axis2_env_t *env,
+    axis2_msg_ctx_t *msg_ctx);
+
+axis2_status_t AXIS2_CALL
 axis2_soap_over_http_sender_free(
     axis2_soap_over_http_sender_t *sender,
     const axis2_env_t *env);
@@ -218,6 +225,9 @@
     int output_stream_size = 0;
     axis2_bool_t doing_mtom = AXIS2_FALSE;
     axis2_property_t *dump_property = NULL;
+    axis2_param_t *ssl_pp_param = NULL; /* ssl passphrase */
+    axis2_property_t *ssl_pp_property = NULL;
+    axis2_char_t *ssl_pp = NULL;
 
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
@@ -462,12 +472,24 @@
     }
 
 	axis2_soap_over_http_sender_configure_server_cert(sender, env, msg_ctx);
+	
+    axis2_soap_over_http_sender_configure_key_file(sender, env, msg_ctx);
 
     axis2_soap_over_http_sender_get_timeout_values(sender, env, msg_ctx);
     AXIS2_HTTP_CLIENT_SET_TIMEOUT(sender_impl->client, env,
             sender_impl->so_timeout);
+    
+    /* TODO: Load from property
+     * ssl_pp_property = AXIS2_MSG_CTX_GET_PROPERTY(AXIS2_SSL_PASSPHRASE);*/
 
-    status_code = AXIS2_HTTP_CLIENT_SEND(sender_impl->client, env, request);
+    ssl_pp_param = AXIS2_MSG_CTX_GET_PARAMETER(msg_ctx, env, AXIS2_SSL_PASSPHRASE);
+
+    if (ssl_pp_param)
+    {
+        ssl_pp = AXIS2_PARAM_GET_VALUE(ssl_pp_param, env);
+    }
+
+    status_code = AXIS2_HTTP_CLIENT_SEND(sender_impl->client, env, request, ssl_pp);
 
 
     /*AXIS2_FREE(env->allocator, buffer);
@@ -865,9 +887,10 @@
     const axis2_env_t *env,
     axis2_msg_ctx_t *msg_ctx)
 {
-	axis2_property_t *server_cert_property;
+	axis2_property_t *server_cert_property = NULL;
+	axis2_param_t *server_cert_param = NULL;
 	axis2_char_t *server_cert = NULL;
-	axis2_status_t status = 0;
+	axis2_status_t status = AXIS2_FAILURE;
     axis2_soap_over_http_sender_impl_t *sender_impl = NULL;
 
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
@@ -876,11 +899,71 @@
     sender_impl = AXIS2_INTF_TO_IMPL(sender);
 
     server_cert_property = AXIS2_MSG_CTX_GET_PROPERTY(msg_ctx, env, 
-													  AXIS2_SSL_SERVER_CERT, AXIS2_FALSE);
+            AXIS2_SSL_SERVER_CERT, AXIS2_FALSE);
     if(server_cert_property)
     {
-		server_cert = (axis2_char_t *) AXIS2_PROPERTY_GET_VALUE(server_cert_property, env);
-		status = AXIS2_HTTP_CLIENT_SET_SERVER_CERT(sender_impl->client, env, server_cert);
+		server_cert = (axis2_char_t *) AXIS2_PROPERTY_GET_VALUE(
+                server_cert_property, env);
+    }
+    else
+    {
+        server_cert_param = AXIS2_MSG_CTX_GET_PARAMETER(msg_ctx, env, 
+                AXIS2_SSL_SERVER_CERT);
+        if(server_cert_param)
+        {
+            server_cert = (axis2_char_t *) AXIS2_PARAM_GET_VALUE(
+                    server_cert_param, env);
+        }
     }
+    
+    if(server_cert)
+    {
+        status = AXIS2_HTTP_CLIENT_SET_SERVER_CERT(sender_impl->client, 
+                env, server_cert);
+    }
+
+    return status;
+}
+axis2_status_t AXIS2_CALL
+axis2_soap_over_http_sender_configure_key_file(
+    axis2_soap_over_http_sender_t *sender,
+    const axis2_env_t *env,
+    axis2_msg_ctx_t *msg_ctx)
+{
+	axis2_property_t *key_file_property = NULL;
+	axis2_param_t *key_file_param = NULL;
+    axis2_char_t *key_file = NULL;
+	axis2_status_t status = AXIS2_FAILURE;
+    axis2_soap_over_http_sender_impl_t *sender_impl = NULL;
+
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+
+    sender_impl = AXIS2_INTF_TO_IMPL(sender);
+
+    key_file_property = AXIS2_MSG_CTX_GET_PROPERTY(msg_ctx, env, 
+            AXIS2_SSL_KEY_FILE, AXIS2_FALSE);
+    if(key_file_property)
+    {
+		key_file = (axis2_char_t *) AXIS2_PROPERTY_GET_VALUE(
+                key_file_property, env);
+    }
+    else
+    {
+        key_file_param = AXIS2_MSG_CTX_GET_PARAMETER(msg_ctx, env,
+                AXIS2_SSL_KEY_FILE);
+        if(key_file_param)
+        {
+            key_file = (axis2_char_t *) AXIS2_PARAM_GET_VALUE(
+                    key_file_param, env);
+        }
+    }
+
+    if (key_file)
+    {
+		status = AXIS2_HTTP_CLIENT_SET_KEY_FILE(sender_impl->client, 
+                env, key_file);
+    }
+
 	return status;
 }

Modified: webservices/axis2/trunk/c/modules/core/transport/http/sender/ssl/ssl_stream.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/modules/core/transport/http/sender/ssl/ssl_stream.c?view=diff&rev=507889&r1=507888&r2=507889
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/sender/ssl/ssl_stream.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/sender/ssl/ssl_stream.c Thu Feb
15 03:07:05 2007
@@ -40,26 +40,55 @@
 
 /********************************Function headers******************************/
 axis2_status_t AXIS2_CALL
-axis2_ssl_stream_free(axis2_stream_t *stream, const axis2_env_t *env);
+axis2_ssl_stream_free(
+    axis2_stream_t *stream, 
+    const axis2_env_t *env
+    );
 
 axis2_stream_type_t AXIS2_CALL
-axis2_ssl_stream_get_type(axis2_stream_t *stream, const axis2_env_t *env);
-
-int AXIS2_CALL
-axis2_ssl_stream_write(axis2_stream_t *stream, const axis2_env_t *env,
-        const void *buffer, size_t count);
-int AXIS2_CALL
-axis2_ssl_stream_read(axis2_stream_t *stream, const axis2_env_t *env,
-        void *buffer, size_t count);
-int AXIS2_CALL
-axis2_ssl_stream_skip(axis2_stream_t *stream, const axis2_env_t *env, int count);
-
-int AXIS2_CALL
-axis2_ssl_stream_get_char(axis2_stream_t *stream, const axis2_env_t *env);
+axis2_ssl_stream_get_type(
+    axis2_stream_t *stream, 
+    const axis2_env_t *env
+    );
+
+int AXIS2_CALL
+axis2_ssl_stream_write(
+    axis2_stream_t *stream,
+    const axis2_env_t *env,
+    const void *buffer,
+    size_t count
+    );
+
+int AXIS2_CALL
+axis2_ssl_stream_read(
+    axis2_stream_t *stream, 
+    const axis2_env_t *env,
+    void *buffer,
+    size_t count
+    );
+
+int AXIS2_CALL
+axis2_ssl_stream_skip(
+    axis2_stream_t *stream,
+    const axis2_env_t *env,
+    int count
+    );
+
+int AXIS2_CALL
+axis2_ssl_stream_get_char(
+    axis2_stream_t *stream,
+    const axis2_env_t *env
+    );
 
 
 AXIS2_EXTERN axis2_stream_t * AXIS2_CALL
-axis2_stream_create_ssl(const axis2_env_t *env, axis2_socket_t socket, axis2_char_t *server_cert)
+axis2_stream_create_ssl(
+    const axis2_env_t *env,
+    axis2_socket_t socket,
+    axis2_char_t *server_cert,
+    axis2_char_t *key_file,
+    axis2_char_t *ssl_pp
+    )
 {
     ssl_stream_impl_t *stream_impl = NULL;
     AXIS2_ENV_CHECK(env, NULL);
@@ -77,7 +106,8 @@
     stream_impl->ctx = NULL;
     stream_impl->ssl = NULL;
 
-    stream_impl->ctx = axis2_ssl_utils_initialize_ctx(env, server_cert);
+    stream_impl->ctx = axis2_ssl_utils_initialize_ctx(env, server_cert,
+            key_file, ssl_pp);
     if (NULL == stream_impl->ctx)
     {
         axis2_ssl_stream_free((axis2_stream_t*)stream_impl, env);
@@ -111,7 +141,10 @@
 
 
 axis2_status_t AXIS2_CALL
-axis2_ssl_stream_free(axis2_stream_t *stream, const axis2_env_t *env)
+axis2_ssl_stream_free(
+    axis2_stream_t *stream,
+    const axis2_env_t *env
+    )
 {
     ssl_stream_impl_t *stream_impl = NULL;
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
@@ -128,8 +161,12 @@
 }
 
 int AXIS2_CALL
-axis2_ssl_stream_read(axis2_stream_t *stream, const axis2_env_t *env,
-        void *buffer, size_t count)
+axis2_ssl_stream_read(
+    axis2_stream_t *stream,
+    const axis2_env_t *env,
+    void *buffer,
+    size_t count
+    )
 {
     ssl_stream_impl_t *stream_impl = NULL;
     int read = -1;
@@ -161,8 +198,12 @@
 }
 
 int AXIS2_CALL
-axis2_ssl_stream_write(axis2_stream_t *stream, const axis2_env_t *env,
-        const void *buf, size_t count)
+axis2_ssl_stream_write(
+    axis2_stream_t *stream,
+    const axis2_env_t *env,
+    const void *buf,
+    size_t count
+    )
 {
     ssl_stream_impl_t *stream_impl = NULL;
     int write = -1;
@@ -186,7 +227,11 @@
 
 
 int AXIS2_CALL
-axis2_ssl_stream_skip(axis2_stream_t *stream, const axis2_env_t *env, int count)
+axis2_ssl_stream_skip(
+    axis2_stream_t *stream, 
+    const axis2_env_t *env, 
+    int count
+    )
 {
     ssl_stream_impl_t *stream_impl = NULL;
     axis2_char_t *tmp_buffer = NULL;
@@ -208,7 +253,10 @@
 }
 
 int AXIS2_CALL
-axis2_ssl_stream_get_char(axis2_stream_t *stream, const axis2_env_t *env)
+axis2_ssl_stream_get_char(
+    axis2_stream_t *stream, 
+    const axis2_env_t *env
+    )
 {
     int ret = -1;
     AXIS2_ENV_CHECK(env, AXIS2_CRITICAL_FAILURE);
@@ -218,7 +266,10 @@
 }
 
 axis2_stream_type_t AXIS2_CALL
-axis2_ssl_stream_get_type(axis2_stream_t *stream, const axis2_env_t *env)
+axis2_ssl_stream_get_type(
+    axis2_stream_t *stream,
+    const axis2_env_t *env
+    )
 {
     AXIS2_ENV_CHECK(env, AXIS2_CRITICAL_FAILURE);
     return AXIS2_INTF_TO_IMPL(stream)->stream_type;

Modified: webservices/axis2/trunk/c/modules/core/transport/http/sender/ssl/ssl_stream.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/modules/core/transport/http/sender/ssl/ssl_stream.h?view=diff&rev=507889&r1=507888&r2=507889
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/sender/ssl/ssl_stream.h (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/sender/ssl/ssl_stream.h Thu Feb
15 03:07:05 2007
@@ -34,7 +34,13 @@
   * @return axis2_stream (ssl)
   */
 AXIS2_EXTERN axis2_stream_t * AXIS2_CALL 
-axis2_stream_create_ssl(const axis2_env_t *env, axis2_socket_t socket, axis2_char_t *server_cert);
+axis2_stream_create_ssl(
+    const axis2_env_t *env,
+    axis2_socket_t socket,
+    axis2_char_t *server_cert,
+    axis2_char_t *key_file,
+    axis2_char_t *ssl_pp
+    );
 
 /** @} */
     

Modified: webservices/axis2/trunk/c/modules/core/transport/http/sender/ssl/ssl_utils.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/modules/core/transport/http/sender/ssl/ssl_utils.c?view=diff&rev=507889&r1=507888&r2=507889
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/sender/ssl/ssl_utils.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/sender/ssl/ssl_utils.c Thu Feb 15
03:07:05 2007
@@ -17,27 +17,53 @@
 #include "ssl_utils.h"
 BIO *bio_err = 0;
 
+static int password_cb(
+    char *buf,
+    int size, 
+    int rwflag, 
+    void *passwd
+    )
+{
+    strncpy(buf, (char *)passwd, size);
+    buf[size-1] = '\0';
+    /*printf("ssl_passphrase:%s", buf);*/
+    return(strlen(buf));
+}
+
 AXIS2_EXTERN SSL_CTX* AXIS2_CALL
-axis2_ssl_utils_initialize_ctx(const axis2_env_t *env, axis2_char_t *server_cert)
+axis2_ssl_utils_initialize_ctx(
+    const axis2_env_t *env,
+    axis2_char_t *server_cert,
+    axis2_char_t *key_file,
+    axis2_char_t *ssl_pp
+)
 {
     SSL_METHOD *meth = NULL;
-    axis2_char_t *ca_file = NULL;
     SSL_CTX *ctx = NULL;
+    axis2_char_t *ca_file = server_cert; /*TODO: remove ca_file*/
+    /*axis2_char_t *key_file = NULL;*/
 
     AXIS2_ENV_CHECK(env, NULL);
 
     /*TODO getenv */
-	if (server_cert)
+	/*if (server_cert)
 		ca_file = server_cert;
 	else
 		ca_file = AXIS2_GETENV("AXIS2_SSL_CA_FILE");
 
+    key_file = AXIS2_GETENV("AXIS2_SSL_KEY_FILE");
+    */
+
+    /*printf("key_file: %s\n", key_file);
+    printf("ca_file: %s\n", server_cert);*/
+
     if (NULL == ca_file)
     {
         AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SSL_NO_CA_FILE,
                 AXIS2_FAILURE);
         return NULL;
     }
+
     if (!bio_err)
     {
         /* Global system initialization*/
@@ -54,15 +80,32 @@
 
     /* Load our keys and certificates
      * If we need client certificates it has to be done here
+     * TODO 
      */
-    /*if(!(SSL_CTX_use_certificate_chain_file(ctx, keyfile)))
+    if (key_file) /*can we check if the server needs client auth?*/
     {
-        SSL_CTX_free(ctx);
-        return NULL;
-    }*/
+        SSL_CTX_set_default_passwd_cb_userdata(ctx, (void *)ssl_pp);
+        SSL_CTX_set_default_passwd_cb(ctx, password_cb);
+
+        if(!(SSL_CTX_use_certificate_chain_file(ctx, key_file)))
+        {
+            printf("Loading client certificate failed!\n");
+            SSL_CTX_free(ctx);
+            return NULL;
+        }
+
+        if(!(SSL_CTX_use_PrivateKey_file(ctx, key_file, SSL_FILETYPE_PEM)))
+        {
+            printf("Loading client key failed!\n");
+            SSL_CTX_free(ctx);
+            return NULL;
+        }
+    }
+
     /* Load the CAs we trust*/
     if (!(SSL_CTX_load_verify_locations(ctx, ca_file, 0)))
     {
+        printf("Loading CA certifiate failed!\n");
         SSL_CTX_free(ctx);
         return NULL;
     }
@@ -75,8 +118,11 @@
 }
 
 AXIS2_EXTERN SSL* AXIS2_CALL
-axis2_ssl_utils_initialize_ssl(const axis2_env_t *env, SSL_CTX *ctx,
-        axis2_socket_t socket)
+axis2_ssl_utils_initialize_ssl(
+    const axis2_env_t *env, 
+    SSL_CTX *ctx,
+    axis2_socket_t socket
+    )
 {
     SSL *ssl = NULL;
     BIO *sbio = NULL;
@@ -105,7 +151,11 @@
 }
 
 AXIS2_EXTERN axis2_status_t AXIS2_CALL
-axis2_ssl_utils_cleanup_ssl(const axis2_env_t *env, SSL_CTX *ctx, SSL *ssl)
+axis2_ssl_utils_cleanup_ssl(
+    const axis2_env_t *env,
+    SSL_CTX *ctx,
+    SSL *ssl
+    )
 {
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
 

Modified: webservices/axis2/trunk/c/modules/core/transport/http/sender/ssl/ssl_utils.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/modules/core/transport/http/sender/ssl/ssl_utils.h?view=diff&rev=507889&r1=507888&r2=507889
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/sender/ssl/ssl_utils.h (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/sender/ssl/ssl_utils.h Thu Feb 15
03:07:05 2007
@@ -31,14 +31,26 @@
 
 
 AXIS2_EXTERN SSL_CTX* AXIS2_CALL
-axis2_ssl_utils_initialize_ctx(const axis2_env_t *env, axis2_char_t *server_cert);
+axis2_ssl_utils_initialize_ctx(
+    const axis2_env_t *env,
+    axis2_char_t *server_cert,
+    axis2_char_t *key_file,
+    axis2_char_t *ssl_pp
+    );
 
 AXIS2_EXTERN SSL* AXIS2_CALL
-axis2_ssl_utils_initialize_ssl(const axis2_env_t *env, SSL_CTX *ctx, 
-                        axis2_socket_t socket);
+axis2_ssl_utils_initialize_ssl(
+    const axis2_env_t *env,
+    SSL_CTX *ctx,
+    axis2_socket_t socket
+    );
                         
 AXIS2_EXTERN axis2_status_t AXIS2_CALL
-axis2_ssl_utils_cleanup_ssl(const axis2_env_t *env, SSL_CTX *ctx, SSL *ssl);
+axis2_ssl_utils_cleanup_ssl(
+    const axis2_env_t *env,
+    SSL_CTX *ctx,
+    SSL *ssl
+    );
 
 #ifdef __cplusplus
 }

Modified: webservices/axis2/trunk/c/test/core/transport/http/test_http_transport.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/test/core/transport/http/test_http_transport.c?view=diff&rev=507889&r1=507888&r2=507889
==============================================================================
--- webservices/axis2/trunk/c/test/core/transport/http/test_http_transport.c (original)
+++ webservices/axis2/trunk/c/test/core/transport/http/test_http_transport.c Thu Feb 15 03:07:05
2007
@@ -189,10 +189,10 @@
     request_body = axis2_stream_create_basic(env);
     request = axis2_http_simple_request_create(env, request_line,
             NULL, 0, NULL);
-    url = axis2_url_create(env, "https", "localhost", 443,
+    url = axis2_url_create(env, "https", "localhost", 9090,
             NULL);
     /* Add an ssl certificate variable */
-    setenv("AXIS2_SSL_CA_FILE", "cert.pem", 1);
+    /*setenv("AXIS2_SSL_CA_FILE", "cert.pem", 1);*/
     header = axis2_http_header_create(env, "Host", AXIS2_URL_GET_SERVER(url, env));
     AXIS2_HTTP_SIMPLE_REQUEST_ADD_HEADER(request, env, header);
     client = axis2_http_client_create(env, url);



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message