diff options
Diffstat (limited to 'http.c')
| -rw-r--r-- | http.c | 35 |
1 files changed, 5 insertions, 30 deletions
| @@ -119,7 +119,7 @@ xs_dict *http_signed_request(snac *snac, const char *method, const char *url, | |||
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | 121 | ||
| 122 | static int _check_signature(snac *snac, char *req, char **err) | 122 | int check_signature(snac *snac, xs_dict *req, xs_str **err) |
| 123 | /* check the signature */ | 123 | /* check the signature */ |
| 124 | { | 124 | { |
| 125 | char *sig_hdr = xs_dict_get(req, "signature"); | 125 | char *sig_hdr = xs_dict_get(req, "signature"); |
| @@ -134,7 +134,8 @@ static int _check_signature(snac *snac, char *req, char **err) | |||
| 134 | { | 134 | { |
| 135 | /* extract the values */ | 135 | /* extract the values */ |
| 136 | xs *l = xs_split(sig_hdr, ","); | 136 | xs *l = xs_split(sig_hdr, ","); |
| 137 | char *v; | 137 | xs_list *p; |
| 138 | xs_val *v; | ||
| 138 | 139 | ||
| 139 | p = l; | 140 | p = l; |
| 140 | while (xs_list_iter(&p, &v)) { | 141 | while (xs_list_iter(&p, &v)) { |
| @@ -182,7 +183,8 @@ static int _check_signature(snac *snac, char *req, char **err) | |||
| 182 | 183 | ||
| 183 | { | 184 | { |
| 184 | xs *l = xs_split(headers, " "); | 185 | xs *l = xs_split(headers, " "); |
| 185 | char *v; | 186 | xs_list *p; |
| 187 | xs_val *v; | ||
| 186 | 188 | ||
| 187 | p = l; | 189 | p = l; |
| 188 | while (xs_list_iter(&p, &v)) { | 190 | while (xs_list_iter(&p, &v)) { |
| @@ -224,30 +226,3 @@ static int _check_signature(snac *snac, char *req, char **err) | |||
| 224 | 226 | ||
| 225 | return 1; | 227 | return 1; |
| 226 | } | 228 | } |
| 227 | |||
| 228 | |||
| 229 | int check_signature(snac *snac, char *req) | ||
| 230 | /* checks the signature and archives the error */ | ||
| 231 | { | ||
| 232 | int ret; | ||
| 233 | xs *err = NULL; | ||
| 234 | |||
| 235 | if ((ret = _check_signature(snac, req, &err)) == 0) { | ||
| 236 | snac_debug(snac, 1, xs_fmt("check_signature %s", err)); | ||
| 237 | |||
| 238 | xs *ntid = tid(0); | ||
| 239 | xs *fn = xs_fmt("%s/error/check_signature_%s", srv_basedir, ntid); | ||
| 240 | FILE *f; | ||
| 241 | |||
| 242 | if ((f = fopen(fn, "w")) != NULL) { | ||
| 243 | fprintf(f, "Error: %s\nRequest headers:\n", err); | ||
| 244 | |||
| 245 | xs *j = xs_json_dumps_pp(req, 4); | ||
| 246 | |||
| 247 | fwrite(j, strlen(j), 1, f); | ||
| 248 | fclose(f); | ||
| 249 | } | ||
| 250 | } | ||
| 251 | |||
| 252 | return ret; | ||
| 253 | } | ||