Home > 付録 > Prepare a Certificate for the Custom Azure App > Windows PowerShell を使用する証明書の準備
Export to PDFWindows PowerShell を使用して自己署名入り証明書を作成する方法については、以下の説明を参照してください。
*Note: 以下の手順は、Windows 10 または Windows 11 のオペレーション システムを使用したマシンで Windows PowerShell を実行することに基づいています。
マシン上の Windows PowerShell を右クリックし、ドロップダウン リストから 管理者として実行 を選択します。
Refer to the following example to use the New-SelfSignedCertificate cmdlet to generate certificate files.
$cert = New-SelfSignedCertificate -Subject CN=AvePointCustomApp -CertStoreLocation 'Cert:\CurrentUser\My' -NotAfter (Get-Date).AddMonths(24)
キーボードの Enter を押します。
*Note: コマンドでパラメーターをカスタマイズするには、以下の情報を参照してください。
Subject – このパラメーターは、証明書の件名を示します。通常、証明書が発行されるエンティティを識別する共通名 (CN) が含まれます。
CertStoreLocation – このパラメーターは、新しい証明書の保存場所を示します。********ユーザー固有の保存場所とマシン全体の保存場所から選択できます。 For example, -CertStoreLocation 'Cert:\CurrentUser\My' for the current user or -CertStoreLocation 'Cert:\LocalMachine\My' for the local machine.
NotAfter – このパラメーターは、証明書の有効期限を設定します。 The Get-Date cmdlet retrieves the current date and time, and AddMonths(24) adds 24 months to it, meaning the certificate will be valid for two years from the date of creation. If necessary, you can change the number of AddMonths.
以下のコマンドを入力して、.crt (または .cer)ファイルをエクスポートします。
Export-Certificate -Cert $cert -FilePath AvePointCustomApp.crt
以下のことに注意してください。
.cer ファイルをエクスポートする場合、上記のコマンドレットの例で .crt を .cer に置き換えてください。
このコマンドで、ファイルは PowerShell セッションの現在の作業ディレクトリに保存されます。別のディレクトリへの保存に希望する場合、以下のコマンドレット例を参考にフル パスを指定してください。
Export-Certificate -Cert $cert -FilePath "C:\Temp\AvePointCustomApp.crt"
以下のコマンドを入力して、パスワード付きの .pfx ファイルをエクスポートします。
Export-PfxCertificate -Password $(Read-Host -AsSecureString -Prompt "Enter a password to protect the certificate") -Cert $cert -FilePath AvePointCustomApp.pfx
以下のことに注意してください。
.pfx ファイルにはプライベート キーが含まれています。
このコマンドで、ファイルは PowerShell セッションの現在の作業ディレクトリに保存されます。別のディレクトリへの保存に希望する場合、以下のコマンドレット例を参考にフル パスを指定してください。
Export-PfxCertificate -Password $(Read-Host -AsSecureString -Prompt "Enter a password to protect the certificate") -Cert $cert -FilePath "C:\Temp\AvePointCustomApp.pfx"
キーボードの Enter を押します。
上記のステップの完了後、2 件の証明書ファイルを取得することができます。
証明書ファイルを削除する場合、以下のコマンドを入力して、キーボードの Enter キーを押します。
Remove-Item "Cert:\CurrentUser\My$($cert.Thumbprint)”