0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

PFX ファイルから証明書のインポート

Posted at

PFX ファイルを使用して証明書をエクスポートする方法と、それを使ってコードに署名する方法を以下に示します。

1. PFX ファイルから証明書のインポート

まず、PFX ファイルから証明書をインポートします。これには Import-PfxCertificate コマンドレットを使用します。以下は例です。

# PFX ファイルのパス
$pfxFilePath = "C:\Path\To\Your\Certificate.pfx"

# PFX ファイルから証明書をインポート
$pfxPassword = Read-Host -AsSecureString -Prompt "Enter PFX Password"
$cert = Import-PfxCertificate -FilePath $pfxFilePath -Password $pfxPassword -CertStoreLocation Cert:\CurrentUser\My

ここで、$pfxFilePath は PFX ファイルのパスを指定し、$pfxPassword は PFX ファイルのパスワードをセキュアに入力します。

2. 証明書の詳細を確認

証明書が正しくインポートされたことを確認します。以下のコマンドを使用して証明書の詳細を表示できます。

$cert | Format-List -Property *

3. PowerShell スクリプトに署名

証明書が正しくインポートされたら、PowerShell スクリプトに署名します。以下は例です。

# PowerShell スクリプトのパス
$scriptPath = "C:\Path\To\Your\Script.ps1"

# 証明書を使用してスクリプトに署名
Set-AuthenticodeSignature -Certificate $cert -FilePath $scriptPath

これで、PFX ファイルを使用して証明書をインポートし、PowerShell スクリプトに署名できるはずです。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?