[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] Miscellaneous SSL changes

From: David Waite <mass_at_akuma.org>
Date: 2003-03-28 07:29:36 CET

This is the new combined patchset. I was having great difficulties
getting the patch to not wrap using my available mail agents, so I'm
just including a text attachment with the log entry and patch.

Fixes for a number of issues which have come up since the ssl merge:
   remove neon values injected into the auth_baton hash
   return null iter_baton
   use void *prompt_baton instead of void **prompt_baton
   strict aliasing warnings
   error handling
   strict ssl-ignore flag checking
   do not return server validation credentials which are known to not be
      adequate for approving the connection

-David Waite

Fixes for a number of issues which have come up since the ssl merge:
   remove neon values injected into the auth_baton hash
   return null iter_baton
   use void *prompt_baton instead of void **prompt_baton
   strict aliasing warnings
   error handling
   strict ssl-ignore flag checking
   do not return server validation credentials which are known to not be
      adequate for approving the connection

* include/svn_auth.h
  (SVN_AUTH_PARAM_SSL_SERVER_DNAME,
   SVN_AUTH_PARAM_SSL_SERVER_CERTIFICATE) : remove
* include/svn_client.h
  (svn_client_get_ssl_server_file_provider,
   svn_client_get_ssl_client_file_provider,
   svn_client_get_ssl_pw_file_provider) : change void **prompt_baton
      to void *prompt_baton
* libsvn_client/auth.c
  (server_ssl_file_first_credentials,
   client_ssl_cert_file_first_credentials,
   client_ssl_pw_file_first_credentials,
   client_ssl_pw_prompt_first_cred,
   client_ssl_prompt_first_cred,
   server_ssl_prompt_first_cred) : set iter_baton reference to NULL
  (svn_client_get_ssl_server_file_provider,
   svn_client_get_ssl_client_file_provider,
   svn_client_get_ssl_pw_file_provider) : see above
  (server_ssl_file_first_credentials,
   server_ssl_prompt_first_cred) : do not return credentials if not all
   failures were approved
  (server_ssl_file_first_credentials) : Chris Foote's server file changes -
     stringently verify ssl-ignore-unknown-ca, ssl-ignore-invalid-date, and
     ssl-ignore-host-mismatch options are set to "true".
* libsvn_ra_dav/session.c
  (server_ssl_callback): remove SVN_AUTH_PARAM_SSL_SERVER_CERTIFICATE
     initializer, use intermediate "void *creds" to avoid aliasing warning
  (client_ssl_keypw_callback, client_ssl_callback): use intermediate
     "void *creds" to avoid aliasing warning

Index: subversion/include/svn_client.h
===================================================================
--- subversion/include/svn_client.h (revision 5486)
+++ subversion/include/svn_client.h (working copy)
@@ -200,7 +200,7 @@
 svn_client_get_ssl_server_prompt_provider(const svn_auth_provider_t **provider,
                                           void **provider_baton,
                                           svn_client_prompt_t prompt_func,
- void **prompt_baton,
+ void *prompt_baton,
                                           apr_pool_t *pool);
 
 /** Set @a *provider and @ *provider_baton to an authentication
@@ -215,7 +215,7 @@
 svn_client_get_ssl_client_prompt_provider(const svn_auth_provider_t **provider,
                                           void **provider_baton,
                                           svn_client_prompt_t prompt_func,
- void **prompt_baton,
+ void *prompt_baton,
                                           apr_pool_t *pool);
 
 /** Set @a *provider and @ *provider_baton to an authentication
@@ -230,7 +230,7 @@
 svn_client_get_ssl_pw_prompt_provider(const svn_auth_provider_t **provider,
                                       void **provider_baton,
                                       svn_client_prompt_t prompt_func,
- void **prompt_baton,
+ void *prompt_baton,
                                       apr_pool_t *pool);
 
 
Index: subversion/include/svn_auth.h
===================================================================
--- subversion/include/svn_auth.h (revision 5486)
+++ subversion/include/svn_auth.h (working copy)
@@ -282,13 +282,6 @@
     Property value is irrelevant; only property's existence matters. */
 #define SVN_AUTH_PARAM_NO_AUTH_CACHE SVN_AUTH_PARAM_PREFIX "no-auth-cache"
 
-/** Available for ssl client cert providers, provides a @c ne_ssl_dname* */
-#define SVN_AUTH_PARAM_SSL_SERVER_DNAME SVN_AUTH_PARAM_PREFIX "ssl:dname"
-/** Available for ssl server cert providers, provides a full
- @c ne_ssl_certificate* */
-#define SVN_AUTH_PARAM_SSL_SERVER_CERTIFICATE SVN_AUTH_PARAM_PREFIX \
- "ssl:server-cert"
-
 /** The following property is for ssl server cert providers. This
     provides the detected failures by the certificate validator */
 #define SVN_AUTH_PARAM_SSL_SERVER_FAILURES_IN SVN_AUTH_PARAM_PREFIX \
