dotnet nuget verify

本文適用於: ✔️ .NET 5.0.100-rc.2.x SDK 與更新版本

名稱

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

概要

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

dotnet nuget verify -h|--help

描述

dotnet nuget verify 命令會驗證已簽署的 NuGet 套件。

注意

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

引數

  • package-path(s)

    為要驗證的套件指定檔案路徑。 您可以傳入多個位置引數,以驗證多個套件。

選項。

  • --all

    指定必須對套件執行所有可行的驗證。 系統預設只會驗證 signatures

注意

此命令目前僅支援 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

    列印如何使用命令的描述。

範例

  • 驗證 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