qshinoの日記

Powershell関係と徒然なこと

SSL証明書作成

By powershell

Short

New-SelfSignedCertificate 
-DnsName "a.jp"  
-KeyAlgorithm RSA 
-KeyLength 2048 
-CertStoreLocation "Cert:\LocalMachine\My"
-NotAfter  (Get-Date).AddYears(10)

上記実行後、下記を実行。

certmgr

中間証明機関→証明書にストアされている。win10,21H1

cerlm

個人→証明書にストアされている

Long

Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved. # 証明書ストアのパス確認 

PS C:\Users\Administrator> Get-PSDrive | Format-Table -AutoSize -Wrap 

Name Used (GB) Free (GB) Provider Root CurrentLocation 
---- --------- --------- -------- ---- --------------- 
Alias Alias 
C 14.65 64.81 FileSystem 
C:\ Users\Administrator 
Cert Certificate \ 
Env Environment 
Function Function 
HKCU Registry HKEY_CURRENT_USER HKLM Registry HKEY_LOCAL_MACHINE Variable Variable 
WSMan WSMan 

# 自己署名証明書作成 
# -DnsName (DNS名) 
# -KeyAlgorithm (RSA | ECDSA) 
# -KeyLength (鍵長) 
# -CertStoreLocation (証明書ストア) 
# -NotAfter (有効期間 : 下例は 10年) 

PS C:\Users\Administrator> New-SelfSignedCertificate  -DnsName "a.jp"  -KeyAlgorithm RSA  -KeyLength 2048  -CertStoreLocation "Cert:\LocalMachine\My"  -NotAfter (Get-Date).AddYears(10) 

PSParentPath: Microsoft.PowerShell.Security\Certificate::LocalMachine\My 

Thumbprint 
Subject 
---------- ------- 
AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJ
 CN=a.jp