Skip to content

Fix generation of local certificate files when running from publish directory#1514

Merged
bart-vmware merged 1 commit into
mainfrom
fix-gen-certificates
May 7, 2025
Merged

Fix generation of local certificate files when running from publish directory#1514
bart-vmware merged 1 commit into
mainfrom
fix-gen-certificates

Conversation

@bart-vmware
Copy link
Copy Markdown
Member

@bart-vmware bart-vmware commented May 7, 2025

Description

Bugfix: AuthApi sample crashes at startup when running from publish directory.

C:\Test\Api> .\Steeltoe.Samples.AuthApi.exe
Unhandled exception. System.TypeInitializationException: The type initializer for 'Steeltoe.Common.Certificates.LocalCertificateWriter' threw an exception.
 ---> System.ArgumentOutOfRangeException: length ('-1') must be a non-negative value. (Parameter 'length')
Actual value was -1.
   at System.ArgumentOutOfRangeException.ThrowNegative[T](T value, String paramName)
   at System.ArgumentOutOfRangeException.ThrowIfNegative[T](T value, String paramName)
   at System.String.ThrowSubstringArgumentOutOfRange(Int32 startIndex, Int32 length)
   at System.String.Substring(Int32 startIndex, Int32 length)
   at Steeltoe.Common.Certificates.LocalCertificateWriter..cctor() in C:\Source\Repos\Steeltoe\src\Common\src\Certificates\LocalCertificateWriter.cs:line 16
   --- End of inner exception stack trace ---
   at Steeltoe.Common.Certificates.LocalCertificateWriter.Write(Guid orgId, Guid spaceId) in C:\Source\Repos\Steeltoe\src\Common\src\Certificates\LocalCertificateWriter.cs:line 46
   at Steeltoe.Common.Certificates.CertificateConfigurationExtensions.AddAppInstanceIdentityCertificate(IConfigurationBuilder builder, TimeProvider timeProvider, Nullable`1 orgId, Nullable`1 spaceId) in C:\Source\Repos\Steeltoe\src\Common\src\Certificates\CertificateConfigurationExtensions.cs:line 135
   at Steeltoe.Common.Certificates.CertificateConfigurationExtensions.AddAppInstanceIdentityCertificate(IConfigurationBuilder builder, Nullable`1 orgId, Nullable`1 spaceId) in C:\Source\Repos\Steeltoe\src\Common\src\Certificates\CertificateConfigurationExtensions.cs:line 97
   at Program.<Main>$(String[] args) in C:\Source\Repos\Samples\Security\src\AuthApi\Program.cs:line 27

It crashes because bin is not in the current directory path.

Quality checklist

  • Your code complies with our Coding Style.
  • You've updated unit and/or integration tests for your change, where applicable.
  • You've updated documentation for your change, where applicable.
    If your change affects other repositories, such as Documentation, Samples and/or MainSite, add linked PRs here.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.
  • You've added required license files and/or file headers (explaining where the code came from with proper attribution), where code is copied from StackOverflow, a blog, or OSS.

@bart-vmware bart-vmware marked this pull request as ready for review May 7, 2025 12:46
@bart-vmware bart-vmware requested a review from TimHess May 7, 2025 12:47
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 7, 2025

@bart-vmware bart-vmware merged commit dd0e55e into main May 7, 2025
19 checks passed
@bart-vmware bart-vmware deleted the fix-gen-certificates branch May 7, 2025 14:54
@bart-vmware bart-vmware added Component/Common ReleaseLine/4.x Identified as a feature/fix for the 4.x release line labels May 23, 2025
@bart-vmware bart-vmware added this to the 4.0.0-rc1 milestone May 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component/Common ReleaseLine/4.x Identified as a feature/fix for the 4.x release line

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants