Skip to content

Refactor DeveloperCertificateService to use ProcessSpec and ProcessUtil APIs with async/await#14110

Merged
danegsta merged 3 commits intodanegsta/trustfrom
copilot/sub-pr-13943-again
Jan 24, 2026
Merged

Refactor DeveloperCertificateService to use ProcessSpec and ProcessUtil APIs with async/await#14110
danegsta merged 3 commits intodanegsta/trustfrom
copilot/sub-pr-13943-again

Conversation

Copy link
Contributor

Copilot AI commented Jan 24, 2026

Description

Refactors certificate trust checking methods to use repository's internal process execution APIs instead of directly creating ProcessStartInfo and calling Process.Start(), and converts synchronous methods to async for proper async/await patterns.

Changes:

  • Replaced ProcessStartInfo with ProcessSpec for process configuration
  • Replaced Process.Start() with ProcessUtil.Run() for process execution
  • Converted IsCertificateTrusted to IsCertificateTrustedAsync with CancellationToken support
  • Converted IsCertificateTrustedInMacOsKeychain to IsCertificateTrustedInMacOsKeychainAsync
  • Replaced synchronous blocking calls (GetAwaiter().GetResult()) with proper async/await patterns
  • Used await using for proper async disposal of IAsyncDisposable instead of try-finally with synchronous disposal
  • Updated using statements: added Aspire.Hosting.Dcp.Process, removed System.Diagnostics
  • Updated call site in DcpHost.cs to use the async method

Before:

var startInfo = new ProcessStartInfo { FileName = "security", ... };
using var process = Process.Start(startInfo);
process.WaitForExit();
return process.ExitCode == 0;

After:

var processSpec = new ProcessSpec("security") 
{
    Arguments = $"verify-cert -p basic -p ssl -c {certPath}",
    ThrowOnNonZeroReturnCode = false
};
var (task, processDisposable) = ProcessUtil.Run(processSpec);
await using (processDisposable.ConfigureAwait(false))
{
    var result = await task.WaitAsync(cancellationToken).ConfigureAwait(false);
    return result.ExitCode == 0;
}

This brings the code in line with process execution patterns and async/await best practices used throughout the rest of the Aspire.Hosting codebase.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
    • No
  • Does the change require an update in our Aspire docs?
    • Yes
    • No

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

… APIs

Co-authored-by: danegsta <50252651+danegsta@users.noreply.github.com>
Copilot AI changed the title [WIP] Update logging PR to use ProcessSpec and ProcessUtil APIs Refactor DeveloperCertificateService to use ProcessSpec and ProcessUtil APIs Jan 24, 2026
Copilot AI requested a review from danegsta January 24, 2026 17:29
try
{
return false;
var result = task.GetAwaiter().GetResult();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot update this method (and IsCertificateTrusted) to be async instead of calling GetAwaiter and synchronously resolving the task.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Converted both methods to async in commit b7d5fcb:

  • IsCertificateTrustedIsCertificateTrustedAsync with CancellationToken support
  • IsCertificateTrustedInMacOsKeychainIsCertificateTrustedInMacOsKeychainAsync
  • Replaced GetAwaiter().GetResult() with await task.WaitAsync(cancellationToken)
  • Used await using for proper async disposal of IAsyncDisposable
  • Updated call site in DcpHost.cs to use the async method

Co-authored-by: danegsta <50252651+danegsta@users.noreply.github.com>
Copilot AI changed the title Refactor DeveloperCertificateService to use ProcessSpec and ProcessUtil APIs Refactor DeveloperCertificateService to use ProcessSpec and ProcessUtil APIs with async/await Jan 24, 2026
Copilot AI requested a review from danegsta January 24, 2026 19:31
@danegsta danegsta marked this pull request as ready for review January 24, 2026 22:03
@danegsta danegsta merged commit c08965a into danegsta/trust Jan 24, 2026
3 of 4 checks passed
@danegsta danegsta deleted the copilot/sub-pr-13943-again branch January 24, 2026 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants