fix regression introduced by addition of 'revoke' field

This commit is contained in:
Christian Grothoff 2020-03-13 19:13:36 +01:00
parent e05ce36f30
commit dc02821d8f
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
5 changed files with 49 additions and 30 deletions

View File

@ -318,7 +318,7 @@ version_completed_cb (void *cls,
response_code = 0; response_code = 0;
break; break;
} }
auditor->retry_delay = GNUNET_TIME_UNIT_ZERO; auditor->retry_delay = GNUNET_TIME_UNIT_ZERO; /* restart quickly */
break; break;
default: default:
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@ -443,6 +443,7 @@ TALER_AUDITOR_connect (struct GNUNET_CURL_Context *ctx,
GNUNET_CURL_append_header (ctx, GNUNET_CURL_append_header (ctx,
"Expect:")); "Expect:"));
auditor = GNUNET_new (struct TALER_AUDITOR_Handle); auditor = GNUNET_new (struct TALER_AUDITOR_Handle);
auditor->retry_delay = GNUNET_TIME_UNIT_SECONDS; /* start slowly */
auditor->ctx = ctx; auditor->ctx = ctx;
auditor->url = GNUNET_strdup (url); auditor->url = GNUNET_strdup (url);
auditor->version_cb = version_cb; auditor->version_cb = version_cb;

View File

