🐛 Fix signature in AP again...
This commit is contained in:
@@ -234,7 +234,7 @@ public class ActivityPubDeliveryService(
|
||||
var request = new HttpRequestMessage(HttpMethod.Post, inboxUrl);
|
||||
|
||||
request.Content = new StringContent(json, Encoding.UTF8, "application/activity+json");
|
||||
request.Headers.Date = DateTimeOffset.UtcNow;
|
||||
request.Headers.Date = DateTimeOffset.UtcNow.ToString("r");
|
||||
|
||||
var bodyBytes = Encoding.UTF8.GetBytes(json);
|
||||
using var sha256 = SHA256.Create();
|
||||
|
||||
@@ -55,9 +55,9 @@ public class ActivityPubKeyService(ILogger<ActivityPubKeyService> logger)
|
||||
private static string ConvertToPem(byte[] keyData, string keyType)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine($"-----BEGIN {keyType}-----");
|
||||
sb.AppendLine(Convert.ToBase64String(keyData));
|
||||
sb.AppendLine($"-----END {keyType}-----");
|
||||
sb.Append($"-----BEGIN {keyType}-----\n");
|
||||
sb.Append(Convert.ToBase64String(keyData) + "\n");
|
||||
sb.Append($"-----END {keyType}-----");
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ public class ActivityPubSignatureService(
|
||||
IConfiguration configuration
|
||||
)
|
||||
{
|
||||
private const string RequestTarget = "(request-target)";
|
||||
private string Domain => configuration["ActivityPub:Domain"] ?? "localhost";
|
||||
|
||||
public bool VerifyIncomingRequest(HttpContext context, out string? actorUri)
|
||||
@@ -209,7 +210,7 @@ public class ActivityPubSignatureService(
|
||||
foreach (var header in headers)
|
||||
{
|
||||
if (sb.Length > 0)
|
||||
sb.AppendLine();
|
||||
sb.Append("\n");
|
||||
|
||||
sb.Append(header.ToLower());
|
||||
sb.Append(": ");
|
||||
@@ -243,7 +244,7 @@ public class ActivityPubSignatureService(
|
||||
foreach (var header in headers)
|
||||
{
|
||||
if (sb.Length > 0)
|
||||
sb.AppendLine();
|
||||
sb.Append("\n");
|
||||
|
||||
sb.Append(header.ToLower());
|
||||
sb.Append(": ");
|
||||
|
||||
Reference in New Issue
Block a user