[Linux] SSL/TLS ์ธ์ฆ์„œ ๋งŒ๋“ค๊ธฐ

2022. 11. 16. 23:09ใ†System ์ž‘์—…์‹ค/LINUX

728x90
๋ฐ˜์‘ํ˜•

 





 

"์ด ํฌ์ŠคํŒ…์€ ์ฟ ํŒก ํŒŒํŠธ๋„ˆ์Šค ํ™œ๋™์˜ ์ผํ™˜์œผ๋กœ, ์ด์— ๋”ฐ๋ฅธ ์ผ์ •์•ก์˜ ์ˆ˜์ˆ˜๋ฃŒ๋ฅผ ์ œ๊ณต๋ฐ›์Šต๋‹ˆ๋‹ค."







๐Ÿš€ SSL/TLS

    ๐Ÿ”ฝ  Linux(CentOS 7.9)

        ๐Ÿ“ฆ ์ธ์ฆ์„œ ๋งŒ๋“ค๊ธฐ


์ตœ์ดˆ ์ฃผ๋‹ˆํ•˜๋ž‘์€ ์œ„์™€ ๊ฐ™์ด ์ธ์ฆ์„œ๋ฅผ ์ €์žฅํ•  Directory๋ฅผ ๋งŒ๋“ค์–ด ์ฃผ์—ˆ์–ด์š”.


openssl genrsa -des3 -out server.key 2048


๊ทธ๋ฆฌ๊ณ , Server์˜ ๊ฐœ์ธํ‚ค๋ฅผ ๋งŒ๋“ค์–ด ์ฃผ๋Š” ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•ด ์ฃผ์—ˆ์–ด์š”.

Enter pass phrase for server.key: ์ด ๋ถ€๋ถ„์—๋Š” Key ๊ฐ’์œผ๋กœ ์ด์šฉ๋  ๊ฐ’์„ ์ž…๋ ฅํ•ด ์ฃผ์–ด์•ผํ•˜๊ณ ,
๊ทธ ๋‹ค์Œ์€ ๋™์ผํ•œ ๊ฐ’์„ ์ž…๋ ฅํ•ด์„œ ๊ฒ€์ฆ ํ•ด์ฃผ์–ด์•ผ ํ•ด์š”.



์ด๋ฒˆ์—๋Š” ์ธ์ฆ ์š”์ฒญ์„œ ์ƒ์„ฑ์„ ํ•ด๋ณผ๊ฒŒ์š”.

์ฐธ๊ณ ํ•  ๊ฒƒ์€ CN(Common Name)์€ ์ด ์ธ์ฆ์„œ๋ฅผ ์ฃผ์ฒด์ ์œผ๋กœ ์‚ฌ์šฉํ•  Server์˜ IP์ฃผ์†Œ๋‚˜, Domain Name์„ ์ž…๋ ฅํ•ด ์ฃผ๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.
์ด๋ฒˆ์— ์ฃผ๋‹ˆํ•˜๋ž‘์€ Docker Registry๋ฅผ ๊ตฌ์ถ•ํ•˜๋ฉด์„œ SSL/TLS๋ฅผ ๊ตฌ์ถ•ํ•˜๊ณ  ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ํ•ด๋‹น Server์˜ Container ๋‚ด๋ถ€ IP๋ฅผ ์ž…๋ ฅํ•ด ์ค„๊ฑฐ์—์š”.

openssl req -new -key {Key File ์ด๋ฆ„}.key -out {์ธ์ฆ์„œ ์ด๋ฆ„ - ์ž„์˜ ์ง€์ •}.csr

๋ฐ˜์‘ํ˜•


์ฃผ๋‹ˆํ•˜๋ž‘์€ ์œ„์™€ ๊ฐ™์ด ์ธ์ฆ ์š”์ฒญ์„œ๋ฅผ ๋งŒ๋“ค์–ด ์ฃผ์—ˆ์–ด์š”.

์ฐธ๊ณ ๋กœ CN์„ ๋นผ๊ณ ๋Š” ๋ชจ๋‘ Enter๋ฅผ ๋ˆŒ๋Ÿฌ ๊ทธ๋ƒฅ ๋„˜์–ด๊ฐ€๋„ ๋ฌด๋ฐฉํ•ฉ๋‹ˆ๋‹ค.


openssl rsa -in {Key File ์ด๋ฆ„}.key -out {Key File ์ด๋ฆ„}.key


