diff options
Diffstat (limited to 'http.c')
| -rw-r--r-- | http.c | 19 |
1 files changed, 18 insertions, 1 deletions
| @@ -109,6 +109,8 @@ int check_signature(snac *snac, char *req) | |||
| 109 | xs *keyId = NULL; | 109 | xs *keyId = NULL; |
| 110 | xs *headers = NULL; | 110 | xs *headers = NULL; |
| 111 | xs *signature = NULL; | 111 | xs *signature = NULL; |
| 112 | xs *created = NULL; | ||
| 113 | xs *expires = NULL; | ||
| 112 | char *pubkey; | 114 | char *pubkey; |
| 113 | char *p; | 115 | char *p; |
| 114 | 116 | ||
| @@ -127,6 +129,12 @@ int check_signature(snac *snac, char *req) | |||
| 127 | else | 129 | else |
| 128 | if (xs_startswith(v, "signature")) | 130 | if (xs_startswith(v, "signature")) |
| 129 | signature = xs_crop(xs_dup(v), 11, -1); | 131 | signature = xs_crop(xs_dup(v), 11, -1); |
| 132 | else | ||
| 133 | if (xs_startswith(v, "created")) | ||
| 134 | created = xs_crop(xs_dup(v), 9, -1); | ||
| 135 | else | ||
| 136 | if (xs_startswith(v, "expires")) | ||
| 137 | expires = xs_crop(xs_dup(v), 9, -1); | ||
| 130 | } | 138 | } |
| 131 | } | 139 | } |
| 132 | 140 | ||
| @@ -170,6 +178,14 @@ int check_signature(snac *snac, char *req) | |||
| 170 | if (strcmp(v, "(request-target)") == 0) { | 178 | if (strcmp(v, "(request-target)") == 0) { |
| 171 | ss = xs_fmt("%s: post %s", v, xs_dict_get(req, "path")); | 179 | ss = xs_fmt("%s: post %s", v, xs_dict_get(req, "path")); |
| 172 | } | 180 | } |
| 181 | else | ||
| 182 | if (strcmp(v, "(created)") == 0) { | ||
| 183 | ss = xs_fmt("%s: %s", v, created); | ||
| 184 | } | ||
| 185 | else | ||
| 186 | if (strcmp(v, "(expires)") == 0) { | ||
| 187 | ss = xs_fmt("%s: %s", v, expires); | ||
| 188 | } | ||
| 173 | else { | 189 | else { |
| 174 | /* add the header */ | 190 | /* add the header */ |
| 175 | if ((hc = xs_dict_get(req, v)) == NULL) { | 191 | if ((hc = xs_dict_get(req, v)) == NULL) { |
| @@ -187,7 +203,8 @@ int check_signature(snac *snac, char *req) | |||
| 187 | } | 203 | } |
| 188 | 204 | ||
| 189 | if (xs_evp_verify(pubkey, sig_str, strlen(sig_str), signature) != 1) { | 205 | if (xs_evp_verify(pubkey, sig_str, strlen(sig_str), signature) != 1) { |
| 190 | snac_debug(snac, 1, xs_fmt("rsa verify error %s", keyId)); | 206 | snac_debug(snac, 0, xs_fmt("rsa verify error %s", keyId)); |
| 207 | return 0; | ||
| 191 | } | 208 | } |
| 192 | 209 | ||
| 193 | return 1; | 210 | return 1; |