admin管理员组

文章数量:1392094

One Visual Studio solution needs a self-signed certificate to work.

We used to make one in cmd as administrator with this command:

makecert -n "CN=TempCA" -r -sv TempCA.pvk TempCA.cer

And when finished, we ran this:

makecert -sr LocalMachine -ss My -a sha1 -n CN=MyTestCert -sky exchange -pe -ic TempCA.cer -iv TempCA.pvk

This works on Windows 10, but we just got upgraded to Windows 11 and now makecert is not compatible anymore.

How do I translate this to the PowerShell variant New-SelfSignedCertificate?

One Visual Studio solution needs a self-signed certificate to work.

We used to make one in cmd as administrator with this command:

makecert -n "CN=TempCA" -r -sv TempCA.pvk TempCA.cer

And when finished, we ran this:

makecert -sr LocalMachine -ss My -a sha1 -n CN=MyTestCert -sky exchange -pe -ic TempCA.cer -iv TempCA.pvk

This works on Windows 10, but we just got upgraded to Windows 11 and now makecert is not compatible anymore.

How do I translate this to the PowerShell variant New-SelfSignedCertificate?

Share Improve this question edited Mar 12 at 8:04 marc_s 756k184 gold badges1.4k silver badges1.5k bronze badges asked Mar 12 at 7:41 EricEric 1471 silver badge13 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

You can create a new self-signed certificate using this command (replace the values in angle brackets):

New-SelfSignedCertificate -Type Custom -Subject "CN=<PublisherName>" -KeyUsage DigitalSignature -FriendlyName "<Certificate firendly name>" -CertStoreLocation "Cert:\CurrentUser\My" -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.3", "2.5.29.19={text}")

To see the certificates you've created, use this command:

Get-ChildItem "Cert:\CurrentUser\My" | Format-Table Thumbprint, Subject, FriendlyName

I've taken this information from Publish a packaged .NET MAUI app for Windows with the CLI; if copy-pasting the command from this comment doesn't work, try copying it directly from this article.

本文标签: self signed certificateHow to use PowerShell NewSelfSignedCertificateStack Overflow