2017-08-14 157 views
1

我正在將現有的Chrome擴展程序移植到Microsoft Edge。 當我在Edge中將其作爲臨時擴展加載時,該擴展就可以工作。邊緣擴展符號失敗

現在我想打包並簽名。該軟件包已成功生成。但是,當我嘗試使用Windows應用程序認證工具包簽字時,出現以下錯誤:

Edge extension manifest.json 
Error Found: The JSON schema validation test detected the following errors: 
Validation failed: Data does not match any schemas from "anyOf" 
Schema location: /allOf/1/dependencies/background/anyOf 
Manifest location: 
Validation failed for extension manifest: Extension\manifest.json 
Impact if not fixed: Microsoft Edge extensions that violate the Windows Store certification requirements can’t be submitted to the Windows Store. 
How to fix: Extension’s manifest.json must include valid entries for all required and specified fields. Please resolve the entries and conflicts above. 

我用打包的命令擴展:

manifoldjs -l debug -p edgeextension -f edgeextension -m EdgeExtension\manifest.json 
manifoldjs -l debug -p edgeextension package Test\edgeextension\manifest\ 

我的清單文件:

{ 
    "author": "Test", 
    "background": { 
     "page": "Agent/Ext/bg-loader.html", 
     "persistent": false 
    }, 
    "content_scripts": [ 
     { 
      "matches": [ 
       "<all_urls>" 
      ], 
      "js": [ 
       "Agent/Content/contentLoader.js" 
      ], 
      "run_at": "document_start", 
      "all_frames": true 
     } 
    ], 
    "content_security_policy" : "script-src 'self'; object-src 'self'", 
    "default_locale" : "en", 
    "description": "Test Web Applications Using Google Chrome", 
    "name": "Test", 
    "permissions": [ 
     "nativeMessaging", 
     "webNavigation", 
     "webRequest", 
     "webRequestBlocking", 
     "tabs", 
     "cookies", 
     "browsingData", 
     "debugger", 
     "<all_urls>", 
     "notifications", 
     "unlimited_storage" 
    ], 
    "version": "1.0.0.0", 
    "-ms-preload": { 
     "backgroundScript": "backgroundScriptsAPIBridge.js", 
     "contentScript": "contentScriptsAPIBridge.js" 
    }, 
    "minimum_edge_version" : "33.14281.1000.0" 
} 

回答

1

在Alexey Sidorov從this thread的幫助下,我想出瞭如何簽署Edge擴展。

Note: Please make sure do following steps in PowerShell, not command line.


創建一個自簽名證書

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

你可以在微軟開發者網站您應用的身份你的主題。

友好名稱可以是任何字符串。

2.導出證書

檢查指紋:

Set-Location Cert:\LocalMachine\My 
Get-ChildItem | Format-Table Subject, FriendlyName, Thumbprint 

你需要一個密碼,出於安全考慮出口。

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

證書安裝到受信任的根證書頒發機構。

在開始菜單中鍵入「管理計算機證書」,導航到受信任的根證書頒發機構\證書。右鍵單擊它,所有任務,導入按照嚮導完成導入。

4.註冊使用SignTool應用程序(該SignTool安裝在Windows 10 SDK,請確保它在你的系統路徑存在。)

檢查您的擴展的哈希算法:

提取物AppxBlockMap.xml在.appx文件,檢查HashMethod

<BlockMap xmlns="http://schemas.microsoft.com/appx/2010/blockmap" HashMethod="http://www.w3.org/2001/04/xmlenc#sha256"> 

散列算法是價值#後,例如,#sha256表示您使用SHA256作爲散列算法。現在

SignTool sign /fd <Hash Algorithm> /a /f <Path to Certificate>.pfx /p <Your Password> <File path>.appx 

5.您可以通過雙擊安裝你的應用。


官方參考:

Create a certificate for package signing

Sign an app package using SignTool