commit 23eb05e

default  ·  2023-01-10 17:21:00 +0000 UTC
parent d2eae2b
Use the already loaded actor in check_signature().
3 files changed,  +7, -5
M http.c
M snac.h
+1, -1
1@@ -839,7 +839,7 @@ int process_message(snac *snac, char *msg, char *req)
2     }
3 
4     /* check the signature */
5-    if (!check_signature(snac, req)) {
6+    if (!check_signature(snac, req, actor_o)) {
7         snac_log(snac, xs_fmt("bad signature"));
8         return 1;
9     }
M http.c
+5, -3
 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 **err)
 6+static int _check_signature(snac *snac, char *req, char *actor, char **err)
 7 /* check the signature */
 8 {
 9     char *sig_hdr = xs_dict_get(req, "signature");
10@@ -144,6 +144,7 @@ static int _check_signature(snac *snac, char *req, 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@@ -154,6 +155,7 @@ static int _check_signature(snac *snac, char *req, char **err)
19         *err = xs_fmt("unknown actor %s", keyId);
20         return 0;
21     }
22+#endif
23 
24     if ((p = xs_dict_get(actor, "publicKey")) == NULL ||
25         ((pubkey = xs_dict_get(p, "publicKeyPem")) == NULL)) {
26@@ -210,13 +212,13 @@ static int _check_signature(snac *snac, char *req, char **err)
27 }
28 
29 
30-int check_signature(snac *snac, char *req)
31+int check_signature(snac *snac, char *req, char *actor)
32 /* checks the signature and archives the error */
33 {
34     int ret;
35     xs *err = NULL;
36 
37-    if ((ret = _check_signature(snac, req, &err)) == 0) {
38+    if ((ret = _check_signature(snac, req, actor, &err)) == 0) {
39         snac_debug(snac, 1, xs_fmt("check_signature %s", err));
40 
41         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);
6+int check_signature(snac *snac, char *req, char *actor);
7 
8 void httpd(void);
9