Django OpenSSL setting
INSTALL openssl
$ openssl version
OpenSSL 1.0.2s 28 May 2019version์ด ๋์ค์ง์์ผ๋ฉด ์ค์น๊ฐ ๋์ด์์ง ์์ ๊ฒ์ด๋ฏ๋ก ์ค์น๊ฐ ํ์ํ๋ค.
homebrew๋ก ์ค์นํ๊ธฐ
$ brew install opensslKey ์์ฑํ๊ธฐ
$ openssl genrsa 1024 > {{keyname}}.key
Generating RSA private key, 1024 bit long modulus
..................+++++
......+++++
e is 65537 (0x10001)Cert ํ์ผ ์์ฑํ๊ธฐ
$ openssl req -new -x509 -nodes -sha256 -days 365 -key {{keyname}}.key > {{certname}}.cert
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]:
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:
Email Address []:์ด๋ .key ํ์ผ๊ณผ .cert ํ์ผ์ manage.py ํ์ผ๊ณผ ๊ฐ์ depth์ ์์ฑํ๋ค.
์ธ์ฆ์๋ ์ค์นํ์ ํค์ฒด์ธ๊ด๋ฆฌ์์ ์ด ์ธ์ฆ์ ์ฌ์ฉ ์ ํญ์ ์ ๋ขฐ๋ก ๋ณ๊ฒฝํด์ค๋ค.

Install django-sslserver
์ด๋ ์ธ๋ถ ๋คํธ์ํฌ ์ ์์ด ์์ ๋กญ์ง ๋ชปํ ๋คํธ์ํฌ (ํ์ฌ ๋คํธ์ํฌ ๋ฑ)์์๋ SSL ์ธ์ฆ์ ๋ฌธ์ ๋ฑ์ผ๋ก pip๋ฅผ ํตํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๋ค์ด ๋ฐ ์ค์น๊ฐ ๋์ง ์์ ์ ์๋ค.
pip์ ์ต์
์ค --trusted-host ์ต์
์ ์ฌ์ฉํด ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ค์นํ๋ url์ ์ต์
์ผ๋ก ์ง์ ํ ์ค์นํด์ฃผ๋ฉด๋๋ค.
๋งค๋ฒ --trusted-host ์ต์
์ ์ถ๊ฐํ๊ธฐ ๊ท์ฐฎ์ ๊ฒฝ์ฐ์๋ .zshrc์ alias ์ค์ ์ ํ๋ฉด๋๋ค.
INSTALLED_APP
์ค์น๊ฐ ์๋ฃ๋๋ฉด Django ํ๋ก์ ํธ settings.py์ INSTALLED_APP์ ์ถ๊ฐํด์ค๋ค.
์๋ฒ๋ณ๋ก ํ๊ฒฝ์ค์ ์ ๋ถ๋ฆฌํ ๊ฒฝ์ฐ์๋ ์๋ง๊ฒ ์ถ๊ฐํด์ค๋ค.(
settings/base.py)
runsslserver
https ๋ก ์ ์ํ ์ ์๋ ๊ฒ์ ํ์ธํ ์ ์๋ค.
์ฐธ๊ณ
Last updated
Was this helpful?