SSL client error in GitHub Actions for DistributedApplicationTesting test
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 991
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 196
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Describe the bug
GitHub Actions error
I have simple test, and local it works perfectly.
```cs
[Fact]
public async Task HealthTest()
{
// Arrange
var appHost = await DistributedApplicationTestingBuilder.CreateAsync();
appHost.Environment.EnvironmentName = "Development";
await using var app = await appHost.BuildAsync();
await app.StartAsync();
// Act
var httpClient = app.CreateHttpClient("server");
var response = await httpClient.GetAsync("/health");
// Assert
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}
```
But on github actions:
```
Test run for /home/runner/work/DigitalCollections/DigitalCollections/Assistant.Tests/bin/Release/net9.0/Assistant.Tests.dll (.NETCoreApp,Version=v9.0)
VSTest version 17.13.0 (x64)
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
[xUnit.net 00:00:35.74] Assistant.Tests.IntegrationTest1.HealthTest [FAIL]
Failed Assistant.Tests.IntegrationTest1.HealthTest [35 s]
Error Message:
System.Net.Http.HttpRequestException : The SSL connection could not be established, see inner exception.
---- System.Security.Authentication.AuthenticationException : The remote certificate is invalid because of errors in the certificate chain: UntrustedRoot
Stack Trace:
at System.Net.Http.ConnectHelper.EstablishSslConnectionAsync(SslClientAuthenticationOptions sslOptions, HttpRequestMessage request, Boolean async, Stream stream, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.InjectNewHttp11ConnectionAsync(QueueItem queueItem)
at System.Threading.Tasks.TaskCompletionSourceWithCancellation`1.WaitWithCancellationAsync(CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at Microsoft.Extensions.Http.Logging.LoggingHttpMessageHandler.g__Core|4_0(HttpRequestMessage request, Boolean useAsync, CancellationToken cancellationToken)
at Microsoft.Extensions.Http.Logging.LoggingScopeHttpMessageHandler.g__Core|4_0(HttpRequestMessage request, Boolean useAsync, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
at GoodLeapAssistant.Tests.IntegrationTest1.HealthTest() in /home/runner/work/DigitalCollections/DigitalCollections/Assistant.Tests/IntegrationTest1.cs:line 21
at Assistant.Tests.IntegrationTest1.HealthTest() in /home/runner/work/DigitalCollections/DigitalCollections/Assistant.Tests/IntegrationTest1.cs:line 24
--- End of stack trace from previous location ---
----- Inner Stack Trace -----
at System.Net.Security.SslStream.SendAuthResetSignal(ReadOnlySpan`1 alert, ExceptionDispatchInfo exception)
at System.Net.Security.SslStream.CompleteHandshake(SslAuthenticationOptions sslAuthenticationOptions)
at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](Boolean receiveFirst, Byte[] reAuthenticationData, CancellationToken cancellationToken)
at System.Net.Http.ConnectHelper.EstablishSslConnectionAsync(SslClientAuthenticationOptions sslOptions, HttpRequestMessage request, Boolean async, Stream stream, CancellationToken cancellationToken)
```
### Expected Behavior
this test shoud works
### Steps To Reproduce
simple aspire app
```cs
var builder = DistributedApplication.CreateBuilder(args);
var postgres = builder.AddPostgres("postgres")
.WithLifetime(ContainerLifetime.Persistent);
var postgresDb = postgres.AddDatabase("postgresdb");
var api = builder.AddProject("server")
.WithReference(postgresDb)
.WaitFor(postgresDb);
builder.Build()
.Run();
```
### Exceptions (if any)
_No response_
### .NET Version info
9.0.203
### Anything else?
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.