|
|
|
@ -69,14 +69,16 @@ static bool test_http_signature()
|
|
|
|
|
}
|
|
|
|
|
static bool test_http_signature_2()
|
|
|
|
|
{
|
|
|
|
|
struct crypto_keys* keys = crypto_keys_new();
|
|
|
|
|
struct crypto_keys* keys = NULL;
|
|
|
|
|
struct http_signature hs;
|
|
|
|
|
bool result = false;
|
|
|
|
|
|
|
|
|
|
memset(&hs,0,sizeof(hs));
|
|
|
|
|
|
|
|
|
|
keys = crypto_keys_new();
|
|
|
|
|
crypto_keys_load_private( keys, "assets/test.private.pem" );
|
|
|
|
|
|
|
|
|
|
struct http_signature hs;
|
|
|
|
|
if( !http_signature_make( "https://example.com/inbox", keys, &hs ) ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
free(hs.host);
|
|
|
|
|
if( !http_signature_make( "https://example.com/inbox", keys, &hs ) ) { goto failed; }
|
|
|
|
|
|
|
|
|
|
char signature_header[512];
|
|
|
|
|
snprintf( signature_header, sizeof(signature_header), "keyId=\"Test\",headers=\"(request-target) host date\",signature=\"%s\"", hs.signature );
|
|
|
|
@ -102,7 +104,14 @@ static bool test_http_signature_2()
|
|
|
|
|
.body = "{\"hello\": \"world\"}",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return http_signature_validate( &env, "post /inbox" );
|
|
|
|
|
result = http_signature_validate( &env, "post /inbox" );
|
|
|
|
|
cleanup:
|
|
|
|
|
http_signature_free(&hs);
|
|
|
|
|
crypto_keys_free(keys);
|
|
|
|
|
return result;
|
|
|
|
|
failed:
|
|
|
|
|
result = false;
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool test_crypto()
|
|
|
|
|