【问题标题】:Visual studio not accepting makecert certificate for Xamarin UWP appVisual Studio 不接受 Xamarin UWP 应用的 makecert 证书
【发布时间】:2019-04-19 14:17:04
【问题描述】:

我有一个 Xamarin 应用程序,我也想在 Windows UWP 上部署它。我尝试使用 makecert.exe 创建自签名证书,但 Visual Studio 不接受它。我从microsoft 遵循了本指南。这是我的命令:

makecert.exe -n "CN=some AG" -r -pe -ss my -eku 1.3.6.1.5.5.7.3.3 ContosoTest.cer

当尝试从 Visual Studio Package.appxmanifest 中的证书存储区导入此证书时,它会抱怨 "Kein Zertifikat erfüllt die Anwendungskriterien"(关于德语,我将计算机切换到英语,但由于某种原因这仍然是德语)大致翻译为 "No certificate complies to the Applications criteria"。当我将证书导出到 pfx 文件并尝试导入时,它只会抱怨 "The Manifest Designer could not import the certificate. The Manifest Designer could not import from file <filepath>."

它适用于直接在 Package.appxmanifest 编辑器中创建的测试证书,但它不会从 makecert 获取证书,即使官方微软指南声明它应该这样工作。 Visual Studio 创建的测试证书包含相同的代码签名目的 1.3.6.1.5.5.7.3.3

我也尝试过使用 powershell New-SelfSignedCertificate 和 Export-PfxCertificate,但效果相同。

为了避免XY Problem,这就是我尝试使用makecert 证书而不是Visual Studio 创建的测试证书的原因。应用程序包将由客户使用不同的证书签名,他不想与我们共享私钥(可以理解)。根据他和谷歌的说法,如果证书具有相同的发布者,则应该可以使用 signtool 对应用程序包进行签名。

我们客户的证书除了CN=some AG 还包括OU=blabla,O=some AG,L=city,S=state,C=DE 形式的其他信息。我无法在 Visual Studio 中以测试证书的名称输入此信息。它会抱怨名称中不允许使用等号=。所以我尝试以另一种方式使用这些信息生成证书。当visual studio没有拿到makecert的证书时,我删除了这个额外的信息,看看是不是这个原因。但是,正如您在上面的命令中看到的那样,即使是带有 CN=some AG 的简单证书也不起作用,而 Visual Studio 允许我创建一个具有如此简单名称的证书。

任何帮助表示赞赏。我尝试了很多不同的方法来生成证书,只有通过 make-cert 和 powershell 才能添加代码签名目的,但是即使这样,visual studio 也不会接受它。尽管微软指南说应该这样做。

【问题讨论】:

    标签: visual-studio xamarin code-signing makecert


    【解决方案1】:

    我在使用 New-SelfSignedCertificate 和 Export-PfxCertificate 时遇到了类似的问题,基本上来自 Shanepowell 的 Mircosoft Doc 的问题 https://github.com/MicrosoftDocs/windows-uwp/issues/1281 解决了我的问题。

    总而言之,您需要添加 -TextExtension 参数以使示例与 Visual Studio 中的导入一起使用。

    New-SelfSignedCertificate -Type Custom -Subject "CN=Contoso Software, O=Contoso Corporation, C=US" -KeyUsage DigitalSignature -FriendlyName -TextExtension @('2.5.29.37={text}1.3.6.1.5.5.7.3.3', '2.5.29.19={text}Subject Type:End Entity') -CertStoreLocation "Cert:\CurrentUser\My"
    

    然后关注 Mircosoft 文档:https://docs.microsoft.com/en-us/windows/uwp/packaging/create-certificate-package-signing

    在你的情况下,我猜是这样的:

    $pwd = ConvertTo-SecureString -String <Your Password> -Force -AsPlainText 
    Export-PfxCertificate -cert "Cert:\LocalMachine\My\<Certificate Thumbprint>" -FilePath <FilePath>.pfx -Password $pwd
    

    现在应该可以在 Visual Studio 中导入 pfx 文件了。

    【讨论】:

      猜你喜欢
      • 2016-12-16
      • 2012-03-04
      • 2020-08-03
      • 2019-12-25
      • 1970-01-01
      • 1970-01-01
      • 2016-02-13
      • 2020-02-22
      • 1970-01-01
      相关资源
      最近更新 更多