Index: subversion/libsvn_client/auth.c
===================================================================
--- subversion/libsvn_client/auth.c (revision 5486)
+++ subversion/libsvn_client/auth.c (working copy)
@@ -425,31 +425,55 @@
                                    apr_pool_t *pool)
 {
   const char *temp_setting;
+ int failures_in = (int) apr_hash_get (parameters,
+ SVN_AUTH_PARAM_SSL_SERVER_FAILURES_IN,
+ APR_HASH_KEY_STRING);
   svn_config_t *cfg = apr_hash_get (parameters,
                                     SVN_AUTH_PARAM_CONFIG,
                                     APR_HASH_KEY_STRING);
   const char *server_group = apr_hash_get (parameters,
                                            SVN_AUTH_PARAM_SERVER_GROUP,
                                            APR_HASH_KEY_STRING);
+ svn_auth_cred_server_ssl_t *cred;
+ int failures_allow = 0;
 
- svn_auth_cred_server_ssl_t *cred =
- apr_palloc (pool, sizeof(svn_auth_cred_server_ssl_t));
+ temp_setting = svn_config_get_server_setting (cfg, server_group,
+ "ssl-ignore-unknown-ca",
+ "false");
+ if (strcasecmp (temp_setting, "true") == 0)
+ {
+ failures_allow |= SVN_AUTH_SSL_UNKNOWNCA;
+ }
 
- cred->failures_allow = 0;
   temp_setting = svn_config_get_server_setting (cfg, server_group,
- "ssl-ignore-unknown-ca", NULL);
- cred->failures_allow = temp_setting ? SVN_AUTH_SSL_UNKNOWNCA : 0;
- temp_setting = svn_config_get_server_setting (cfg, server_group,
                                                 "ssl-ignore-host-mismatch",
- NULL);
- cred->failures_allow |= temp_setting ? SVN_AUTH_SSL_CNMISMATCH : 0;
+ "false");
+ if (strcasecmp (temp_setting, "true") == 0)
+ {
+ failures_allow |= SVN_AUTH_SSL_CNMISMATCH;
+ }
+
   temp_setting = svn_config_get_server_setting (cfg, server_group,
                                                 "ssl-ignore-invalid-date",
- NULL);
- cred->failures_allow |=
- temp_setting ? (SVN_AUTH_SSL_NOTYETVALID | SVN_AUTH_SSL_EXPIRED) : 0;
+ "false");
+ if (strcasecmp (temp_setting, "true") == 0)
+ {
+ failures_allow |= SVN_AUTH_SSL_NOTYETVALID | SVN_AUTH_SSL_EXPIRED;
+ }
 
- *credentials = cred;
+ /* don't return creds unless we consider the certificate completely
+ * acceptable */
+ if ( (failures_in & ~failures_allow) == 0)
+ {
+ cred = apr_palloc (pool, sizeof(svn_auth_cred_server_ssl_t));
+ *credentials = cred;
+ cred->failures_allow = failures_allow;
+ }
+ else
+ {
+ *credentials = NULL;
+ }
+ *iter_baton = NULL;
   return SVN_NO_ERROR;
 }
 
@@ -507,6 +531,7 @@
       *credentials = NULL;
     }
 
+ *iter_baton = NULL;
   return SVN_NO_ERROR;
 }
 
@@ -537,7 +562,7 @@
       *credentials = cred;
     }
   else *credentials = NULL;
-
+ *iter_baton = NULL;
   return SVN_NO_ERROR;
 }
 
@@ -621,7 +646,7 @@
     {
       *credentials = NULL;
     }
-
+ *iter_baton = NULL;
   return SVN_NO_ERROR;
 }
 
@@ -695,7 +720,7 @@
   cred->key_file = key_file;
   cred->cert_type = cert_type;
   *credentials = cred;
-
+ *iter_baton = NULL;
   return SVN_NO_ERROR;
 }
 
@@ -751,17 +776,17 @@
   SVN_ERR(pb->prompt_func (&choice, buf->data, FALSE,
                            pb->prompt_baton, pool));
   
- cred = apr_palloc (pool, sizeof(*cred));
   if (choice && (choice[0] == 'y' || choice[0] == 'Y'))
     {
+ cred = apr_palloc (pool, sizeof(*cred));
       cred->failures_allow = failures_in;
+ *credentials = cred;
     }
   else
     {
- cred->failures_allow = 0;
+ *credentials = NULL;
     }
- *credentials = cred;
-
+ *iter_baton = NULL;
   return SVN_NO_ERROR;
 }
 