@ -756,7 +756,7 @@ update_auditors (struct TALER_EXCHANGE_Handle *exchange)
/** /**
* Compare two denomination keys. * Compare two denomination keys. Ignores revocation data.
* *
* @param denom1 first denomination key * @param denom1 first denomination key
* @param denom2 second denomination key * @param denom2 second denomination key
@ -769,6 +769,9 @@ denoms_cmp (struct TALER_EXCHANGE_DenomPublicKey *denom1,
{ {
struct GNUNET_CRYPTO_RsaPublicKey *tmp1; struct GNUNET_CRYPTO_RsaPublicKey *tmp1;
struct GNUNET_CRYPTO_RsaPublicKey *tmp2; struct GNUNET_CRYPTO_RsaPublicKey *tmp2;
int r1;
int r2;
int ret;
/* First check if pub is the same. */ /* First check if pub is the same. */
if (0 != GNUNET_CRYPTO_rsa_public_key_cmp if (0 != GNUNET_CRYPTO_rsa_public_key_cmp
@ -778,24 +781,19 @@ denoms_cmp (struct TALER_EXCHANGE_DenomPublicKey *denom1,
tmp1 = denom1->key.rsa_public_key; tmp1 = denom1->key.rsa_public_key;
tmp2 = denom2->key.rsa_public_key; tmp2 = denom2->key.rsa_public_key;
r1 = denom1->revoked;
r2 = denom2->revoked;
denom1->key.rsa_public_key = NULL; denom1->key.rsa_public_key = NULL;
denom2->key.rsa_public_key = NULL; denom2->key.rsa_public_key = NULL;
/* Then procede with the rest of the object. */ /* Then procede with the rest of the object. */
if (0 != GNUNET_memcmp (denom1, ret = GNUNET_memcmp (denom1,
denom2)) denom2);
{ denom1->revoked = r1;
denom1->key.rsa_public_key = tmp1; denom2->revoked = r2;
denom2->key.rsa_public_key = tmp2;
return 1;
}
denom1->key.rsa_public_key = tmp1; denom1->key.rsa_public_key = tmp1;
denom2->key.rsa_public_key = tmp2; denom2->key.rsa_public_key = tmp2;
return ret;
return 0;
} }
@ -935,6 +933,9 @@ decode_keys_json (const json_t *resp_obj,
struct TALER_EXCHANGE_DenomPublicKey dk; struct TALER_EXCHANGE_DenomPublicKey dk;
int found = GNUNET_NO; int found = GNUNET_NO;
memset (&dk,
0,
sizeof (dk));
EXITIF (GNUNET_SYSERR == EXITIF (GNUNET_SYSERR ==
parse_json_denomkey (&dk, parse_json_denomkey (&dk,
check_sig, check_sig,
@ -956,7 +957,7 @@ decode_keys_json (const json_t *resp_obj,
if (GNUNET_YES == found) if (GNUNET_YES == found)
{ {
/* 0:0:0 did not support /keys cherry picking */ /* 0:0:0 did not support /keys cherry picking */
TALER_LOG_DEBUG ("Skipping denomination key: already know it\n");
/* Okay, but why breaking here? It could be that the /* Okay, but why breaking here? It could be that the
* user redownloaded all the keys in a forced way. */ * user redownloaded all the keys in a forced way. */
GNUNET_break_op (0 == current); GNUNET_break_op (0 == current);
@ -970,7 +971,7 @@ decode_keys_json (const json_t *resp_obj,
key_data->denom_keys[key_data->num_denom_keys++] = dk; key_data->denom_keys[key_data->num_denom_keys++] = dk;
/* Update "last_denom_issue_date" */ /* Update "last_denom_issue_date" */
TALER_LOG_DEBUG ("Crawling DK 'valid_from': %s\n", TALER_LOG_DEBUG ("Adding denomination key that is valid_from %s\n",
GNUNET_STRINGS_absolute_time_to_string (dk.valid_from)); GNUNET_STRINGS_absolute_time_to_string (dk.valid_from));
key_data->last_denom_issue_date key_data->last_denom_issue_date
= GNUNET_TIME_absolute_max (key_data->last_denom_issue_date, = GNUNET_TIME_absolute_max (key_data->last_denom_issue_date,
@ -1012,6 +1013,11 @@ decode_keys_json (const json_t *resp_obj,
found = GNUNET_YES; found = GNUNET_YES;
/* Merge denomination key signatures of downloaded /keys into existing /* Merge denomination key signatures of downloaded /keys into existing
auditor information 'aix'. */ auditor information 'aix'. */
TALER_LOG_DEBUG (
"Merging %u new audited keys with %u known audited keys\n",
aix->num_denom_keys,
ai.num_denom_keys);
GNUNET_array_grow (aix->denom_keys, GNUNET_array_grow (aix->denom_keys,
aix->num_denom_keys, aix->num_denom_keys,
aix->num_denom_keys + ai.num_denom_keys); aix->num_denom_keys + ai.num_denom_keys);
@ -1212,8 +1218,8 @@ TALER_EXCHANGE_check_keys_current (struct TALER_EXCHANGE_Handle *exchange,
if (GNUNET_YES == pull_all_keys) if (GNUNET_YES == pull_all_keys)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Forcing re-download of all keys\n"); "Forcing re-download of all exchange keys\n");
GNUNET_break (GNUNET_YES == force_download); GNUNET_break (GNUNET_YES == force_download);
exchange->state = MHS_INIT; exchange->state = MHS_INIT;
} }
@ -1291,7 +1297,7 @@ keys_completed_cb (void *cls,
for (unsigned int i = 0; i<kd_old.num_denom_keys; i++) for (unsigned int i = 0; i<kd_old.num_denom_keys; i++)
kd.denom_keys[i].key.rsa_public_key kd.denom_keys[i].key.rsa_public_key
= GNUNET_CRYPTO_rsa_public_key_dup ( = GNUNET_CRYPTO_rsa_public_key_dup (
kd_old.denom_keys[i].key.rsa_public_key); kd_old.denom_keys[i].key.rsa_public_key);
kd.num_auditors = kd_old.num_auditors; kd.num_auditors = kd_old.num_auditors;
kd.auditors = GNUNET_new_array (kd.num_auditors, kd.auditors = GNUNET_new_array (kd.num_auditors,
@ -1365,8 +1371,8 @@ keys_completed_cb (void *cls,
exchange->kr = NULL; exchange->kr = NULL;
free_keys_request (kr); free_keys_request (kr);
exchange->state = MHS_FAILED; exchange->state = MHS_FAILED;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"/keys download failed\n"); "Exchange keys download failed\n");
if (NULL != exchange->key_data_raw) if (NULL != exchange->key_data_raw)
{ {
json_decref (exchange->key_data_raw); json_decref (exchange->key_data_raw);
@ -1384,6 +1390,8 @@ keys_completed_cb (void *cls,
exchange->key_data_expiration = kr->expire; exchange->key_data_expiration = kr->expire;
free_keys_request (kr); free_keys_request (kr);
exchange->state = MHS_CERT; exchange->state = MHS_CERT;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Successfully downloaded exchange's keys\n");
update_auditors (exchange); update_auditors (exchange);
/* notify application about the key information */ /* notify application about the key information */
exchange->cert_cb (exchange->cert_cb_cls, exchange->cert_cb (exchange->cert_cb_cls,
@ -1604,6 +1612,8 @@ deserialize_data (struct TALER_EXCHANGE_Handle *exchange,
exchange->key_data = key_data; exchange->key_data = key_data;
exchange->key_data_expiration = expire; exchange->key_data_expiration = expire;
exchange->state = MHS_CERT; exchange->state = MHS_CERT;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Successfully loaded exchange's keys via deserialization\n");
update_auditors (exchange); update_auditors (exchange);
/* notify application about the key information */ /* notify application about the key information */
exchange->cert_cb (exchange->cert_cb_cls, exchange->cert_cb (exchange->cert_cb_cls,

View File

@ -148,6 +148,7 @@ test_auditor_api_LDADD = \
test_auditor_api_version_SOURCES = \ test_auditor_api_version_SOURCES = \
test_auditor_api_version.c test_auditor_api_version.c
test_auditor_api_version_LDADD = \ test_auditor_api_version_LDADD = \
libtalertesting.la \
$(top_builddir)/src/lib/libtalerauditor.la \ $(top_builddir)/src/lib/libtalerauditor.la \
$(LIBGCRYPT_LIBS) \ $(LIBGCRYPT_LIBS) \
$(top_builddir)/src/util/libtalerutil.la \ $(top_builddir)/src/util/libtalerutil.la \

View File

@ -151,8 +151,16 @@ main (int argc,
" is your PATH correct?\n"); " is your PATH correct?\n");
return 77; return 77;
} }
GNUNET_SCHEDULER_run (&run, if (0 != TALER_TESTING_wait_auditor_ready ("http://localhost:8083/"))
NULL); {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to launch `taler-auditor-httpd`\n");
}
else
{
GNUNET_SCHEDULER_run (&run,
NULL);
}
GNUNET_OS_process_kill (proc, SIGTERM); GNUNET_OS_process_kill (proc, SIGTERM);
GNUNET_OS_process_wait (proc); GNUNET_OS_process_wait (proc);
GNUNET_OS_process_destroy (proc); GNUNET_OS_process_destroy (proc);

View File

@ -69,12 +69,12 @@ struct CheckKeysState
/** /**
* Value X to set as the URL parameter: * Value X to set as the URL parameter:
* "/keys?last_denom_issue=X" is used only when `set_last_denom' * "/keys?last_denom_issue=X" is used only when `set_last_denom'
* equals GNUNET_YES. * equals #GNUNET_YES.
*/ */
struct GNUNET_TIME_Absolute last_denom_date; struct GNUNET_TIME_Absolute last_denom_date;
/** /**
* If GNUNET_YES, then we'll provide the "/keys" request. * If #GNUNET_YES, then we'll provide the "/keys" request.
* with the "now" argument. * with the "now" argument.
*/ */
int with_now; int with_now;
@ -160,11 +160,10 @@ check_keys_run (void *cls,
{ {
/* Did not get the expected number of denomination keys! */ /* Did not get the expected number of denomination keys! */
GNUNET_break (0); GNUNET_break (0);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, TALER_LOG_ERROR ("Got %u keys in step %s, expected %u\n",
"Got %u keys in step %s, expected %u\n", is->keys->num_denom_keys,
is->keys->num_denom_keys, cmd->label,
cmd->label, cks->num_denom_keys);
cks->num_denom_keys);
TALER_TESTING_interpreter_fail (is); TALER_TESTING_interpreter_fail (is);
return; return;
} }