์œ„์™€ ๊ฐ™์ด ๋ช…๋ น์–ด๋ฅผ ์ด์šฉํ•˜์—ฌ Key File ์•”ํ˜ธํ™”๋ฅผ ํ•ด์ œํ•ด ์ฃผ์—ˆ์–ด์š”.

์ฐธ๊ณ ๋กœ Enter pass phrase for server.key: ์—๋Š” Key File์„ ์ƒ์„ฑํ•  ๋•Œ, ์ž…๋ ฅํ–ˆ๋˜ ๋‚ด์šฉ์„ ์ž…๋ ฅํ•ด ์ฃผ์—ˆ์–ด์š”.


echo subjectAltName=IP:{SSL/TLS ํ†ต์‹ ํ•˜๊ณ ์ž ํ•˜๋Š” Server IP},IP:127.0.0.1 > extfile.cnf


SAN ์„ค์ •์„ ์œ„ํ•ด Config File์„ ์œ„์™€ ๊ฐ™์ด ๋งŒ๋“ค์–ด ์ฃผ์—ˆ์–ด์š”.

์œ„์˜ ์„ค์ •์„ ์•ˆํ•ด์ฃผ๋ฉด ์ฐจ ํ›„ Docker Registry์— Push๋ฅผ ํ–ˆ์„ ๋•Œ, Error๊ฐ€ ๋ฐœ์ƒํ•˜๊ธฐ ๋•Œ๋ฌธ์ด์—์š”.


openssl x509 -req -days {์ธ์ฆ์„œ ํ™œ์„ฑํ™” ๊ธฐ๊ฐ„(์ผ ์ˆ˜ ๊ธฐ์ค€)} -signkey {Key File ์ด๋ฆ„}.key -in {์ธ์ฆ์„œ File ์ด๋ฆ„}.csr -out {์ธ์ฆ์„œ File ์ด๋ฆ„}.crt -extfile extfile.cnt

728x90


์ด์ œ ์ž์ฒด ์„œ๋ช…์„ ํ†ตํ•ด ์ธ์ฆ์„œ๋ฅผ ์ƒ์„ฑํ•ด ์ฃผ์—ˆ์–ด์š”.


๋‹ค์Œ์€ ์ธ์ฆ์„œ๋ฅผ ์‹ค์ œ ์‚ฌ์šฉํ•˜๊ณ ์ž ํ•˜๋Š” Server์— ์ ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์•Œ์•„์•ผ ํ•ด์š”.

์œ„์—์„œ๋„ ์–ธ๊ธ‰ํ–ˆ์ง€๋งŒ, ์ฃผ๋‹ˆํ•˜๋ž‘์€ Docker Registry๋ฅผ ์ด์šฉํ•˜๊ธฐ ์œ„ํ•ด ์œ„ ์ž‘์—…์„ ํ–ˆ๊ณ ,
์ด ํ›„ ์ž‘์—…์€ ๊ทธ ๊ณณ์—์„œ ์ •๋ฆฌ๋ฅผ ํ•ด๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

ํ•ด๋‹น ์ž‘์—…์— ๋Œ€ํ•œ ๋‚ด์šฉ์€ ์ด ๊ณณ์— ์ค€๋น„ํ•ด ๋‘˜๊ฒŒ์š”!

๊ทธ๋Ÿผ ํ•ด๋‹น ์ •๋ฆฌ ์ž๋ฃŒ์—์„œ ๋ต๊ฒŒ์š” :)









๐Ÿง ์ฐธ๊ณ  ์ž๋ฃŒ

 

[Docker Registry] ๋„์ปค ์‚ฌ์„ค ์›๊ฒฉ ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ ๋งŒ๋“ค๊ธฐ

Contents 0. Prologue 1. Registry ์ด๋ฏธ์ง€ ๋‹ค์šด๋กœ๋“œ 2. SSL ์ธ์ฆ์„œ ์ƒ์„ฑ ๋ฐ ์ ์šฉ 3. Image Pull/Push ํ•ด๋ณด๊ธฐ Docker Registry ๋ฅผ ํ™œ์šฉํ•ด ๊ฐœ์ธ์šฉ ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ๋ฅผ ์›๊ฒฉ ์„œ๋ฒ„์— ๊ตฌ์ถ•ํ•˜๊ณ  ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์•Œ์•„๋ด…๋‹ˆ๋‹ค. 0. Prol

5equal0.tistory.com

 

 

 

 

 

 

 

 

 

728x90
๋ฐ˜์‘ํ˜•