vmware / PowerCLI-Example-Scripts

http://blogs.vmware.com/powercli
Other
743 stars 601 forks source link

Fix the bug of not creating certificates in linux #604

Closed Jiancao164 closed 1 year ago

Jiancao164 commented 1 year ago

Problem: certificatesList.Add(new X509Certificate2(Encoding.ASCII.GetBytes(cert))) caused ASN1 Corrupted Data error in Linux.

Root cause: Each certificate cert was converted from a byte array and stored as a string representation that was encoded with base-64 digits. Encoding.ASCII.GetBytes() is to get the ASCII byte representation of the base64 string, not to restore the original byte array from the base64 string. It might work with Windows but not Linux. This problem was also tracked in https://github.com/dotnet/runtime/issues/47005.

Solution: replaced it with new X509Certificate2(Convert.FromBase64String(cert)) to restore the original byte array.

Jiancao164 commented 1 year ago

This PR fixes #509.

Jiancao164 commented 1 year ago

Hi @vmwclabot @kamennikolov, can you take a look at this PR?

kamennikolov commented 1 year ago

Thank you for this fix.

Jiancao164 commented 1 year ago

@kamennikolov , thank you for doing it! Since we are currently waiting for it, when can we expect the new version to be published in PSGallery?

kamennikolov commented 1 year ago

We have built the module, so you can now take it from the github repo. Uploading it to the PowerShell gallery will take some time though.

et1975 commented 1 year ago

@kamennikolov What's the timeframe we should anticipate for the release to PSGallery?

kamennikolov commented 1 year ago

It dependes on when we'll have the resources to do it. Currently everyone in the team is busy with tasks for the next PowerCLI release. I cannot give a specific timeframe.

kamennikolov commented 1 year ago

The new version is now uploaded to the PowerShell Gallery - https://www.powershellgallery.com/packages/VMware.vSphere.SsoAdmin/1.3.9