-
Notifications
You must be signed in to change notification settings - Fork 51
Expose TLS remote public keys #205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
56bd2e6
Update SIPSorcery security dependency
flcl42 0358fc6
Clarify WebRTC certificate construction test
flcl42 8725993
Expose TLS remote public keys
flcl42 2fdb69f
Bind TLS certificate identity keys
flcl42 6dd1f49
Cover conflicting TLS identities
flcl42 1c6fd0e
Preserve dialed peer identity for TLS
flcl42 d0a84e2
Verify Noise dialed peer identity
flcl42 959dca2
Merge branch 'main' into tls-remote-public-key
flcl42 80940fa
Address independent review feedback
flcl42 250ca5a
Run all CI tests and bound TLS handshake cleanup
flcl42 76c8826
Preserve unsigned secp256k1 private key values
flcl42 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/libp2p/Libp2p.Protocols.Tls.Tests/IpTcpPeerIdentityTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| // SPDX-FileCopyrightText: 2026 Demerzel Solutions Limited | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| using Multiformats.Address; | ||
| using Nethermind.Libp2p.Core; | ||
| using Nethermind.Libp2p.Core.TestsBase; | ||
| using NSubstitute; | ||
| using System.Net; | ||
| using System.Net.Sockets; | ||
|
|
||
| namespace Nethermind.Libp2p.Protocols.TLS.Tests; | ||
|
|
||
| [TestFixture] | ||
| public class IpTcpPeerIdentityTests | ||
| { | ||
| [TestCase(false)] | ||
| [TestCase(true)] | ||
| public async Task Test_DialPassesExpectedPeerIdToSecurityProtocol(bool includePeerId) | ||
| { | ||
| using TcpListener listener = new(IPAddress.Loopback, 0); | ||
| listener.Start(); | ||
| int port = ((IPEndPoint)listener.LocalEndpoint).Port; | ||
| Multiaddress dialAddress = includePeerId | ||
| ? $"/ip4/127.0.0.1/tcp/{port}/p2p/{TestPeers.PeerId(2)}" | ||
| : $"/ip4/127.0.0.1/tcp/{port}"; | ||
|
|
||
| State state = new(); | ||
| TestChannel channel = new(); | ||
| TaskCompletionSource<string> upgradedAddress = new(TaskCreationOptions.RunContinuationsAsynchronously); | ||
| INewConnectionContext connection = Substitute.For<INewConnectionContext>(); | ||
| connection.State.Returns(state); | ||
| connection.Upgrade(Arg.Any<UpgradeOptions>()).Returns(_ => | ||
| { | ||
| // Capture the address before a security protocol can enrich it. | ||
| upgradedAddress.SetResult(state.RemoteAddress!.ToString()); | ||
| return channel; | ||
| }); | ||
| ITransportContext context = Substitute.For<ITransportContext>(); | ||
| context.CreateConnection().Returns(connection); | ||
|
|
||
| using CancellationTokenSource cancellation = new(TimeSpan.FromSeconds(15)); | ||
| Task dialTask = new IpTcpProtocol().DialAsync(context, dialAddress, cancellation.Token); | ||
| try | ||
| { | ||
| using TcpClient accepted = await listener.AcceptTcpClientAsync(cancellation.Token); | ||
| string actualAddress = await upgradedAddress.Task.WaitAsync(cancellation.Token); | ||
| Assert.That(actualAddress, Is.EqualTo(dialAddress.ToString())); | ||
| } | ||
| finally | ||
| { | ||
| await channel.CloseAsync(); | ||
| await dialTask.WaitAsync(TimeSpan.FromSeconds(15)); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.