FreeBSD/contrib/subversion/subversion/libsvn_subr/ssl_server_trust_providers.c
/* retrieve ssl server CA failure overrides (if any) from servers
   config */
retrieve ssl server CA failure overrides (if any) from servers
config
retrieve ssl server CA failure overrides ( if any ) from servers config
static svn_error_t *
ssl_server_trust_file_first_credentials(void **credentials,
                                        void **iter_baton,
                                        void *provider_baton,
                                        apr_hash_t *parameters,
                                        const char *realmstring,
                                        apr_pool_t *pool)
{
  apr_uint32_t *failures = svn_hash_gets(parameters,
                                         SVN_AUTH_PARAM_SSL_SERVER_FAILURES);
  const svn_auth_ssl_server_cert_info_t *cert_info =
    svn_hash_gets(parameters, SVN_AUTH_PARAM_SSL_SERVER_CERT_INFO);
  apr_hash_t *creds_hash = NULL;
  const char *config_dir;
  svn_error_t *error = SVN_NO_ERROR;
  *credentials = NULL;
  *iter_baton = NULL;
  config_dir = svn_hash_gets(parameters, SVN_AUTH_PARAM_CONFIG_DIR);
  error =
    svn_config_read_auth_data(&creds_hash, SVN_AUTH_CRED_SSL_SERVER_TRUST,
                              realmstring, config_dir, pool);
  svn_error_clear(error);
  if (! error && creds_hash)
    {
      svn_string_t *trusted_cert, *this_cert, *failstr;
      apr_uint32_t last_failures = 0;
      trusted_cert = svn_hash_gets(creds_hash, SVN_CONFIG_AUTHN_ASCII_CERT_KEY);
      this_cert = svn_string_create(cert_info->ascii_cert, pool);
      failstr = svn_hash_gets(creds_hash, SVN_CONFIG_AUTHN_FAILURES_KEY);
      if (failstr)
        SVN_ERR(svn_cstring_atoui(&last_failures, failstr->data));
      if (trusted_cert &&
          svn_string_compare(this_cert, trusted_cert) &&
          (*failures & ~last_failures) == 0)
        {
          *failures = 0;
        }
    }
  if (! *failures)
    {
      svn_auth_cred_ssl_server_trust_t *creds =
        apr_pcalloc(pool, sizeof(*creds));
      creds->may_save = FALSE; 
      *credentials = creds;
    }
  return SVN_NO_ERROR;
}
static svn_error_t * ssl_server_trust_file_first_credentials ( void * * credentials , void * * iter_baton , void * provider_baton , apr_hash_t * parameters , const char * realmstring , apr_pool_t * pool ) { apr_uint32_t * failures = svn_hash_gets ( parameters , SVN_AUTH_PARAM_SSL_SERVER_FAILURES ) ; const svn_auth_ssl_server_cert_info_t * cert_info = svn_hash_gets ( parameters , SVN_AUTH_PARAM_SSL_SERVER_CERT_INFO ) ; apr_hash_t * creds_hash = NULL ; const char * config_dir ; svn_error_t * error = SVN_NO_ERROR ; * credentials = NULL ; * iter_baton = NULL ; config_dir = svn_hash_gets ( parameters , SVN_AUTH_PARAM_CONFIG_DIR ) ; error = svn_config_read_auth_data ( & creds_hash , SVN_AUTH_CRED_SSL_SERVER_TRUST , realmstring , config_dir , pool ) ; svn_error_clear ( error ) ; if ( ! error && creds_hash ) { svn_string_t * trusted_cert , * this_cert , * failstr ; apr_uint32_t last_failures = 0 ; trusted_cert = svn_hash_gets ( creds_hash , SVN_CONFIG_AUTHN_ASCII_CERT_KEY ) ; this_cert = svn_string_create ( cert_info -> ascii_cert , pool ) ; failstr = svn_hash_gets ( creds_hash , SVN_CONFIG_AUTHN_FAILURES_KEY ) ; if ( failstr ) SVN_ERR ( svn_cstring_atoui ( & last_failures , failstr -> data ) ) ; if ( trusted_cert && svn_string_compare ( this_cert , trusted_cert ) && ( * failures & ~ last_failures ) == 0 ) { * failures = 0 ; } } if ( ! * failures ) { svn_auth_cred_ssl_server_trust_t * creds = apr_pcalloc ( pool , sizeof ( * creds ) ) ; creds -> may_save = FALSE ; * credentials = creds ; } return SVN_NO_ERROR ; }
retrieve ssl server CA failure overrides (if any) from servers
config
retrieve ssl server CA failure overrides ( if any ) from servers config
/* Check if this is a permanently accepted certificate */ /* If the cert is trusted and there are no new failures, we
       * accept it by clearing all failures. */ /* If all failures are cleared now, we return the creds */ /* No need to save it again... */