Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 
(연관된 글이 1개 있습니다.)

"Let's Encrypt" SSL 인증서를 Azure Cloud Services(classic)에 업데이트하는 방법

지난 글에도 썼지만,

Let's Encrypt 인증서 업데이트 주기: 90일
; https://www.sysnet.pe.kr/2/0/11005

주기가 엄청 빨리 오는군요. ^^;

문제는, "Azure App Services"에 올라가는 "Web App" 같은 경우는 Let's Encrypt를 위한 확장 도구들이 있는 반면,

Azure Let's Encrypt (x86)
; https://www.siteextensions.net/packages/letsencrypt/

Azure Let's Encrypt (x64)
; https://www.siteextensions.net/packages/letsencrypt64/

아쉽게도 "Azure Cloud Services(classic)"의 경우에는 애당초 확장이 없기 때문에 수작업으로 해야 합니다. (음... 이거 은근히 불편하군요. ^^; 시간 날 때 classic 서비스를 WebApp으로 바꿔야겠습니다.)

어쨌든 "Azure Cloud Services(classic)"에 올려진 사이트를 위해 인증서를 다시 업데이트해야 하는데 지난번 그 작업을 하려니,

"Let's Encrypt"에서 제공하는 무료 SSL 인증서를 IIS에 적용하는 방법 (1)
; https://www.sysnet.pe.kr/2/0/10958

가슴이 답답해집니다. ^^

혹시나 싶어, 그동안 좀 편해진 것이 있을까 싶어서 검색해 봤는데, 다행히 다음의 글이 나옵니다.

Using Let's Encrypt with IIS on Windows 
; https://weblog.west-wind.com/posts/2016/Feb/22/Using-Lets-Encrypt-with-IIS-on-Windows

오호~~~ 방법이 매우 쉬워졌습니다. 어디 한번 해볼까요? ^^ 우선, 다음의 링크에서 letsencrypt 도구를 다운로드받습니다.

letsencrypt-win-simple v1.9.1 
; https://github.com/Lone-Coder/letsencrypt-win-simple/releases

그다음, "Azure Cloud Services(classic)"에 올려진 웹 사이트가 동작 중인 서버에 RDP 접속을 합니다. Visual Studio를 이용하면 편한데, 이에 대해서는 다음의 글에서 설명하고 있으니 참고하세요.

Azure 구독 후 PaaS 서비스 만들어 보기
; https://www.sysnet.pe.kr/2/0/11023

RDP 접속이 된 컴퓨터에서, 다운로드 받은 letsencrypt 파일의 압축을 풀어줍니다. 그다음, 해당 서버에서 IIS 관리자를 실행시키고 여러분들의 웹 사이트에 대한 바인딩 정보를 열고, "http"에 대해 "Host name"의 값을 채워줍니다.

lets_cert_update_1.png

이제, "letsencrypt.exe" 파일을 그냥 실행만 해주면 됩니다. 그럼, 콘솔 프로그램이 뜨고 묻고 답하는 식으로 진행이 완료됩니다.

C:\lets_cert>letsencrypt.exe
Let's Encrypt (Simple Windows ACME Client)
Renewal Period: 60
Certificate Store: WebHosting

ACME Server: https://acme-v01.api.letsencrypt.org/
Config Folder: D:\Users\TestUser\AppData\Roaming\letsencrypt-win-simple\httpsacme-v01.api.letsencrypt.org
Certificate Folder: D:\Users\TestUser\AppData\Roaming\letsencrypt-win-simple\httpsacme-v01.api.letsencrypt.org
Loading Signer from D:\Users\TestUser\AppData\Roaming\letsencrypt-win-simple\httpsacme-v01.api.letsencrypt.org\Signer

Getting AcmeServerDirectory
Loading Registration from D:\Users\TestUser\AppData\Roaming\letsencrypt-win-simple\httpsacme-v01.api.letsencrypt.org\Registration

Scanning IIS Site Bindings for Hosts
 1: IIS www.sysnet.pe.kr (E:\sitesroot\0)

 W: Generate a certificate via WebDav and install it manually.
 F: Generate a certificate via FTP/ FTPS and install it manually.
 M: Generate a certificate manually.
 A: Get certificates for all hosts
 Q: Quit
Which host do you want to get a certificate for: 1

