Skip to content

SSL client error in GitHub Actions for DistributedApplicationTesting test #9061

Open
@KSemenenko

Description

@KSemenenko

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

GitHub Actions error
I have simple test, and local it works perfectly.

[Fact]
public async Task HealthTest()
{
    // Arrange
    var appHost = await DistributedApplicationTestingBuilder.CreateAsync<Projects.Server>();
    
    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.<SendCoreAsync>g__Core|4_0(HttpRequestMessage request, Boolean useAsync, CancellationToken cancellationToken)
   at Microsoft.Extensions.Http.Logging.LoggingScopeHttpMessageHandler.<SendCoreAsync>g__Core|4_0(HttpRequestMessage request, Boolean useAsync, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.<SendAsync>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

var builder = DistributedApplication.CreateBuilder(args);

var postgres = builder.AddPostgres("postgres")
    .WithLifetime(ContainerLifetime.Persistent);

var postgresDb = postgres.AddDatabase("postgresdb");

var api = builder.AddProject<Projects.Server>("server")
    .WithReference(postgresDb)
    .WaitFor(postgresDb);

builder.Build()
    .Run();

Exceptions (if any)

No response

.NET Version info

9.0.203

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-integrationsIssues pertaining to Aspire Integrations packages

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions