[컴] Windows 에서 Let’s Encrypt 인증서 발급받기

 windows / ssl / tsl / https 인증서 / 쉽게 발급 / 인증서 /certificate / 


Windows 에서 Let’s Encrypt 인증서 발급받기

에 가면 각 language 별로, 인증서 발급시 사용가능한 tool 이 나와 있다.

기본적으로 사이트에선 Cerbot 을 추천하지만, test 용으로 사용할 것이라서 발급받기 쉬운 windows tool 을 사용하기로 한다.

여기선 powershell module을 사용해 보자.

설치

Install-Module -Name Posh-ACME -Scope CurrentUser

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
Import-Module Posh-ACME
PS C:\Users\user1111> Install-Module -Name Posh-ACME -Scope CurrentUser                                                                      

계속하려면 NuGet 공급자가 필요합니다.
'C:\Users\user1111\AppData\Local\PackageManagement\ProviderAssemblies'에서 NuGet 공급자를 사용할 수 있어야
합니다. 또한 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'를 실행하여 NuGet
공급자를 설치할 수 있습니다. 지금 PowerShellGet에서 NuGet 공급자를 설치하고 가져오시겠습니까?
[Y] 예(Y)  [N] 아니요(N)  [S] 일시 중단(S)  [?] 도움말 (기본값은 "Y"): Y

신뢰할 수 없는 리포지토리
신뢰할 수 없는 리포지토리에서 모듈을 설치하는 중입니다. 이 리포지토리를 신뢰하는 경우 Set-PSRepository
cmdlet을 실행하여 InstallationPolicy 값을 변경하십시오. 'PSGallery'에서 모듈을 설치하시겠습니까?
[Y] 예(Y)  [A] 모두 예(A)  [N] 아니요(N)  [L] 모두 아니요(L)  [S] 일시 중단(S)  [?] 도움말
(기본값은 "N"):Y
C:\Users\user1111\Documents\WindowsPowerShell\Modules\Posh-ACME\3.17.0\Posh-ACME.Format.ps1xml, , C:\Users\na
mh\Documents\WindowsPowerShell\Modules\Posh-ACME\3.17.0\Posh-ACME.Format.ps1xml: 다음 유효성 검사 예외로
인해 파일을 건너뛰었습니다. 이 시스템에서 스크립트를 실행할 수 없으므로 C:\Users\user1111\Documents\WindowsPo werShell\Modules\Posh-ACME\3.17.0\Posh-ACME.Format.ps1xml 파일을 로드할 수 없습니다. 자세한 내용은 about_ Execution_Policies(https://go.microsoft.com/fwlink/?LinkID=135170)를 참조하십시오..
위치 줄:1 문자:1 
+ Import-Module Posh-ACME
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Import-Module], RuntimeException
    + FullyQualifiedErrorId : FormatXmlUpdateException,Microsoft.PowerShell.Commands.ImportModuleCommand

발급

New-PACertificate enctest.mytest.com -AcceptTOS

PS C:\Users\user1111> Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
PS C:\Users\user1111> Get-ExecutionPolicy -List                                                                                                                                                                      
Scope ExecutionPolicy
----- ---------------   
MachinePolicy    Undefined                                                                             
UserPolicy       Undefined                                                                             
Process          Undefined                                                                             
CurrentUser      RemoteSigned                                                                          
LocalMachine     Undefined

PS C:\Users\user1111> Import-Module Posh-ACME
PS C:\Users\user1111> New-PACertificate enctest.mytest.com -AcceptTOS
Please review the Terms of Service here: https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf
경고: No email contacts specified for this account. Certificate expiration warnings will not be sent
unless you add at least one with Set-PAAccount.

Please create the following TXT records:

이상황에서 DNS 에 TXT record 를 추가한다. 아래 command 로 TXT 가 반영되었는지 확인할 수 있다.

  • nslookup.exe -q=TXT _acme-challenge.enctest.mytest.com

완료가 되면 아래처럼 결과가 보인다. 아래 적힌 것처럼 TXT record 는 이제 사용할 일이 없으니 지우면 된다.

Please remove the following TXT records:
------------------------------------------
_acme-challenge.enctest.mytest.com -> Q1GytfJfzcg5PvcCXDymvkVbQePUa-dBW5UgtW1349k
------------------------------------------


Subject                                  NotAfter                 KeyLength Thumbprint
-------                                  --------                 --------- ----------
CN=enctest.mytest.com 2021-01-25 오전 11:35:00 2048      C1DB2491871AF26D689A87DA2F...

인증서 위치

Get-PACertificate | Format-List

로 어디에 file 이 생성됐는지 확인할 수 있다. 기본적으로 %LOCALAPPDATA%\Posh-ACME 에 생성된다.



PS C:\Users\user1111> Get-PACertificate | Format-List


Subject       : CN=enctest.mytest.com
NotBefore     : 2020-10-27 오전 11:35:00
NotAfter      : 2021-01-25 오전 11:35:00
KeyLength     : 2048
Thumbprint    : C1DB2491871AF26D689A87DA2FD07D64740E8229
AllSANs       : {enctest.mytest.com}
CertFile      : C:\Users\user1111\AppData\Local\Posh-ACME\acme-v02.api.letsencrypt.org\100428009\user1111testuj28
                sphvrzc28kh.mytest.com\cert.cer
KeyFile       : C:\Users\user1111\AppData\Local\Posh-ACME\acme-v02.api.letsencrypt.org\100428009\user1111testuj28
                sphvrzc28kh.mytest.com\cert.key
ChainFile     : C:\Users\user1111\AppData\Local\Posh-ACME\acme-v02.api.letsencrypt.org\100428009\user1111testuj28
                sphvrzc28kh.mytest.com\chain.cer
FullChainFile : C:\Users\user1111\AppData\Local\Posh-ACME\acme-v02.api.letsencrypt.org\100428009\user1111testuj28
                sphvrzc28kh.mytest.com\fullchain.cer
PfxFile       : C:\Users\user1111\AppData\Local\Posh-ACME\acme-v02.api.letsencrypt.org\100428009\user1111testuj28
                sphvrzc28kh.mytest.com\cert.pfx
PfxFullChain  : C:\Users\user1111\AppData\Local\Posh-ACME\acme-v02.api.letsencrypt.org\100428009\user1111testuj28
                sphvrzc28kh.mytest.com\fullchain.pfx
PfxPass       : System.Security.SecureString

삭제

See Also

댓글 없음:

댓글 쓰기