Authorizing Identifier www.sysnet.pe.kr Using Challenge Type http-01
 Writing challenge answer to E:\sitesroot\0\.well-known/acme-challenge/Oai93FK55h4rSBiPLcKglU6rQjRZaxC72db7tQkUVuc
 Writing web.config to add extensionless mime type to E:\sitesroot\0\.well-known\acme-challenge\web.config
 Answer should now be browsable at https://www.sysnet.pe.kr/.well-known/acme-challenge/Oai93FK55h4rSBiPLcKglU6rQjRZaxC72db7tQkUVuc
 Submitting answer
 Refreshing authorization
 Authorization Result: valid
 Deleting answer

Requesting Certificate
 Request Status: Created
 Saving Certificate to D:\Users\TestUser\AppData\Roaming\letsencrypt-win-simple\httpsacme-v01.api.letsencrypt.org\www.sysnet.pe.kr-crt.der
 Saving Issuer Certificate to D:\Users\TestUser\AppData\Roaming\letsencrypt-win-simple\httpsacme-v01.api.letsencrypt.org\ca-0A0141420000015385736A0B85ECA708-crt.pem
 Saving Certificate to D:\Users\TestUser\AppData\Roaming\letsencrypt-win-simple\httpsacme-v01.api.letsencrypt.org\www.sysnet.pe.kr-all.pfx
 Opened Certificate Store "WebHosting"
 Adding Certificate to Store
 Closing Certificate Store
 Adding https Binding

Warning creating HTTPS Binding for www.sysnet.pe.kr.
The HTTP binding is IP specific; the app can create it. However, if you have other HTTPS sites they will all get an invalid certificate error until you manually edit one of their HTTPS bindings.

You need to edit the binding, turn off SNI, click OK, edit it again, enable SNI and click OK. That should fix the error.

Otherwise, manually create the HTTPS binding and rerun the application.

You can see https://github.com/Lone-Coder/letsencrypt-win-simple/wiki/HTTPS-Binding-With-Specific-IP for more information.

Press Y to acknowledge this and continue. Press any other key to stop installing the certificate
^C
C:\lets_cert>

위의 출력 내용 중 굵은 색 부분을 보면 "Scanning IIS Site Bindings for Hosts"가 나오는데 거기가 바로 letsencrypt 도구가 발견한 웹 사이트 목록이 나오는 곳입니다. 따라서 "1"번을 선택해 주면 그곳의 hostname 값으로 SSL 인증서가 발급됩니다. 이후 자동으로 .pfx 파일로 인증서가 컴퓨터에 저장됩니다. 위의 출력에서 보면 다음의 경로에 해당합니다.

D:\Users\TestUser\AppData\Roaming\letsencrypt-win-simple\httpsacme-v01.api.letsencrypt.org\www.sysnet.pe.kr-all.pfx

그리곤 "Press Y to acknowledge this and continue. Press any other key to stop installing the certificate"라면서 사용자 입력을 기다리는데 여기서 Ctrl+C 키를 이용해 동작을 중지시켜 줍니다. 왜냐하면, 어차피 Azure의 VM은 임의로 재할당될 수 있기 때문에 이곳에 그 인증서를 설치해도 시간이 지나면 설정이 지워지므로 쓸모가 없습니다.

어쨌든, 지겨운 인증서 발급 단계는 끝났으므로 나머지는 www.sysnet.pe.kr-all.pfx 파일을 Azure Portal에 올려야 합니다.

SSL 인증서를 Azure Cloud Service에 적용하는 방법
; https://www.sysnet.pe.kr/2/0/11006

그런데, 주의할 것은 letsencrypt.exe가 저장한 .pfx 파일은 기본적으로 암호가 걸려있지 않습니다. 그런데, Azure Portal에 .pfx 파일을 올리려면 무조건 암호를 입력해야 합니다. 따라서, 어쩔 수 없이 .pfx 파일을 로컬에 설치한 후 그것을 다시 저장하면서 암호를 지정해야 합니다.

그렇게 인증서를 업로드 했으면 이제 Azure 프로젝트의 .cscfg 파일에 해당 Certificate 노드의 "thumbprint" 값을 갱신된 인증서의 것으로 바꾼 후 웹 사이트를 다시 게시하면 됩니다. 뭐 이 정도만 해도 많이 편해지긴 했지만 다음 3개월 후에는 좀 더 편해질 수 있는 방법을 연구해봐야겠습니다. ^^




참고로, letsencrypt.exe의 도움말을 보니, "--manualhost"라는 항목이 있군요. 따라서, Azure VM의 IIS 관리자에서 굳이 Hostname을 등록할 필요없이 letsencrypt 실행 중에 입력을 하는 것도 가능하겠습니다.





[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]

[연관 글]






[최초 등록일: ]
[최종 수정일: 6/27/2021]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




