about summary refs log tree commit diff
path: root/Utilities/LibMatrix.FederationTest/Controllers
diff options
context:
space:
mode:
Diffstat (limited to 'Utilities/LibMatrix.FederationTest/Controllers')
-rw-r--r--Utilities/LibMatrix.FederationTest/Controllers/RemoteServerPingController.cs4
-rw-r--r--Utilities/LibMatrix.FederationTest/Controllers/Spec/FederationKeysController.cs9
-rw-r--r--Utilities/LibMatrix.FederationTest/Controllers/TestController.cs47
3 files changed, 30 insertions, 30 deletions
diff --git a/Utilities/LibMatrix.FederationTest/Controllers/RemoteServerPingController.cs b/Utilities/LibMatrix.FederationTest/Controllers/RemoteServerPingController.cs

index 8d3a5ea..ce0e119 100644 --- a/Utilities/LibMatrix.FederationTest/Controllers/RemoteServerPingController.cs +++ b/Utilities/LibMatrix.FederationTest/Controllers/RemoteServerPingController.cs
@@ -20,8 +20,8 @@ public class RemoteServerPingController(FederationTestConfiguration config, Fede try { var ownKey = keyStore.GetCurrentSigningKey(); var hs = new AuthenticatedFederationClient(hsResolveResult.Server, new() { - PrivateKey = , - OriginServerName = null + PrivateKey = ownKey.CurrentSigningKey, + OriginServerName = config.ServerName }); var keys = await hs.GetServerKeysAsync(); responseMessage["version"] = await hs.GetServerVersionAsync(); diff --git a/Utilities/LibMatrix.FederationTest/Controllers/Spec/FederationKeysController.cs b/Utilities/LibMatrix.FederationTest/Controllers/Spec/FederationKeysController.cs
index 6516415..d96bef5 100644 --- a/Utilities/LibMatrix.FederationTest/Controllers/Spec/FederationKeysController.cs +++ b/Utilities/LibMatrix.FederationTest/Controllers/Spec/FederationKeysController.cs
@@ -23,18 +23,19 @@ public class FederationKeysController(FederationTestConfiguration config, Federa if (_cachedServerKeysResponse == null || _cachedServerKeysResponse.TypedContent.ValidUntil < DateTime.Now + TimeSpan.FromSeconds(30)) { var keys = keyStore.GetCurrentSigningKey(); _cachedServerKeysResponse = new ServerKeysResponse() { - ValidUntil = DateTime.Now + TimeSpan.FromMinutes(1), + ValidUntil = DateTime.Now + TimeSpan.FromMinutes(5), ServerName = config.ServerName, OldVerifyKeys = [], VerifyKeysById = new() { { - new() { Algorithm = "ed25519", KeyId = "0" }, new ServerKeysResponse.CurrentVerifyKey() { - Key = keys.publicKey.ToUnpaddedBase64(), + keys.CurrentSigningKey.KeyId, new ServerKeysResponse.CurrentVerifyKey() { + Key = keys.CurrentSigningKey.PublicKey //.ToUnpaddedBase64(), } } } - }.Sign(config.ServerName, new VersionedKeyId() { Algorithm = "ed25519", KeyId = "0" }, keys.privateKey); + }.Sign(keys.CurrentSigningKey); } + _serverKeyCacheLock.Release(); return _cachedServerKeysResponse; diff --git a/Utilities/LibMatrix.FederationTest/Controllers/TestController.cs b/Utilities/LibMatrix.FederationTest/Controllers/TestController.cs
index 9c0981d..900c8a0 100644 --- a/Utilities/LibMatrix.FederationTest/Controllers/TestController.cs +++ b/Utilities/LibMatrix.FederationTest/Controllers/TestController.cs
@@ -1,10 +1,8 @@ using System.Text.Json.Nodes; -using LibMatrix.Abstractions; using LibMatrix.Extensions; using LibMatrix.Federation; using LibMatrix.Federation.Extensions; using LibMatrix.FederationTest.Services; -using LibMatrix.Homeservers; using Microsoft.AspNetCore.Mvc; namespace LibMatrix.FederationTest.Controllers; @@ -21,32 +19,33 @@ public class TestController(FederationTestConfiguration config, FederationKeySto BaseAddress = new Uri("https://matrix.rory.gay") }; - var keyId = new VersionedKeyId() { - Algorithm = "ed25519", - KeyId = "0" - }; + var currentKey = keyStore.GetCurrentSigningKey().CurrentSigningKey; var signatureData = new XMatrixAuthorizationScheme.XMatrixRequestSignature() { - Method = "GET", - Uri = "/_matrix/federation/v1/user/devices/@emma:rory.gay", - OriginServerName = config.ServerName, - DestinationServerName = "rory.gay" - } - .Sign(config.ServerName, keyId, keyStore.GetCurrentSigningKey().privateKey); - - var signature = signatureData.Signatures[config.ServerName][keyId]; - var headerValue = new XMatrixAuthorizationScheme.XMatrixAuthorizationHeader() { - Origin = config.ServerName, - Destination = "rory.gay", - Key = keyId, - Signature = signature - }.ToHeaderValue(); - - var req = new HttpRequestMessage(HttpMethod.Get, "/_matrix/federation/v1/user/devices/@emma:rory.gay"); - req.Headers.Add("Authorization", headerValue); - + OriginServerName = config.ServerName, + Method = "GET", + DestinationServerName = "rory.gay", + Uri = "/_matrix/federation/v1/user/devices/@emma:rory.gay", + }; + // .Sign(currentKey); + // + // var signature = signatureData.Signatures[config.ServerName][currentKey.KeyId]; + // var headerValue = new XMatrixAuthorizationScheme.XMatrixAuthorizationHeader() { + // Origin = config.ServerName, + // Key = currentKey.KeyId, + // Destination = "rory.gay", + // Signature = signature + // }.ToHeaderValue(); + + // var req = new HttpRequestMessage(HttpMethod.Get, "/_matrix/federation/v1/user/devices/@emma:rory.gay"); + // req.Headers.Add("Authorization", headerValue); + + var req = signatureData.ToSignedHttpRequestMessage(currentKey); var response = await hc.SendAsync(req); var content = await response.Content.ReadFromJsonAsync<JsonObject>(); return content!; } + + // [HttpGet("/testMakeJoin")] + // public async Task<JsonObject> GetTestMakeJoin() { } } \ No newline at end of file