@@ -795,7 +820,7 @@
 svn_client_get_ssl_server_prompt_provider (const svn_auth_provider_t **provider,
                                            void **provider_baton,
                                            svn_client_prompt_t prompt_func,
- void **prompt_baton,
+ void *prompt_baton,
                                            apr_pool_t *pool)
 {
   cred_ssl_provider_baton *pb = apr_palloc (pool, sizeof(*pb));
@@ -809,7 +834,7 @@
 svn_client_get_ssl_client_prompt_provider (const svn_auth_provider_t **provider,
                                            void **provider_baton,
                                            svn_client_prompt_t prompt_func,
- void **prompt_baton,
+ void *prompt_baton,
                                            apr_pool_t *pool)
 {
   cred_ssl_provider_baton *pb = apr_palloc (pool, sizeof(*pb));
@@ -823,7 +848,7 @@
 svn_client_get_ssl_pw_prompt_provider (const svn_auth_provider_t **provider,
                                        void **provider_baton,
                                        svn_client_prompt_t prompt_func,
- void **prompt_baton,
+ void *prompt_baton,
                                        apr_pool_t *pool)
 {
   cred_ssl_provider_baton *pb = apr_palloc (pool, sizeof(*pb));
Index: subversion/libsvn_ra_dav/session.c
===================================================================
--- subversion/libsvn_ra_dav/session.c (revision 5486)
+++ subversion/libsvn_ra_dav/session.c (working copy)
@@ -102,16 +102,14 @@
                     const ne_ssl_certificate *cert)
 {
   svn_ra_session_t *ras = userdata;
- svn_auth_cred_server_ssl_t *credentials;
   void *creds;
+ svn_auth_cred_server_ssl_t *server_creds;
   svn_auth_iterstate_t *state;
   apr_pool_t *pool;
   svn_error_t *error;
- int failures_allowed;
-
+ int failures_allowed = 0;
+
   svn_auth_set_parameter(ras->callbacks->auth_baton,
- SVN_AUTH_PARAM_SSL_SERVER_CERTIFICATE, cert);
- svn_auth_set_parameter(ras->callbacks->auth_baton,
                          SVN_AUTH_PARAM_SSL_SERVER_FAILURES_IN,
                          (void*)failures);
 
@@ -120,10 +118,16 @@
                                      SVN_AUTH_CRED_SERVER_SSL,
                                      ras->callbacks->auth_baton,
                                      pool);
- credentials = creds;
- failures_allowed = (credentials) ? credentials->failures_allow : 0;
+ if (error || !creds)
+ {
+ svn_error_clear(error);
+ }
+ else
+ {
+ server_creds = creds;
+ failures_allowed = (server_creds) ? server_creds->failures_allow : 0;
+ }
   apr_pool_destroy(pool);
-
   return (failures & ~failures_allowed);
 }
 
@@ -131,8 +135,8 @@
 client_ssl_keypw_callback(void *userdata, char *pwbuf, size_t len)
 {
   svn_ra_session_t *ras = userdata;
- svn_auth_cred_client_ssl_pass_t *credentials;
   void *creds;
+ svn_auth_cred_client_ssl_pass_t *pw_creds = NULL;
   svn_auth_iterstate_t *state;
   apr_pool_t *pool;
   svn_error_t *error;
@@ -142,13 +146,20 @@
                                      SVN_AUTH_CRED_CLIENT_PASS_SSL,
                                      ras->callbacks->auth_baton,
                                      pool);
- credentials = creds;
- if (credentials)
+ if (error || !creds)
     {
- strncpy(pwbuf, credentials->password, len);
+ svn_error_clear(error);
     }
+ else
+ {
+ pw_creds = creds;
+ if (pw_creds)
+ {
+ strncpy(pwbuf, pw_creds->password, len);
+ }
+ }
   apr_pool_destroy(pool);
- return (credentials == NULL);
+ return (pw_creds == NULL);
 }
 
 static void
@@ -156,8 +167,8 @@
                     const ne_ssl_dname *server)
 {
   svn_ra_session_t *ras = userdata;
- svn_auth_cred_client_ssl_t *credentials;
   void *creds;
+ svn_auth_cred_client_ssl_t *client_creds;
   svn_auth_iterstate_t *state;
   apr_pool_t *pool;
   svn_error_t *error;
@@ -166,17 +177,25 @@
                                      SVN_AUTH_CRED_CLIENT_SSL,
                                      ras->callbacks->auth_baton,
                                      pool);
- credentials = creds;
- if(credentials)
+ if (error || !creds)
     {
- if(credentials->cert_type == svn_auth_ssl_pem_cert_type)
+ svn_error_clear(error);
+ }
+ else
+ {
+ client_creds = creds;
+ if (client_creds)
         {
- ne_ssl_load_pem(sess, credentials->cert_file, credentials->key_file);
+ if (client_creds->cert_type == svn_auth_ssl_pem_cert_type)
+ {
+ ne_ssl_load_pem(sess, client_creds->cert_file,
+ client_creds->key_file);
+ }
+ else
+ {
+ ne_ssl_load_pkcs12(sess, client_creds->cert_file);
+ }
         }
- else
- {
- ne_ssl_load_pkcs12(sess, credentials->cert_file);
- }
     }
   apr_pool_destroy(pool);
 }

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Mar 28 07:30:32 2003

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.