commit 1aac24c

default  ·  2023-01-11 08:38:19 +0000 UTC
parent 1438d04
More keyId/signature tweaks.
3 files changed,  +7, -14
M http.c
M snac.h
+1, -6
 1@@ -139,11 +139,6 @@ int send_to_inbox(snac *snac, char *inbox, char *msg, d_char **payload, int *p_s
 2     response = http_signed_request(snac, "POST", inbox,
 3         NULL, j_msg, strlen(j_msg), &status, payload, p_size);
 4 
 5-    if (status == 400) {
 6-        snac_debug(snac, 0, xs_fmt("send_to_inbox error %d (response date: '%s')",
 7-            status, xs_dict_get(response, "date")));
 8-    }
 9-
10     xs_free(response);
11 
12     return status;
13@@ -839,7 +834,7 @@ int process_message(snac *snac, char *msg, char *req)
14     }
15 
16     /* check the signature */
17-    if (!check_signature(snac, req, actor_o)) {
18+    if (!check_signature(snac, req)) {
19         snac_log(snac, xs_fmt("bad signature %s", actor));
20         return 1;
21     }
M http.c
+5, -7
 1@@ -103,7 +103,7 @@ d_char *http_signed_request(snac *snac, char *method, char *url,
 2 }
 3 
 4 
 5-static int _check_signature(snac *snac, char *req, char *actor, char **err)
 6+static int _check_signature(snac *snac, char *req, char **err)
 7 /* check the signature */
 8 {
 9     char *sig_hdr = xs_dict_get(req, "signature");
10@@ -144,18 +144,16 @@ static int _check_signature(snac *snac, char *req, char *actor, char **err)
11         return 0;
12     }
13 
14-#if 0
15     /* strip the # from the keyId */
16     if ((p = strchr(keyId, '#')) != NULL)
17         *p = '\0';
18 
19-    /* the actor must already be here */
20     xs *actor = NULL;
21-    if (!valid_status(actor_get(snac, keyId, &actor))) {
22+
23+    if (!valid_status(actor_request(snac, keyId, &actor))) {
24         *err = xs_fmt("unknown actor %s", keyId);
25         return 0;
26     }
27-#endif
28 
29     if ((p = xs_dict_get(actor, "publicKey")) == NULL ||
30         ((pubkey = xs_dict_get(p, "publicKeyPem")) == NULL)) {
31@@ -212,13 +210,13 @@ static int _check_signature(snac *snac, char *req, char *actor, char **err)
32 }
33 
34 
35-int check_signature(snac *snac, char *req, char *actor)
36+int check_signature(snac *snac, char *req)
37 /* checks the signature and archives the error */
38 {
39     int ret;
40     xs *err = NULL;
41 
42-    if ((ret = _check_signature(snac, req, actor, &err)) == 0) {
43+    if ((ret = _check_signature(snac, req, &err)) == 0) {
44         snac_debug(snac, 1, xs_fmt("check_signature %s", err));
45 
46         xs *ntid = tid(0);
M snac.h
+1, -1
1@@ -139,7 +139,7 @@ d_char *http_signed_request(snac *snac, char *method, char *url,
2                         d_char *headers,
3                         d_char *body, int b_size,
4                         int *status, d_char **payload, int *p_size);
5-int check_signature(snac *snac, char *req, char *actor);
6+int check_signature(snac *snac, char *req);
7 
8 void httpd(void);
9