署名を管理する
このセクションでは、SMCTL で署名を管理するために使用するコマンドについてカバーします。これらのコマンドは、署名、署名の検証、および署名の削除です。フラグを使用してコマンドのパラメータを指定します。
前提条件
すべての署名に使用するツールについて、OSのパス変数に実行形式が存在する必要があります。
jarsigner、apksigner、jSign では、PKCS11 の設定ファイルは必須です。
署名に使用する鍵ペアのエイリアスか証明書のフィンガープリントを指定してください。
構成
署名に使用されるデフォルトのツールは、オペレーティングシステムに基づきます。例えば:
WindowsではSigntoolが使用されます。
Linuxでは、Jsign が Authenticode署名に使用されます。
署名のアルゴリズムは、<--sigalg string> フラグで設定できます(署名に使われるツールが提供するオプションに基づき適用されます)。
ダイジェストのアルゴリズムは、<--digalg string> フラグで設定できます(署名に使われるツールが提供するオプションに基づき適用されます)。
特定の種類のファイルに署名する必要がある場合は、<--ツールストリング> フラグを使用します (例: --ツール apksigner は *.apk ファイルにのみ署名します)。
特定の種類のファイルに署名が必要な場合は <--ツールストリング>フラグを使用します (例:--ツール apksigner は *.apk ファイルにのみ署名します)。
APK Signerでサポート対象 SDKの最低バージョンは18です。
コマンド
署名を管理するのに利用可能なすべての操作を一覧表示するには、次のコマンドを挿入します。
smctl signature --help
or
smctl signature -h
or
smctl sign --help
or
smctl sign -h
署名
署名コマンドは、以下のように始まります。
smctl signature <keypair alias>
or
smctl sign <keypair alias >
フラグ
署名コマンドは、これらのフラグをサポートしています。
ショートカット | フラグ | 説明 |
---|---|---|
--all-metadata | すべての署名のメタデータをキャプチャします。デフォルトでは、すべてのメタデータをキャプチャします。 | |
--certificate string | 署名に使用する証明書のパス。 形式: --certificate="<value>" | |
--checksum-after-signing | 署名のメタデータをキャプチャ - 署名後のチェックサム。デフォルトでキャプチャするには空白のままにします。 | |
--checksum-before-signing | 署名のメタデータをキャプチャ - 署名されていないファイルの署名前のチェックサム。デフォルトでは、キャプチャは空白のままです。 | |
--config-file string | PKCS11設定ファイルのパス。 形式: --config-file="<value>" | |
--deep | Sign all internal frameworks and plugins (This flag only applies to Apple codesign) (default true) 注記This flag only applies to Apple codesign commands. | |
-d | --digalg string | Specify the digest algorithm to use for signing (default based on the tool used for signing). Format: --digalg="<value>" |
--digest-algorithm | Capture the digest algorithm in the signature metadata. Leave blank to capture by default. | |
--digicert-ctk-app-path string | Provide the path to DigiCert SSM Signing Clients.app. 注記This flag only applies to Apple codesign and productsign commands. | |
--digicert-ctk-cli-path string | Provide the path to DigiCert SSM Signing Clients.app's CLI. 注記This flag only applies to Apple codesign and productsign commands. | |
--dryrun | Verify if the file can be signed without actually signing it (This flag only applies to Apple codesign) | |
--entitlements-file-path | Specify the entitlements file path. 注記This flag only applies to Apple codesign commands. | |
--exit-non-zero-on-fail | Returns a non-zero status if any files fail to be signed during bulk signing. | |
--failfast | Stops bulk signing immediately upon encountering the first file that cannot be signed. | |
--file-location | 署名キャプチャのメタデータ - ファイルの場所。デフォルトでキャプチャするには空白のままにします。 | |
--file-name | 署名キャプチャのメタデータ - ファイル名。デフォルトでキャプチャするには空白のままにします。 | |
-f | --fingerprint string | 署名に使用する証明書のフィンガープリント。 形式: --fingerprint="<value>" 注記For Apple codesign and productsign, after the key is added to the token. |
--force | Replace existing signatures (default value 'true'). 注記This flag only applies to Apple codesign commands. | |
--identity string | Specify the apple developer or installer certificate that you will use to sign with. This information can be found using security export-smartcard. 注記This flag only applies to Apple codesign commands, after the key is added to the token. | |
-i | --input string | 入力ファイルまたはフォルダのパス。フォルダを指定した場合は、そのフォルダ内のすべてのファイルに署名されます。 形式: --input="<value>" |
--keychain-path string | Provide the path to Keychain (This flag only applies to Apple productsign) | |
-k | --keypair-alias string | 署名に使用する鍵ペアのエイリアス。 形式: --keypair-alias="<value>" |
--output-file | Signed package file (should be different than input file) 注記This flag is compulsory for Apple productsign. | |
--openssl-pkcs11-engine string | Provide the path to the OpenSSL PKCS11 engine. 注記This flag only applies to osslsigncode. | |
--pkcs11-module string | Provide the absolute path to the DigiCert® Software Trust Manager PKCS11 library. | |
--preserve-metadata | Preserve the metadata. 注記This flag only applies to Apple codesign commands. | |
-s | --sigalg string | 使用する署名アルゴリズム(デフォルトは、署名に使用したツールに基づく)。 形式: --sigalg="<value>" |
--signing-tool | 署名キャプチャのメタデータ - 署名ツール。デフォルトでキャプチャするには空白のままにします。 | |
--timestamp | タイムスタンプの有効・無効を設定します。デフォルトは有効です。 | |
--timestamp-flag | 署名のメタデータを取得する。(タイムスタンプが実行されたかどうか)デフォルトでキャプチャするには空白のままにします。 | |
-t | --tool string | 署名に使用するツール(空白のままだと拡張子で署名されます)。 形式: --tool="<value>" |
--tsa-url | 署名のメタデータをキャプチャ - TSA URL (タイムスタンプURLを使用します)。デフォルトでキャプチャするには空白のままにします。 | |
-v | --verbose | 署名の冗長ロギング。 |
-h | --help | 署名に関するヘルプ。 |
例
説明: 指定されたファイルまたはフォルダに、指定された鍵ペアと証明書で署名します。
コマンド:
smctl sign --keypair-alias=<keypair alias> --config-file <path to config file> --input <path to file or folder to be signed>
コマンドの例:
smctl sign --keypair-alias=keypair-dynamic-kp1 --config-file C:\Users\Name\Desktop\smctl\pkcs11properties.cfg --input C:\Users\Name\Desktop\folder_or_files_to_sign
説明: 指定されたファイルまたはフォルダに、提供された証明書のフィンガープリントを使用して署名します。このコマンドは、Windowsでのみ動作します。
コマンド:
smctl sign --keypair-alias=<keypair alias> --input <path to file or folder to be signed>
コマンドの例:
smctl sign --keypair-alias=keypair-dynamic-kp1 -i C:\Users\Name\Desktop\folder_or_files_to_sign
注記
It is no longer necessary to add the <--certificate string> flag to the command because the certificate is automatically downloaded when you specify the keypair alias.
Apple examples
Description: Codesign a .app file using the keypair alias of the Apple certificate.
Command:
smctl-mac-x64 sign --keypair-alias <keypair_alias of apple certificate> --input <path_of_app or dmg_file_to_be_signed>
Command sample:
smctl-mac-x64 sign -k apple_codesign --verbose=true --input /Users/Name/Downloads/Example.app
Description: Verify if the file can be signed using codesign.
Command:
smctl-mac-x64 sign --keypair-alias <keypair_alias of apple certificate keypair> --dryrun=true --input <path_of_app/dmg_file_to_be_signed>
Command sample:
smctl-mac-x64 sign -k apple_codesign --verbose=true –dryrun=true --input /Users/Name/Downloads//Example.app
Description: Verify if .app file was signed.
Command:
smctl-mac-x64 sign verify --input <path_of_signed_app/dmg_file>
Command sample
smctl-mac-x64 sign verify --input /Users/Name/Downloads//Example.app
Description: Sign .pkg file using productsign.
Command:
smctl-mac-x64 sign --keypair-alias < keypair_alias of apple certificate > --verbose --input <path_of_pkg_file_to_be_signed>
Command sample:
smctl-mac-x64 sign -k apple_installer_productsign --verbose=true --input /Users/Name/Downloads/test.pkg
Description: Verify if .pkg file was signed.
Command:
smctl-mac-x64 sign verify --verbose --input <path_of_signed_pkg_file>
Command sample
smctl-mac-x64 sign verify --verbose=true --input /Users/Name/Downloads/test.pkg
サブコマンド
署名コマンドは、これらサブコマンドをサポートしています。
smctl signature <subcommand>
or
smctl sign <subcommand>
サブコマンド | 説明 |
---|---|
署名を削除する | |
署名を検証する | |
Sign hashes. | |
Verify hashes. | |
Sign and verify JSON SBOMs using in-toto functionality. |
署名を削除する
以下で始まる署名コマンドを削除します。
smctl sign remove
フラグ
署名を削除するコマンドは、以下のフラグをサポートしています。
ショートカット | フラグ | 説明 |
---|---|---|
-i | --input string | ファイルまたはフォルダを指定します。フォルダを指定すると、そのフォルダ内のすべてのファイルの署名が削除されます(signtool のみサポート)。 形式: --input="<value>" |
-h | --help | 削除に関するヘルプ。 |
例
説明: 指定されたファイルまたは指定されたフォルダ内のファイルの電子署名を削除します。
コマンド:
smctl sign remove --input <path to file or folder to be signed>
コマンドの例:
smctl sign remove -i C:\Users\Name\Desktop\file_or_folder_with_files_to_be_signed
署名を検証する
署名検証のコマンドは、以下のように始まります。
smctl signature verify
or
smctl sign verify
フラグ
署名の検証コマンドは、以下のフラグをサポートしています。
ショートカット | フラグ | 説明 |
---|---|---|
-f | --fingerprint string | 検証に使用する証明書のフィンガープリント。これは、使用するツールのオプションに基づき適用されます。 形式: --fingerprint="<value>" |
-i | --input string | ファイルまたはフォルダを指定します。フォルダを指定した場合は、そのフォルダ内のすべてのファイルが検証の対象となります。 形式: --input="<value>" |
-t | --tool | Specify the signing tool to be used for signing files. Omit this parameter to allow SMCTL to select an appropriate signing tool based on the file extension. |
-q | --quiet | Specify this parameter to limit the output of the command to a simple one confirmation of success or failure. |
-v | --verbose | Specify this parameter to enable detailed output of the command, providing comprehensive information about the signing process, including success and failure details. |
-h | --help | 検証に関するヘルプ。 |
例
説明: 指定されたファイルパスにある証明書のフィンガープリントで参照される署名を検証します。
コマンド:
smctl sign verify --fingerprint <certificate fingerprint> --input <path to file or folder to be verified>
コマンドの例:
smctl sign verify --fingerprint da39a3ee5e6b4b0d3255bfef95601890afd80709 -i C:\Users\Name\Desktop\file_or_folder_with_files_to_be_verified