zoukankan      html  css  js  c++  java
  • 创建一个UWP 打包签名

    Create a certificate for package signing

    [ Updated for UWP apps on Windows 10. For Windows 8.x articles, see the archive ]

    This article explains how to create and export a certificate for app package signing using PowerShell tools. It's recommended that you use Visual Studio for Packaging UWP apps, but you can still package a Store ready app manually if you did not use Visual Studio to develop your app.

    Important

    If you used Visual Studio to develop your app, it's recommended that you use the Visual Studio wizard to import a certificate and sign your app package. For more information, see Package a UWP app with Visual Studio.

    Prerequisites

    • A packaged or unpackaged app
      An app containing an AppxManifest.xml file. You will need to reference the manifest file while creating the certificate that will be used to sign the final app package. For details on how to manually package an app, see Create an app package with the MakeAppx.exe tool.

    • Public Key Infrastructure (PKI) Cmdlets
      You need PKI cmdlets to create and export your signing certificate. For more information, see Public Key Infrastructure Cmdlets.

    Create a self signed certificate

    A self signed certificate is useful for testing your app before you're ready to publish it to the store. Follow the steps outlined in this section to create a self signed certificate.

    Determine the subject of your packaged app

    To use a certificate to sign your app package, the "Subject" in the certificate must match the "Publisher" section in your app's manifest.

    For example, the "Identity" section in your app's AppxManifest.xml file should look something like this:

    Copy
    Code
      <Identity Name="Contoso.AssetTracker" 
        Version="1.0.0.0" 
        Publisher="CN=Contoso Software, O=Contoso Corporation, C=US"/>
    

    The "Publisher", in this case, is "CN=Contoso Software, O=Contoso Corporation, C=US" which needs to be used for creating your certificate.

    Use New-SelfSignedCertificate to create a certificate

    Use the New-SelfSignedCertificate PowerShell cmdlet to create a self signed certificate. New-SelfSignedCertificate has several parameters for customization, but for the purpose of this article, we'll focus on creating a simple certificate that will work with SignTool. For more examples and uses of this cmdlet, see New-SelfSignedCertificate.

    Based on the AppxManifest.xml file from the previous example, you should use the following syntax to create a certificate. In an elevated PowerShell prompt:

    Copy
    Code
    New-SelfSignedCertificate -Type Custom -Subject "CN=Contoso Software, O=Contoso Corporation, C=US" -KeyUsage DigitalSignature -FriendlyName <Your Friendly Name> -CertStoreLocation "Cert:LocalMachineMy"
    

    After running this command, the certificate will be added to the local certificate store, as specified in the "-CertStoreLocation" parameter. The result of the commmand will also produce the certificate's thumbprint.

    Note
    You can view your certificate in a PowerShell window by using the following commands:

    Copy
    Code
    Set-Location Cert:LocalMachineMy
    Get-ChildItem | Format-Table Subject, FriendlyName, Thumbprint
    

    This will display all of the certificates in your local store.

    Export a certificate

    To export the certificate in the local store to a Personal Information Exchange (PFX) file, use the Export-PfxCertificate cmdlet.

    When using Export-PfxCertificate, you must either create and use a password or use the "-ProtectTo" parameter to specify which users or groups can access the file without a password. Note that an error will be displayed if you don't use either the "-Password" or "-ProtectTo" parameter.

    • Password usage

      Copy
      Code
      $pwd = ConvertTo-SecureString -String <Your Password> -Force -AsPlainText 
      Export-PfxCertificate -cert "Cert:LocalMachineMy<Certificate Thumbprint>" -FilePath <FilePath>.pfx -Password $pwd
      
    • ProtectTo usage

      Copy
      Code
      Export-PfxCertificate -cert Cert:LocalMachineMy<Certificate Thumbprint> -FilePath <FilePath>.pfx -ProtectTo <Username or group name>
      

    After you create and export your certificate, you're ready to sign your app package with SignTool. For the next step in the manual packaging process, see Sign an app package using SignTool.

  • 相关阅读:
    (转)数据库中索引的策略和设计
    (转)冷备份与热备份、双机热备与容错
    (转)Mysql数据库存储引擎
    (转)B-树和B+树的应用:数据搜索和数据库索引
    mock实例方法
    mockito模拟静态方法
    mock测试类的时候,添加@InjectMocks
    已经mock类中引用的其它service类,但是在invoke私有方法的时候,该service类是空值
    inside when() you don't call method on mock but on some other object
    org.mockito.exceptions.misusing.MissingMethodInvocationException: when() requires an argument which has to be 'a method call on a mock'
  • 原文地址:https://www.cnblogs.com/Javi/p/6702977.html
Copyright © 2011-2022 走看看