时间:2026-01-08 17:07
人气:
作者:admin
自签名证书仅用于测试安装,MSIX上传到微软商店时可以不签名。
New-SelfSignedCertificate -Type Custom -KeyUsage DigitalSignature -CertStoreLocation "Cert:\CurrentUser\My" -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.3", "2.5.29.19={text}") -Subject "CN=Contoso Software, O=Contoso Corporation, C=US" -FriendlyName "Your friendly name goes here"
如果要上传到微软商店,Subject参数要对应产品标识页面的Package/Identity/Publisher
可以使用以下命令在 PowerShell 窗口中查看证书:
Set-Location Cert:\CurrentUser\My
Get-ChildItem | Format-Table Subject, FriendlyName, Thumbprint
若要将新创建的证书导入本地计算机受信任人员证书存储,需要首先使用 Export-PfxCertificate cmdlet 将其导出到个人信息交换 (PFX) 文件。
使用 Export-PfxCertificate 时,必须创建和使用密码,或使用“-ProtectTo”参数指定哪些用户或组可以在不使用密码的情况下访问文件。 请注意,如果不使用“-Password”或“-ProtectTo”参数,则会显示错误。 建议使用“-Password”进行常规使用,而当用户帐户由域控制器提供支持时,“-ProtectTo”非常有用。
$password = ConvertTo-SecureString -String <Your Password> -Force -AsPlainText
Export-PfxCertificate -cert "Cert:\CurrentUser\My\<Certificate Thumbprint>" -FilePath <FilePath>.pfx -Password $password
Export-PfxCertificate -cert Cert:\CurrentUser\My\<Certificate Thumbprint> -FilePath <FilePath>.pfx -ProtectTo <Username or group name>
SignTool sign /fd <Hash Algorithm> /a /f <Path to Certificate>.pfx /p <Your Password> <File path>.msix
在创建包时选择签名证书