카테고리 없음

[nestjs] windows powershell 환경에서 HTTPS 인증서 생성 및 적용 방법 입니다.

Hwoarang757 2025. 2. 26. 14:17

출처 :

https://xionwcfm.tistory.com/255

 

윈도우 환경에서 mkcert 사용해보자

🐕 mkcert...를 사용해봅시다. https://github.com/FiloSottile/mkcert GitHub - FiloSottile/mkcert: A simple zero-config tool to make locally trusted development certificates with any names you'd lik A simple zero-config tool to make locally trusted d

xionwcfm.tistory.com

https://msm1307.tistory.com/179

 

nestjs https 적용 (feat: mkcert)

mkcert란?로컬 개발 환경에서 쉽게 신뢰할 수 있는 인증서를 생성할 수 있는 도구이다. mkcert를 사용하면 로컬에서 브라우저가 신뢰할 수 있는 인증서를 생성할 수 있다. 설치mkcert 설치brew install m

msm1307.tistory.com

 


1. powershell 관리자 권한으로 실행 합니다.

 - choco 설치 진행 

$ Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))



2. mkcert를 설치 합니다.

$ choco install mkcert 
$ mkcert -install

 

"예(Y)"를 클릭 해주었습니다.

3. 인증서를 생성합니다.

 - 현재 실행하는 경로에 key.pem과 cert.pem 파일이 생성되는 것을 확인 하였습니다.

$ mkcert -key-file key.pem -cert-file cert.pem localhost 127.0.0.1 ::1

 



4. main.ts 부분을 수정 하였습니다 , (key.pem , cert.pem 파일의 경우 , 프로젝트 root 디렉터리에 배치 하였습니다. ) 
   ( src 상위 디렉터리 )  
   - 인증서에 대한 만료기간은 현재 일시에서 2년을 더한 일자로 확인 됩니다. 

  const httpsOptions = {
    key : fs.readFileSync('./key.pem'),
    cert : fs.readFileSync('./cert.pem')
  }

  //const app = await NestFactory.create(AppModule);
  const app = await NestFactory.create(AppModule ,{
    httpsOptions,
  });