Skip to content

Instantly share code, notes, and snippets.

@esctabcapslock
Last active March 16, 2022 04:32
Show Gist options
  • Save esctabcapslock/0feba97b6d07e64eb40043d50893c4bc to your computer and use it in GitHub Desktop.
Save esctabcapslock/0feba97b6d07e64eb40043d50893c4bc to your computer and use it in GitHub Desktop.

node.js https 사용법

  1. 개인키 생성
  • openssl genrsa -out private.key 2048
  1. 개인키로 공개키 생성
  • openssl rsa -in private.key -pubout -out public.key
  1. CSR 생성 (Certificate Signing Request - 인증서 서명 요청)
  • openssl req -new -key private.key -out private.csr
  1. CRT 인증서 만들기
  • openssl req -x509 -days 365 -key private.key -in private.csr -out mycommoncrt.crt -days 365

  • openssl x509 -in mycommoncrt.crt -out mycommonpem.pem -outform PEM

  • mycommonpem.pem 과 private.key 가 필요하다!!!

  • https://cinema4dr12.tistory.com/984 참조함

  • openssl genrsa 1024 > private.pem

  • openssl req -x509 -new -key private.pem > public.pem

  • 한 뒤, 두 파일을 생성하는 방법도 있다

node.js 적용방법

const https = require('https');
const options = {
    key: fs.readFileSync( "./private.key", "utf8" ),
    cert: fs.readFileSync( "./mycommonpem.pem", "utf8" )
};

var server = https.createServer(options,function (요청, 응답) {  (//이하 생략....```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment