自己証明書作成時に有効期限の開始日を指定する方法を教えてください

:white_question_mark: Question

自己証明書作成時に有効期限の開始日を指定する方法を教えてください

:light_bulb: Answer

以下のように記載してください。

証明書の有効期限開始日を指定(例:2025年7月20日から有効)

$startDate = Get-Date “2025-07-20”

$ssc = New-SelfSignedCertificate -FriendlyName "TestingCertificate"
-DnsName “loadbalancer.domain.local”,“node1.domain.local”,“node2.domain.local” `
-NotBefore $startDate

$store = New-Object System.Security.Cryptography.X509Certificates.X509Store(“Root”, “LocalMachine”)
$store.Open(“MaxAllowed”)
$store.Add($ssc)

$pass = ConvertTo-SecureString -String “myPass” -Force -AsPlainText
Export-PfxCertificate -Cert $ssc -FilePath “C:\temp\testingCertificate.pfx” -Password $pass