共用方式為


dotnet nuget 驗證

此文章適用於:✔️ .NET 6 SDK 與更新版本

Name

dotnet nuget verify - 驗證已簽署的 NuGet 套件。

Synopsis

dotnet nuget verify [<package-path(s)>]
    [--all]
    [--certificate-fingerprint <FINGERPRINT>]
    [-v|--verbosity <LEVEL>]
    [--configfile <FILE>]

dotnet nuget verify -h|--help

Description

命令 dotnet nuget verify 會驗證已簽署的 NuGet 套件。 在 .NET 10 和更新版本中,命令也會輸出套件的內容哈希,這可能有助於調查鎖定檔案驗證錯誤。

Note

此命令需要適用於程式代碼簽署和時間戳的憑證跟證書存放區。 此外,某些作系統和 .NET SDK 組合可能不支援此命令。 如需詳細資訊,請參閱 NuGet 簽署的套件驗證

Arguments

  • package-path(s)

    指定要驗證之封裝的檔案路徑。 您可以傳入多個位置自變數來驗證多個套件。

選項

  • --all

    指定所有可能的驗證都應該在套件上執行。 根據預設,只會 signatures 驗證。

Note

此命令目前僅 signature 支持驗證。

  • --certificate-fingerprint <FINGERPRINT>

    確認簽署者憑證符合其中一個指定的 SHA256 指紋。 這個選項可以多次提供,以提供多個指紋。

  • -v|--verbosity <LEVEL>

    設定命令的詳細資訊層級。 允許的值為 q[uiet]m[inimal]n[ormal]d[etailed]diag[nostic]。 預設值為 minimal。 如需詳細資訊,請參閱LoggerVerbosity

    下表顯示每個詳細資訊層級所顯示的內容。

    q[uiet] m[inimal] n[ormal] d[etailed] diag[nostic]
    Certificate chain Information ✔️ ✔️
    Path to package being verified ✔️ ✔️ ✔️
    Hashing algorithm used for signature ✔️ ✔️ ✔️
    Author/Repository Certificate -> SHA1 hash ✔️ ✔️ ✔️
    Author/Repository Certificate -> Issued By ✔️ ✔️ ✔️
    Timestamp Certificate -> Issued By ✔️ ✔️ ✔️
    Timestamp Certificate -> SHA-256 hash ✔️ ✔️ ✔️
    Timestamp Certificate -> Validity period ✔️ ✔️ ✔️
    Timestamp Certificate -> SHA1 hash ✔️ ✔️ ✔️
    Timestamp Certificate -> Subject name ✔️ ✔️ ✔️
    Author/Repository Certificate -> Subject name ✔️ ✔️ ✔️ ✔️
    Author/Repository Certificate -> SHA-256 hash ✔️ ✔️ ✔️ ✔️
    Author/Repository Certificate -> Validity period ✔️ ✔️ ✔️ ✔️
    Author/Repository Certificate -> Service index URL (If applicable) ✔️ ✔️ ✔️ ✔️
    Package name being verified ✔️ ✔️ ✔️ ✔️
    Type of signature (author or repository) ✔️ ✔️ ✔️ ✔️

    ❌ 表示 顯示的詳細數據。 ✔️ 表示顯示的詳細數據。

  • --configfile <FILE>

    要使用的 NuGet 組態檔 (nuget.config)。 若已指定,僅會使用此檔案中的設定。 若未指定,則將使用當前目錄中組態檔的階層。 如需詳細資訊,請參閱常見的 NuGet 組態

  • -?|-h|--help

    輸出有關如何使用命令的說明。

Examples

  • 驗證 foo.nupkg

    dotnet nuget verify foo.nupkg
    
  • 確認多個 NuGet 套件 - 指定目錄中的 foo.nupkg所有 .nupkg 檔案

    dotnet nuget verify foo.nupkg c:\mydir\*.nupkg
    
  • 確認 foo.nupkg 簽章符合指定的憑證指紋:

    dotnet nuget verify foo.nupkg --certificate-fingerprint CE40881FF5F0AD3E58965DA20A9F571EF1651A56933748E1BF1C99E537C4E039
    
  • 確認 foo.nupkg 簽章符合其中一個指定的憑證指紋:

    dotnet nuget verify foo.nupkg --certificate-fingerprint CE40881FF5F0AD3E58965DA20A9F571EF1651A56933748E1BF1C99E537C4E039 --certificate-fingerprint EC10992GG5F0AD3E58965DA20A9F571EF1651A56933748E1BF1C99E537C4E027
    
  • 僅使用來自指定 nuget.config 檔案的設定 (packagesourcestrustedSigners) 來確認 foo.nupkg 的簽章:

    dotnet nuget verify foo.nupkg --configfile ..\Settings\nuget.config