You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by dr...@apache.org on 2007/03/28 18:05:04 UTC
svn commit: r523382 - in /apr/apr-util/trunk: include/apr_ssl.h
include/private/apr_ssl_private.h ssl/apr_ssl.c ssl/apr_ssl_openssl.c
test/echod.c test/sockperf.c test/testssl.c
Author: dreid
Date: Wed Mar 28 09:05:03 2007
New Revision: 523382
URL: http://svn.apache.org/viewvc?view=rev&rev=523382
Log:
Explicity state what type of factory we are creating rather than
trying to guess based on the arguments passed in, which was less
than optimal.
Highlighted by Joe Orton
Modified:
apr/apr-util/trunk/include/apr_ssl.h
apr/apr-util/trunk/include/private/apr_ssl_private.h
apr/apr-util/trunk/ssl/apr_ssl.c
apr/apr-util/trunk/ssl/apr_ssl_openssl.c
apr/apr-util/trunk/test/echod.c
apr/apr-util/trunk/test/sockperf.c
apr/apr-util/trunk/test/testssl.c
Modified: apr/apr-util/trunk/include/apr_ssl.h
URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/include/apr_ssl.h?view=diff&rev=523382&r1=523381&r2=523382
==============================================================================
--- apr/apr-util/trunk/include/apr_ssl.h (original)
+++ apr/apr-util/trunk/include/apr_ssl.h Wed Mar 28 09:05:03 2007
@@ -39,6 +39,14 @@
*/
/**
+ * Values that determine how a created factory will be used.
+ */
+typedef enum {
+ APR_SSL_FACTORY_SERVER, /**< Factory is for server operations */
+ APR_SSL_FACTORY_CLIENT, /**< Factory is for client operations */
+} apr_ssl_factory_type_e;
+
+/**
* Structure for referencing an ssl "factory"
*/
typedef struct apr_ssl_factory apr_ssl_factory_t;
@@ -54,23 +62,23 @@
const char *privateKeyFilename,
const char *certificateFilename,
const char *digestTypeToUse,
+ apr_ssl_factory_type_e purpose,
apr_pool_t *pool)
* @brief Attempts to create an SSL "factory". The "factory" is then
- * used to create sockets. If a private key filename
- * is passed then the created factory will assume it is to be used
- * in a server context.
+ * used to create sockets.
* @param newFactory The newly created factory
- * @param privateKeyFilename
+ * @param privateKeyFilename Private key filename to use
* @param certificateFilename X509 certificate file
* @param digestTypeToUse A string identifying the type of digest scheme
* to use
+ * @param purpose Constant that determines how the created factory will be used
* @param pool The pool to use for memory allocations
* @return an APR_ status code
*/
APU_DECLARE(apr_status_t) apr_ssl_factory_create(apr_ssl_factory_t **,
+ const char *, const char *,
const char *,
- const char *,
- const char *,
+ apr_ssl_factory_type_e,
apr_pool_t *);
/**
Modified: apr/apr-util/trunk/include/private/apr_ssl_private.h
URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/include/private/apr_ssl_private.h?view=diff&rev=523382&r1=523381&r2=523382
==============================================================================
--- apr/apr-util/trunk/include/private/apr_ssl_private.h (original)
+++ apr/apr-util/trunk/include/private/apr_ssl_private.h Wed Mar 28 09:05:03 2007
@@ -38,8 +38,9 @@
* SSL factory structure
*/
struct apr_ssl_factory {
- apr_pool_t *pool; /**< pool to use for memory allocations */
- apu_ssl_data_t *sslData; /**< Pointer to implementation specific data */
+ apr_pool_t *pool; /**< pool to use for memory allocations */
+ apr_ssl_factory_type_e purpose; /**< Purpose of the factory */
+ apu_ssl_data_t *sslData; /**< Pointer to implementation specific data */
};
/**
Modified: apr/apr-util/trunk/ssl/apr_ssl.c
URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/ssl/apr_ssl.c?view=diff&rev=523382&r1=523381&r2=523382
==============================================================================
--- apr/apr-util/trunk/ssl/apr_ssl.c (original)
+++ apr/apr-util/trunk/ssl/apr_ssl.c Wed Mar 28 09:05:03 2007
@@ -39,6 +39,7 @@
const char *privateKeyFn,
const char *certFn,
const char *digestType,
+ apr_ssl_factory_type_e why,
apr_pool_t *p)
{
@@ -60,6 +61,7 @@
*fact = NULL;
asf->pool = p;
+ asf->purpose = why;
if ((rv = apu_ssl_factory_create(asf, privateKeyFn, certFn,
digestType)) != APR_SUCCESS)
return rv;
Modified: apr/apr-util/trunk/ssl/apr_ssl_openssl.c
URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/ssl/apr_ssl_openssl.c?view=diff&rev=523382&r1=523381&r2=523382
==============================================================================
--- apr/apr-util/trunk/ssl/apr_ssl_openssl.c (original)
+++ apr/apr-util/trunk/ssl/apr_ssl_openssl.c Wed Mar 28 09:05:03 2007
@@ -58,6 +58,9 @@
sock->sslData->sslErr = SSL_get_error(sock->sslData->ssl, fncode);
}
+/* The apr_ssl_factory_t structure will have the pool and purpose
+ * fields set only.
+ */
apr_status_t apu_ssl_factory_create(apr_ssl_factory_t *asf,
const char *privateKeyFn,
const char *certFn,
@@ -68,7 +71,7 @@
return -1;
}
- if (privateKeyFn && certFn) {
+ if (asf->purpose == APR_SSL_FACTORY_SERVER) {
sslData->ctx = SSL_CTX_new(SSLv23_server_method());
if (sslData->ctx) {
if (!SSL_CTX_use_PrivateKey_file(sslData->ctx, privateKeyFn,
@@ -82,7 +85,7 @@
}
} else {
sslData->ctx = SSL_CTX_new(SSLv23_client_method());
- }
+ }
if (digestType) {
sslData->md = EVP_get_digestbyname(digestType);
Modified: apr/apr-util/trunk/test/echod.c
URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/test/echod.c?view=diff&rev=523382&r1=523381&r2=523382
==============================================================================
--- apr/apr-util/trunk/test/echod.c (original)
+++ apr/apr-util/trunk/test/echod.c Wed Mar 28 09:05:03 2007
@@ -154,7 +154,8 @@
printf("\tPrivate key: %s\n", keyFn);
printf("\tCertificate: %s\n", certFn);
- rv = apr_ssl_factory_create(&asf, keyFn, certFn, NULL, pool);
+ rv = apr_ssl_factory_create(&asf, keyFn, certFn, NULL,
+ APR_SSL_FACTORY_SERVER, pool);
if (rv != APR_SUCCESS) {
reportError("Unable to create an SSL factory!", rv, pool);
exit(1);
Modified: apr/apr-util/trunk/test/sockperf.c
URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/test/sockperf.c?view=diff&rev=523382&r1=523381&r2=523382
==============================================================================
--- apr/apr-util/trunk/test/sockperf.c (original)
+++ apr/apr-util/trunk/test/sockperf.c Wed Mar 28 09:05:03 2007
@@ -216,7 +216,8 @@
apr_pool_create(&pool, NULL);
- rv = apr_ssl_factory_create(&asf, NULL, NULL, NULL, pool);
+ rv = apr_ssl_factory_create(&asf, NULL, NULL, NULL,
+ APR_SSL_FACTORY_CLIENT, pool);
results = (struct testResult *)apr_pcalloc(pool,
sizeof(*results) * nTests);
Modified: apr/apr-util/trunk/test/testssl.c
URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/test/testssl.c?view=diff&rev=523382&r1=523381&r2=523382
==============================================================================
--- apr/apr-util/trunk/test/testssl.c (original)
+++ apr/apr-util/trunk/test/testssl.c Wed Mar 28 09:05:03 2007
@@ -206,7 +206,8 @@
exit(1);
}
- if (apr_ssl_factory_create(&asf, NULL, NULL, NULL, pool) != APR_SUCCESS) {
+ if (apr_ssl_factory_create(&asf, NULL, NULL, NULL,
+ APR_SSL_FACTORY_CLIENT, pool) != APR_SUCCESS) {
fprintf(stderr, "Unable to create client factory\n");
} else {
int i;