mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 05:15:04 +00:00
More keyId/signature tweaks.
This commit is contained in:
parent
1438d046a5
commit
1aac24ca75
3 changed files with 7 additions and 14 deletions
|
@ -139,11 +139,6 @@ int send_to_inbox(snac *snac, char *inbox, char *msg, d_char **payload, int *p_s
|
|||
response = http_signed_request(snac, "POST", inbox,
|
||||
NULL, j_msg, strlen(j_msg), &status, payload, p_size);
|
||||
|
||||
if (status == 400) {
|
||||
snac_debug(snac, 0, xs_fmt("send_to_inbox error %d (response date: '%s')",
|
||||
status, xs_dict_get(response, "date")));
|
||||
}
|
||||
|
||||
xs_free(response);
|
||||
|
||||
return status;
|
||||
|
@ -839,7 +834,7 @@ int process_message(snac *snac, char *msg, char *req)
|
|||
}
|
||||
|
||||
/* check the signature */
|
||||
if (!check_signature(snac, req, actor_o)) {
|
||||
if (!check_signature(snac, req)) {
|
||||
snac_log(snac, xs_fmt("bad signature %s", actor));
|
||||
return 1;
|
||||
}
|
||||
|
|
12
http.c
12
http.c
|
@ -103,7 +103,7 @@ d_char *http_signed_request(snac *snac, char *method, char *url,
|
|||
}
|
||||
|
||||
|
||||
static int _check_signature(snac *snac, char *req, char *actor, char **err)
|
||||
static int _check_signature(snac *snac, char *req, char **err)
|
||||
/* check the signature */
|
||||
{
|
||||
char *sig_hdr = xs_dict_get(req, "signature");
|
||||
|
@ -144,18 +144,16 @@ static int _check_signature(snac *snac, char *req, char *actor, char **err)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* strip the # from the keyId */
|
||||
if ((p = strchr(keyId, '#')) != NULL)
|
||||
*p = '\0';
|
||||
|
||||
/* the actor must already be here */
|
||||
xs *actor = NULL;
|
||||
if (!valid_status(actor_get(snac, keyId, &actor))) {
|
||||
|
||||
if (!valid_status(actor_request(snac, keyId, &actor))) {
|
||||
*err = xs_fmt("unknown actor %s", keyId);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((p = xs_dict_get(actor, "publicKey")) == NULL ||
|
||||
((pubkey = xs_dict_get(p, "publicKeyPem")) == NULL)) {
|
||||
|
@ -212,13 +210,13 @@ static int _check_signature(snac *snac, char *req, char *actor, char **err)
|
|||
}
|
||||
|
||||
|
||||
int check_signature(snac *snac, char *req, char *actor)
|
||||
int check_signature(snac *snac, char *req)
|
||||
/* checks the signature and archives the error */
|
||||
{
|
||||
int ret;
|
||||
xs *err = NULL;
|
||||
|
||||
if ((ret = _check_signature(snac, req, actor, &err)) == 0) {
|
||||
if ((ret = _check_signature(snac, req, &err)) == 0) {
|
||||
snac_debug(snac, 1, xs_fmt("check_signature %s", err));
|
||||
|
||||
xs *ntid = tid(0);
|
||||
|
|
2
snac.h
2
snac.h
|
@ -139,7 +139,7 @@ d_char *http_signed_request(snac *snac, char *method, char *url,
|
|||
d_char *headers,
|
||||
d_char *body, int b_size,
|
||||
int *status, d_char **payload, int *p_size);
|
||||
int check_signature(snac *snac, char *req, char *actor);
|
||||
int check_signature(snac *snac, char *req);
|
||||
|
||||
void httpd(void);
|
||||
|
||||
|
|
Loading…
Reference in a new issue