diff options
| author | 2023-01-10 18:21:00 +0100 | |
|---|---|---|
| committer | 2023-01-10 18:21:00 +0100 | |
| commit | 23eb05ee99dace9ba5d828334eac3eccbe1417e4 (patch) | |
| tree | 823d88e314f5f8029e90eaa4f436af621d2bac19 /http.c | |
| parent | Backport from xs. (diff) | |
| download | snac2-23eb05ee99dace9ba5d828334eac3eccbe1417e4.tar.gz snac2-23eb05ee99dace9ba5d828334eac3eccbe1417e4.tar.xz snac2-23eb05ee99dace9ba5d828334eac3eccbe1417e4.zip | |
Use the already loaded actor in check_signature().
Diffstat (limited to 'http.c')
| -rw-r--r-- | http.c | 8 |
1 files changed, 5 insertions, 3 deletions
| @@ -103,7 +103,7 @@ d_char *http_signed_request(snac *snac, char *method, char *url, | |||
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | 105 | ||
| 106 | static int _check_signature(snac *snac, char *req, char **err) | 106 | static int _check_signature(snac *snac, char *req, char *actor, char **err) |
| 107 | /* check the signature */ | 107 | /* check the signature */ |
| 108 | { | 108 | { |
| 109 | char *sig_hdr = xs_dict_get(req, "signature"); | 109 | char *sig_hdr = xs_dict_get(req, "signature"); |
| @@ -144,6 +144,7 @@ static int _check_signature(snac *snac, char *req, char **err) | |||
| 144 | return 0; | 144 | return 0; |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | #if 0 | ||
| 147 | /* strip the # from the keyId */ | 148 | /* strip the # from the keyId */ |
| 148 | if ((p = strchr(keyId, '#')) != NULL) | 149 | if ((p = strchr(keyId, '#')) != NULL) |
| 149 | *p = '\0'; | 150 | *p = '\0'; |
| @@ -154,6 +155,7 @@ static int _check_signature(snac *snac, char *req, char **err) | |||
| 154 | *err = xs_fmt("unknown actor %s", keyId); | 155 | *err = xs_fmt("unknown actor %s", keyId); |
| 155 | return 0; | 156 | return 0; |
| 156 | } | 157 | } |
| 158 | #endif | ||
| 157 | 159 | ||
| 158 | if ((p = xs_dict_get(actor, "publicKey")) == NULL || | 160 | if ((p = xs_dict_get(actor, "publicKey")) == NULL || |
| 159 | ((pubkey = xs_dict_get(p, "publicKeyPem")) == NULL)) { | 161 | ((pubkey = xs_dict_get(p, "publicKeyPem")) == NULL)) { |
| @@ -210,13 +212,13 @@ static int _check_signature(snac *snac, char *req, char **err) | |||
| 210 | } | 212 | } |
| 211 | 213 | ||
| 212 | 214 | ||
| 213 | int check_signature(snac *snac, char *req) | 215 | int check_signature(snac *snac, char *req, char *actor) |
| 214 | /* checks the signature and archives the error */ | 216 | /* checks the signature and archives the error */ |
| 215 | { | 217 | { |
| 216 | int ret; | 218 | int ret; |
| 217 | xs *err = NULL; | 219 | xs *err = NULL; |
| 218 | 220 | ||
| 219 | if ((ret = _check_signature(snac, req, &err)) == 0) { | 221 | if ((ret = _check_signature(snac, req, actor, &err)) == 0) { |
| 220 | snac_debug(snac, 1, xs_fmt("check_signature %s", err)); | 222 | snac_debug(snac, 1, xs_fmt("check_signature %s", err)); |
| 221 | 223 | ||
| 222 | xs *ntid = tid(0); | 224 | xs *ntid = tid(0); |