Jil*_*aik 5 powershell windows-8 windows-runtime sideloading
以前我们有一个代码签名证书,每件事都很好.最近证书已过期,因此我们从Comodo获得了新证书,并发布了该证书的新版本.
所以这就是问题:软件包系列名称已更改为新的证书,因此我无法使用新证书打包的新版本升级旧的已安装应用程序.
需要解决方案来将Package Family Name维持为常量或新证书,我们还需要为旧应用程序提供升级.
我们怎样才能做到这一点?
从PowerShell升级包时出错错误:
Add-AppxPackage : Deployment failed with HRESULT: 0x80073CF3, Package failed updates, dependency or conflict validation. Windows cannot install package df70dbc9-455c-4c32-b052-7ac2943630b7_1.0.193.1_x64__qbsrcgy0j364g because a different package df70dbc9-455c-4c32-b052-7ac2943630b7_1.0.0.191_x64__hs446qhh7vdt4 with the same name is already installed. Remove package df70dbc9-455c-4c32-b052-7ac2943630b7_1.0.0.191_x64__hs446qhh7vdt4 before installing. NOTE: For additional information, look for [ActivityId] b0deec37-ac10-0001-81fd-deb010acd101 in the Event Log or use the command line Get-AppxLog -ActivityID b0deec37-ac10-0001-81fd-deb010acd101 At C:\Users\\Desktop\\myappName_1.0.193.1_x64_Test\Add-AppDevPackage.ps1:388 char:13 + Add-AppxPackage -Path $DeveloperPackagePath.FullName -DependencyPath ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : WriteError: (C:\Users\myuser....193.1_x64.appx:String) [Add-AppxPackage], IOException + FullyQualifiedErrorId : DeploymentError,Microsoft.Windows.Appx.PackageManager.Commands.AddAppxPackageCommand Error: Could not install the app.
包名称系列名称(PFN)后缀(在您的情况下hs446qhh7vdt4
)是证书主题的哈希值(AKA 主题名称):
certutil -dump foo.pfx
Enter PFX password:
================ Certificate 0 ================
================ Begin Nesting Level 1 ================
Element 0:
Serial Number: xxxxxxxxxxxxxxxxx
Issuer: CN=Microsoft, O=Contoso, L=Redmond, S=Washington, C=US
NotBefore: 11/1/2016 12:00 AM
NotAfter: 11/1/2017 12:00 AM
Subject: CN=Microsoft, O=Contoso, L=Redmond, S=Washington, C=US <== THIS IS HASHED
Run Code Online (Sandbox Code Playgroud)
如果您确保生成的新证书具有相同的主题,您将获得相同的PFN.请注意,您可能无法从Visual Studio中生成商店证书(在写作的时候,它不能解析复杂的科目,如上面的一个多"零件"一样CN=X
,O=Y
).在这种情况下,您必须创建自己的,但必须符合商店验证.
幸运的是,有一个简单的命令可以生成您需要的确切证书.打开Visual Studio开发人员提示并运行(一行):
makecert -sv foo.pvk -n "CN=Contoso, O=Contoso, L=Redmond, S=Washington, C=US"
foo.cer -b 11/01/2016 -e 11/01/2017 -r -cy end -a sha256 -eku 1.3.6.1.5.5.7.3.3
Run Code Online (Sandbox Code Playgroud)
确保更换有效日期(相隔不超过一年!)以及主题(取自您之前使用的证书certutil -dump
).输出cert(cer
)和私钥(pvk
)的名称没有意义.这个命令会产生foo.pvk
和foo.cer
,你会再能结合到一个PFX像这样:
PVK2PFX -pvk foo.pvk -spc foo.cer -pfx foo.pfx
Run Code Online (Sandbox Code Playgroud)
高级生成的另一种选择
如果您有更高级的证书要求,您应该能够使用certreq
(尽管尚未测试).创建一个cert.inf
使用以下内容命名的文件:
[Version]
Signature = "$Windows NT$"
[Strings]
szOID_ENHANCED_KEY_USAGE = "2.5.29.37"
szOID_CODE_SIGNING = "1.3.6.1.5.5.7.3.3"
szOID_BASIC_CONSTRAINTS2 = "2.5.29.19"
[NewRequest]
Subject = "CN=Contoso, O=Contoso, L=Redmond, S=Washington, C=US"
Exportable = true
HashAlgorithm = Sha256
KeyLength = 2048
RequestType = Cert
ValidityPeriod = "Years"
ValidityPeriodUnits = "1"
[Extensions]
%szOID_ENHANCED_KEY_USAGE% = "{text}%szOID_CODE_SIGNING%"
%szOID_BASIC_CONSTRAINTS2% = "{text}"
Run Code Online (Sandbox Code Playgroud)
替换主题和有效期,并根据文档调整所需的任何高级设置(或更有可能在网络上找到).然后执行以下操作:
certreq -new cert.inf cert.cer
cert.cer
并将其安装到受信任的根证书颁发机构存储(用户或计算机).certreq -accept -user cert.cer
或certreq -accept -machine cert.cer
(取决于您在上一步中选择的商店).certutil -exportpfx -p "YOUR_PFX_PASS" my SERIAL_NUMBER foo.pfx
(用实际值替换密码和序列号)您现在应该有一个有效的商店pfx.
更先进的一代的另一种选择
使用OpenSSL.很确定它可以做到以上所有以及更多,但我没有亲自尝试过,所以你必须弄明白 - 并希望一旦你这样做就分享到这里!
归档时间: |
|
查看次数: |
798 次 |
最近记录: |