From 068068f40fc97f09525aaccf560a1be352abd159 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 25 May 2021 21:34:18 +0200 Subject: return signed error message with HTTP_GONE status if denomination is not currently valid for specified operation (#6889) --- src/exchange/taler-exchange-httpd_responses.c | 52 +++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'src/exchange/taler-exchange-httpd_responses.c') diff --git a/src/exchange/taler-exchange-httpd_responses.c b/src/exchange/taler-exchange-httpd_responses.c index 234074747..4bb3ffd48 100644 --- a/src/exchange/taler-exchange-httpd_responses.c +++ b/src/exchange/taler-exchange-httpd_responses.c @@ -466,6 +466,58 @@ TEH_RESPONSE_reply_unknown_denom_pub_hash ( } +MHD_RESULT +TEH_RESPONSE_reply_expired_denom_pub_hash ( + struct MHD_Connection *connection, + const struct GNUNET_HashCode *dph, + struct GNUNET_TIME_Absolute now, + enum TALER_ErrorCode ec, + const char *oper) +{ + struct TALER_ExchangePublicKeyP epub; + struct TALER_ExchangeSignatureP esig; + enum TALER_ErrorCode ecr; + struct TALER_DenominationExpiredAffirmationPS dua = { + .purpose.size = htonl (sizeof (dua)), + .purpose.purpose = htonl ( + TALER_SIGNATURE_EXCHANGE_AFFIRM_DENOM_EXPIRED), + .timestamp = GNUNET_TIME_absolute_hton (now), + .h_denom_pub = *dph, + }; + + strncpy (dua.operation, + oper, + sizeof (dua.operation)); + ecr = TEH_keys_exchange_sign (&dua, + &epub, + &esig); + if (TALER_EC_NONE != ecr) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + ec, + NULL); + } + return TALER_MHD_reply_json_pack ( + connection, + MHD_HTTP_GONE, + "{s:I,s:s,s:o,s:o,s:o,s:o}", + "code", + ec, + "oper", + oper, + "timestamp", + GNUNET_JSON_from_time_abs (now), + "exchange_pub", + GNUNET_JSON_from_data_auto (&epub), + "exchange_sig", + GNUNET_JSON_from_data_auto (&esig), + "h_denom_pub", + GNUNET_JSON_from_data_auto (dph)); +} + + /** * Send proof that a request is invalid to client because of * insufficient funds. This function will create a message with all -- cgit v1.2.3