-
Notifications
You must be signed in to change notification settings - Fork 48
Allow overriding SSL configuration #697
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
4 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,167 @@ | ||
| // Copyright 2012-2013 Octopus Deploy Pty. Ltd. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| using System; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
| using FluentAssertions; | ||
| using Halibut.Diagnostics; | ||
| using Halibut.ServiceModel; | ||
| using Halibut.Tests.Support; | ||
| using NUnit.Framework; | ||
|
|
||
| namespace Halibut.Tests | ||
| { | ||
| public class ClientServerLifecycleTests : BaseTest | ||
| { | ||
| [Test] | ||
| public async Task ListeningConfiguration() | ||
| { | ||
| await using var server = RunServer(out var serverPort); | ||
|
|
||
| await using var runtime = CreateRuntimeForListener(); | ||
| var client = CreateClient(runtime, serverPort); | ||
| var result = await client.AddAsync(2, 2); | ||
| result.Should().Be(4); | ||
| } | ||
|
|
||
| [Test] | ||
| public async Task PollingConfiguration() | ||
| { | ||
| await using var server = RunServer(out var serverPort); | ||
| await using var runtime = CreateRuntimeForPoller(server, out var client); | ||
| var result = await client.AddAsync(2, 2); | ||
| result.Should().Be(4); | ||
| } | ||
|
|
||
| [Test] | ||
| public async Task ListeningThenPollingConfiguration() | ||
| { | ||
| // On NET4.8 with SslProtocols.None this will result in SSPI errors | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Running each of the above tests independently succeeded on .NET4.8 with This added test exists to provide a straightforward entrypoint into the problem that can be run independently. |
||
| await ListeningConfiguration(); | ||
| await PollingConfiguration(); | ||
| } | ||
|
|
||
| HalibutRuntime CreateRuntimeForListener() | ||
| { | ||
| var runtime = new HalibutRuntimeBuilder() | ||
| .WithServerCertificate(Certificates.TentacleListening) | ||
| .WithLogFactory(new TestLogFactory(HalibutLog)) | ||
| .Build(); | ||
| return runtime; | ||
| } | ||
|
|
||
| HalibutRuntime CreateRuntimeForPoller(HalibutRuntime serverRuntime, out IAsyncClientCalculatorService client) | ||
| { | ||
| var runtime = new HalibutRuntimeBuilder() | ||
| .WithServerCertificate(Certificates.TentaclePolling) | ||
| .WithLogFactory(new TestLogFactory(HalibutLog)) | ||
| .Build(); | ||
| var port = runtime.Listen(); | ||
| runtime.Trust(Certificates.OctopusPublicThumbprint); | ||
|
|
||
| var pollEndpoint = new ServiceEndPoint( | ||
| baseUri: new Uri($"https://localhost:{port}/"), | ||
| remoteThumbprint: Certificates.TentaclePollingPublicThumbprint, | ||
| halibutTimeoutsAndLimits: runtime.TimeoutsAndLimits | ||
| ) | ||
| { | ||
| TcpClientConnectTimeout = TimeSpan.FromSeconds(5) | ||
| }; | ||
| var pollingUri = new Uri("poll://TEST-POLL"); | ||
| serverRuntime.Poll(pollingUri, pollEndpoint, CancellationToken); | ||
| var clientEndpoint = new ServiceEndPoint( | ||
| baseUri: pollingUri, | ||
| remoteThumbprint: Certificates.OctopusPublicThumbprint, | ||
| halibutTimeoutsAndLimits: runtime.TimeoutsAndLimits | ||
| ); | ||
| client = runtime.CreateAsyncClient<ICalculatorService, IAsyncClientCalculatorService>(clientEndpoint); | ||
|
|
||
| return runtime; | ||
| } | ||
|
|
||
| static IAsyncClientCalculatorService CreateClient(HalibutRuntime runtime, int port) | ||
| { | ||
| var endpoint = new ServiceEndPoint( | ||
| baseUri: $"https://localhost:{port}", | ||
| remoteThumbprint: Certificates.OctopusPublicThumbprint, | ||
| halibutTimeoutsAndLimits: runtime.TimeoutsAndLimits | ||
| ); | ||
| var client = runtime | ||
| .CreateAsyncClient<ICalculatorService, IAsyncClientCalculatorService>(endpoint); | ||
| return client; | ||
| } | ||
|
|
||
| static IServiceFactory CreateServiceFactory() | ||
| { | ||
| var services = new DelegateServiceFactory(); | ||
| services.Register<ICalculatorService, IAsyncCalculatorService>(() => new AsyncCalculatorService()); | ||
| return services; | ||
| } | ||
|
|
||
| HalibutRuntime RunServer(out int port) | ||
| { | ||
| var services = CreateServiceFactory(); | ||
|
|
||
| var runtime = new HalibutRuntimeBuilder() | ||
| .WithServerCertificate(Certificates.Octopus) | ||
| .WithServiceFactory(services) | ||
| .WithLogFactory(new TestLogFactory(HalibutLog)) | ||
| .Build(); | ||
|
|
||
| runtime.Trust(Certificates.TentacleListeningPublicThumbprint); | ||
| runtime.Trust(Certificates.TentaclePollingPublicThumbprint); | ||
| port = runtime.Listen(); | ||
|
|
||
| return runtime; | ||
| } | ||
|
|
||
| public class TestLogFactory : ILogFactory | ||
| { | ||
| readonly ILog _log; | ||
| public TestLogFactory(ILog log) | ||
| { | ||
| _log = log; | ||
| } | ||
|
|
||
| public ILog ForEndpoint(Uri endpoint) => _log; | ||
|
|
||
| public ILog ForPrefix(string endPoint) => _log; | ||
| } | ||
|
|
||
| public interface ICalculatorService | ||
| { | ||
| long Add(long a, long b); | ||
| } | ||
|
|
||
| public interface IAsyncCalculatorService | ||
| { | ||
| Task<long> AddAsync(long a, long b, CancellationToken cancellationToken); | ||
| } | ||
|
|
||
| public interface IAsyncClientCalculatorService | ||
| { | ||
| Task<long> AddAsync(long a, long b); | ||
| } | ||
|
|
||
| public class AsyncCalculatorService : IAsyncCalculatorService | ||
| { | ||
| public async Task<long> AddAsync(long a, long b, CancellationToken cancellationToken) | ||
| { | ||
| await Task.CompletedTask; | ||
| return a + b; | ||
| } | ||
| } | ||
| } | ||
| } | ||
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
27 changes: 27 additions & 0 deletions
27
source/Halibut/Transport/DefaultSslConfigurationProvider.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,27 @@ | ||
| // Copyright 2012-2013 Octopus Deploy Pty. Ltd. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| using System; | ||
| using System.Security.Authentication; | ||
|
|
||
| namespace Halibut.Transport | ||
| { | ||
| /// <summary> | ||
| /// Provides a default implementation of ISslConfigurationProvider that uses the system defaults. | ||
| /// </summary> | ||
| public class DefaultSslConfigurationProvider : ISslConfigurationProvider | ||
| { | ||
| public SslProtocols SupportedProtocols => SslProtocols.None; | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| // Copyright 2012-2013 Octopus Deploy Pty. Ltd. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| using System.Security.Authentication; | ||
|
|
||
| namespace Halibut.Transport | ||
| { | ||
| public interface ISslConfigurationProvider | ||
| { | ||
| public SslProtocols SupportedProtocols { get; } | ||
| } | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a slimmed down variant of what the DotMemory test does. This test exercises the code paths that were problematic with .NET4.8 and will also run on .net8.0