... [61]  62  63  64  65  66  67  68  69  70  71  72  73  74  75  ...
NoWriterDateCnt.TitleFile(s)
12091정성태12/25/201911826디버깅 기술: 147. pdb 파일을 다운로드하기 위한 symchk.exe 실행에 필요한 최소 파일 [1]
12090정성태12/24/201910482.NET Framework: 871. .NET AnyCPU로 빌드된 PE 헤더의 로딩 전/후 차이점 [1]파일 다운로드1
12089정성태12/23/201911180디버깅 기술: 146. gflags와 _CrtIsMemoryBlock을 이용한 Heap 메모리 손상 여부 체크
12088정성태12/23/201910145Linux: 28. Linux - 윈도우의 "Run as different user" 기능을 shell에서 실행하는 방법
12087정성태12/21/201910627디버깅 기술: 145. windbg/sos - Dictionary의 entries 배열 내용을 모두 덤프하는 방법 (do_hashtable.py) [1]
12086정성태12/20/201912630디버깅 기술: 144. windbg - Marshal.FreeHGlobal에서 발생한 덤프 분석 사례
12085정성태12/20/201910358오류 유형: 586. iisreset - The data is invalid. (2147942413, 8007000d) 오류 발생 - 두 번째 이야기 [1]
12084정성태12/19/201911013디버깅 기술: 143. windbg/sos - Hashtable의 buckets 배열 내용을 모두 덤프하는 방법 (do_hashtable.py) [1]
12083정성태12/17/201912331Linux: 27. linux - lldb를 이용한 .NET Core 응용 프로그램의 메모리 덤프 분석 방법 [2]
12082정성태12/17/201912088오류 유형: 585. lsof: WARNING: can't stat() fuse.gvfsd-fuse file system
12081정성태12/16/201913804개발 환경 구성: 465. 로컬 PC에서 개발 중인 ASP.NET Core 웹 응용 프로그램을 다른 PC에서도 접근하는 방법 [5]
12080정성태12/16/201911807.NET Framework: 870. C# - 프로세스의 모든 핸들을 열람
12079정성태12/13/201912939오류 유형: 584. 원격 데스크톱(rdp) 환경에서 다중 또는 고용량 파일 복사 시 "Unspecified error" 오류 발생
12078정성태12/13/201912971Linux: 26. .NET Core 응용 프로그램을 위한 메모리 덤프 방법 [3]
12077정성태12/13/201912453Linux: 25. 자주 실행할 명령어 또는 초기 환경을 "~/.bashrc" 파일에 등록
12076정성태12/12/201910683디버깅 기술: 142. Linux - lldb 환경에서 sos 확장 명령어를 이용한 닷넷 프로세스 디버깅 - 배포 방법에 따른 차이
12075정성태12/11/201911543디버깅 기술: 141. Linux - lldb 환경에서 sos 확장 명령어를 이용한 닷넷 프로세스 디버깅
12074정성태12/10/201911137디버깅 기술: 140. windbg/Visual Studio - 값이 변경된 경우를 위한 정지점(BP) 설정(Data Breakpoint)
12073정성태12/10/201912986Linux: 24. Linux/C# - 실행 파일이 아닌 스크립트 형식의 명령어를 Process.Start로 실행하는 방법
12072정성태12/9/201910287오류 유형: 583. iisreset 수행 시 "No such interface supported" 오류
12071정성태12/9/201912699오류 유형: 582. 리눅스 디스크 공간 부족 및 safemode 부팅 방법
12070정성태12/9/201914787오류 유형: 581. resize2fs: Bad magic number in super-block while trying to open /dev/.../root
12069정성태12/2/201911225디버깅 기술: 139. windbg - x64 덤프 분석 시 메서드의 인자 또는 로컬 변수의 값을 확인하는 방법
12068정성태11/28/201914413디버깅 기술: 138. windbg와 Win32 API로 알아보는 Windows Heap 정보 분석 [3]파일 다운로드2
12067정성태11/27/201911232디버깅 기술: 137. 실제 사례를 통해 Debug Diagnostics 도구가 생성한 닷넷 웹 응용 프로그램의 성능 장애 보고서 설명 [1]파일 다운로드1
12066정성태11/27/201911068디버깅 기술: 136. windbg - C# PInvoke 호출 시 마샬링을 담당하는 함수 분석 - OracleCommand.ExecuteReader에서 OpsSql.Prepare2 PInvoke 호출 분석
... [61]  62  63  64  65  66  67  68  69  70  71  72  73  74  75  ...