[vscode] Live Server Extension https ์ฐ๊ฒฐํ๊ธฐ w/openssl
์์ํ๋ฉฐ
PWA ์ฐ์ต์ ์ํด์ ๊ฐ๋จํ ํ๋ก์ ํธ๋ฅผ ๊ตฌ์ฑํ๋ค.
192, 512px ์ฌ์ด์ฆ์ ๋ ๋ก๊ณ ์ src ํด๋์๋ index.html, index.js, master.css, manifest.json ์ด๋ ๊ฒ ํ์ผ์ ๋๊ณ ์๋ค. lighthouse๋ฅผ ํตํด pwa ๋ฆฌํฌํธ๋ฅผ ์ถ๋ ฅํ๋๋ฐ https ๋ถ๋ถ์ ํด๊ฒฐํด์ผ ํ ๊ฒ ๊ฐ์์, Live Server ์ค์ ์ ์๋ณด๊ธฐ๋ก ํ๋ค.
๋ฌธ์ ์ํฉ
Live Server extension์ ๋ค์ด๊ฐ ์ค๋ช ์ ๋ณด๋ ๋คํํ https๋ฅผ ์ง์ํ๋ค.
๊ณต์ฉ ์ฌ์ดํธ๊ฐ ์๋ ํ ์คํธ๋ฅผ ์ํจ์ด๋ ์์ฒด ์๋ช ์ ํตํด์ ๊ฐ๋จํ๊ฒ Open SSL์ ์ด์ฉํ๊ธฐ๋ก ํ๋ค. Open SSL์ ๋คํธ์ํฌ๋ฅผ ํตํ ๋ฐ์ดํฐ ํต์ ์ ์ฐ์ด๋ ๋ ํ๋กํ ์ฝ TLS, SSL์ ์คํ ์์ค ๋ฒ์ ์ด๋ฉฐ, ์ด ๋งํฌ์์ ๋ค์ด๋ก๋ ๋ฐ์ ์ ์์๋ค.
OpenSSL ๋ค์ด๋ก๋
OpenSSL ํ๊ฒฝ๋ณ์ ์ค์
์์ถ ํด์ ํ ์ด๋ฐ ํ์ผ๋ค์ ๊ฐ์ง๊ณ ์๋๋ฐ, ํ๊ฒฝ ๋ณ์ ์ง์ ์ ํตํด ์ข ๋ ํธํ๊ฒ ์ฌ์ฉํด๋ณด์. ๋ด PC -> ์์ฑ -> ๊ณ ๊ธ ์์คํ ์ค์ ๋ณด๊ธฐ -> ๊ณ ๊ธ ํญ ํด๋ฆญ -> ํ๊ฒฝ ๋ณ์ ํด๋ฆญ
์์คํ ๋ณ์ -> Path ํด๋ฆญ -> ์๋ก ๋ง๋ค๊ธฐ ํด๋ฆญ ํ OpenSSL ์์ถ ํด์ ํ ํด๋์ bin ํ์ผ ๊ฒฝ๋ก๋ฅผ ๋ฃ์ด์ค๋ค.
์ด๋ฒ์๋ ์์คํ ๋ณ์ -> ์๋ก๋ง๋ค๊ธฐ๋ฅผ ํด๋ฆญํด bin ํด๋ ๋ด openssl.cnf ํ์ผ์ ๊ฒฝ๋ก๋ฅผ ์ฐพ์์ ์ ๋ ฅํด์ค๋ค. ์ฌ๊ธฐ๊น์ง ํ๊ฒฝ ๋ณ์ ์ค์ ์ด ์๋ฃ๋์๋ค๋ฉด ํค ๋ฐ๊ธ์ ์ํด ๋ค์ CMD ์ฐฝ์ผ๋ก ์ด๋ํ๋ค.
์ธ์ฆํค ๋ฐ๊ธ
CMD ์ฐฝ์์ ์๋ ๋ช ๋ น์ด๋ฅผ ์ ๋ ฅํ๋ค.
openssl genrsa -aes256 -out localhost.key 2048
generating RSA์ ์ค์๋ง์ธ ๋ช ๋ น์ด genrsa๋ฅผ ํตํด ์๋ฐฉํฅ ์๊ณ ๋ฆฌ์ฆ์ธ (๊ทธ๋์ SSL ์ธ์ฆ ๋ฑ์ ์ฌ์ฉ๋๋ ๋ฐฉ์์ธ) AES-256 ๋ฐฉ์์ ์ํธ๋ฅผ ์์ฑํ๋ค๋ ๋ช ๋ น์ด์ด๊ณ , ํด๋น output์ localhost.key๋ผ๋ ์ด๋ฆ์ ํ์ผ์ ์ ์ฅํ๋ค๋ ์๋ฏธ์ด๋ค. 2048์ ์ฌ์ด์ฆ๋ฅผ ์๋ฏธํ๋ฉฐ, localhost.key๋ ๋ค๋ฅธ ์ด๋ฆ์ ํ์ผ๋ก ๋ณ๊ฒฝํด๋ ๋ฌด๋ฐฉํ๋ค.
์ด๋ ์ํธ๋ฅผ ๋ฌป๊ณ ํ์ธํ๋ ์์ ์ ๊ฑฐ์น๋ค.
ํค ํ์ผ์ด ์ ์์ฑ๋์๋ค๋ฉด, ๋ค์์ pem ํ์ผ์ ์์ฑํ๋ค. PEM ํ์ผ์ ๋ณด์ ์น ์ฌ์ดํธ๋ฅผ ์ธ์ฆํ๋๋ฐ ์ฌ์ฉ๋๋ ์ธ์ฆ์๋ฅผ Base64 ๋ฐฉ์์ผ๋ก ์ธ์ฝ๋ฉ๋ ํ์ผ์ด๋ค.
openssl req -days 3650 -new -newkey rsa:2048 -key localhost.key -x509 -out localhost.pem
# ์ดํ ์ง๋ฌธ ๋ช ๊ฐ์ง๊ฐ ๋์จ๋๋ฐ, ๊ตณ์ด ์ ์ง ์์๋ ๋๋ ๋ถ๋ถ์ ๊ณต๋ฐฑ์ผ๋ก ๋จ๊ธฐ๊ณ Enter ํค๋ก ๋์ด๊ฐ๋ ๋๋ค.
Enter pass phrase for [์๊น ์
๋ ฅํ localhost.key ๋๋ ์ฌ์ฉ์๊ฐ ์ง์ ํ ํ์ผ ์ด๋ฆ]:
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:KR
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:Seoul
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:localhost
Email Address []:
์ด์ ํด๋น ๊ฒฝ๋ก๋ฅผ ์ฐธ๊ณ ํด์ vscode ์ค์ ํ์ผ์ ์ถ๊ฐํ๋ค.
vscode
.vscode/settings.json
{
"liveServer.settings.port" : 5501,
"liveServer.settings.root": "/",
"liveServer.settings.CustomBrowser": "chrome",
"liveServer.settings.https": {
"enable": true,
"cert": "C:\\Users\\fnsk9\\https\\localhost.pem",
"key": "C:\\Users\\fnsk9\\https\\localhost.key",
"passphrase": "[์๊น ์
๋ ฅํ ๋น๋ฐ๋ฒํธ]"
}
}
Tips : ์ฌ์ฉ ๊ฐ๋ฅํ ๋ธ๋ผ์ฐ์ ์ต์ ์ ์๋์ ๊ฐ๋ค.
- Chrome
- chrome:PrivateMode
- firefox
- firefox:PrivateMode
- microsoft-edge
- blisk
์ฌ๊ธฐ๊น์ง ๋ง์น๊ณ ์๋ฒ๋ฅผ ๋ค์ ์คํ์ํค๋ฉด,
ํ๋กํ ์ฝ์ด https๋ก ๋ฐ๊ฟ ์คํ๋๊ณ ์๋ค.
์ฐธ๊ณ
www.youtube.com/watch?v=v4jgr0ppw8Q
oops.org/?t=lecture&sb=sslwrap&n=2
blog.naver.com/PostView.nhn?blogId=baekmg1988&logNo=221454486746