Skip to content
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

fix(pwsh): fix reading .pem files from PowerShell runspace #859

Merged
merged 1 commit into from
May 15, 2024

Conversation

thenextman
Copy link
Member

When we call Encoding.GetString(byte[]) from a C# PowerShell runspace (e.g. DPS Console), we are getting the following error:

The following exception occurred while retrieving member "GetString": "GenericArguments[0], 'System.ReadOnlySpan1[System.Byte]', on 'System.Func2[T,TResult]' violates the constraint of type 'T'."

I don't know why. This results in an empty $PemData which obviously can't be parsed.

The workaround is to read the certificate and private key file directly as UTF8, rather than getting the UTF8 representation of the data.

@thenextman thenextman requested a review from a team May 15, 2024 15:44
Copy link
Member

@CBenoit CBenoit left a comment

Choose a reason for hiding this comment

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

Subtle! Thank you!

@CBenoit CBenoit enabled auto-merge (squash) May 15, 2024 15:44
@CBenoit CBenoit changed the title fix(powershell): fix reading .pem files from PowerShell runspace fix(pwsh): fix reading .pem files from PowerShell runspace May 15, 2024
@CBenoit CBenoit merged commit 98437f6 into master May 15, 2024
19 checks passed
@CBenoit CBenoit deleted the fix-powershell-cert-encoding branch May 15, 2024 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants