Posts Golang Slice
Post
Cancel

Golang Slice

SSL / TLS


๐Ÿ’ฟ SSL / TLS

image

  • SSL: Secure Sockets Layer(Netscape์‚ฌ์—์„œ ๊ฐœ๋ฐœ)
  • TLS: Transport Layer Security

๐Ÿ’ฟ Certificate ๋ณด์žฅ

image

  • ๋จผ์ € ์„œ๋ฒ„์ธก์— ์ธ์ฆ์„œ๊ฐ€ ํ•„์š”ํ•จ
    • ์ด ์ธ์ฆ์„œ ๋ฐœ๊ธ‰์„ ์œ„ํ•ด์„œ key(๊ณต๊ฐœํ‚ค, ๊ฐœ์ธํ‚ค)๋ฅผ ๋งŒ๋“ค์–ด์•ผ ํ•จ
      • ๊ณต๊ฐœํ‚ค(csr)๋ฅผ CA๊ธฐ๊ด€์— ๋ณด๋‚ด๋ฉด ๊ณต๊ฐœํ‚ค์™€ ์ธ์ฆ์„œ(crt)๋ฅผ ๋ฌถ์–ด์„œ ๋ณด๋‚ด์คŒ
  • Client๊ฐ€ ์„œ๋ฒ„ ์ ‘์†์‹œ ์ธ์ฆ์„œ๋ฅผ ์š”๊ตฌ
    • Server๊ฐ€ ์ธ์ฆ์„œ์™€ ๊ณต๊ฐœํ‚ค๋ฅผ ๋ณด๋ƒ„
  • Client๊ฐ€ CA๊ธฐ๊ด€์— ์ธ์ฆ์„œ๋ฅผ ํ™•์ธ ์š”์ฒญ
  • CA๊ธฐ๊ด€์˜ ํ™•์ธ์ด ์™„๋ฃŒ๋˜๋ฉด ์•”ํ˜ธํ™”๋œ session key๋ฅผ ๋ณด๋ƒ„
    • ํ†ต์‹ ํ• ๋•Œ ๋งˆ๋‹ค ๊ณต๊ฐœํ‚ค๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด resource๋ฅผ ๋„ˆ๋ฌด ๋งŽ์ด ์žก์•„๋จน์Œ(๊ณต๊ฐœํ‚ค๋Š” ๋งŽ์ด ๊ธธ๋‹ค)
    • ๊ทธ๋ž˜์„œ ์ฒ˜์Œ ํ†ต์‹ ํ•  ๋•Œ๋งŒ session key๋ฅผ ๊ณต๊ฐœํ‚ค๋กœ ์•”ํ˜ธํ™” ํ•ด์„œ ์‚ฌ์šฉ
  • ์ด์ œ ์ด session key๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ์•”ํ˜ธํ™”ํ•ด์„œ ์‚ฌ์šฉํ•จ ___

๐Ÿ’ฟ ๋™์ž‘

image

1> Client Hello

Client๊ฐ€ ์„œ๋ฒ„์— ์ ‘์†์„ ์‹œ๋„ํ• ๋•Œ ํ•˜๋Š” ์ฒซ๋ฒˆ์งธ ์ธ์‚ฌ

  • random: Client๋Š” 32 ๋ฐ”์ดํŠธ ๋‚œ์ˆ˜๊ฐ’์„ ์ „๋‹ฌ
    • ๋‚˜์ค‘์— ๋น„๋ฐ€ ๋ฐ์ดํ„ฐ(master secret)๋ฅผ ์œ„ํ•ด ์‚ฌ์šฉ๋จ
  • session ID: ์„ธ์…˜์„ ์ฒ˜์Œ ์ƒ์„ฑํ• ๋•Œ๋Š” ๋นˆ๊ฐ’, ์ด๋ฏธ ์ƒ์„ฑ๋œ ์„ธ์…˜์ด ์žˆ๋‹ค๋ฉด ๊ทธ ์„ธ์…˜ ID๋ฅผ ์ „๋‹ฌ
  • cipher suit: ํด๋ผ์ด์–ธํŠธ๊ฐ€ ์ง€์›๊ฐ€๋Šฅํ•œ ํ‚ค ๊ตํ™˜ ์•Œ๊ณ ๋ฆฌ์ฆ˜, ๋Œ€์นญํ‚ค ์•”ํ˜ธ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋“ฑ์„ ์•Œ๋ ค์คŒ
    • ํ‚ค๊ตํ™˜์€ RSA, ๋Œ€์นญํ‚ค๋Š” AES_128 GCM๋ฐฉ์‹๋“ฑ์„ ์‚ฌ์šฉ

2> Server Hello

์‚ฌ์šฉํ•  TLS๋ฒ„์ „, Client, ์„œ๋ฒ„ ๊ณตํ†ต์œผ๋กœ ์ง€์›๊ฐ€๋Šฅํ•œ Cipher suite, ์••์ถ•๋ฐฉ์‹๋“ฑ์„ client์— ์ „๋‹ฌ

  • random: ์„œ๋ฒ„๋„ 32byte ๋‚œ์ˆ˜๋ฅผ client์— ์ „๋‹ฌ
    • ์ด ์—ญ์‹œ master secret์ด๋ผ๋Š” ๋น„๋ฐ€ ๊ฐ’์„ ์ƒ์„ฑํ•  ๋•Œ ์‚ฌ์šฉ
  • session ID: ์„ธ์…˜ ์ •๋ณด

3> server certificate

์—ฌ๊ธฐ์„œ ์ธ์ฆ์„œ๋ฅผ ์ด์šฉํ•ด์„œ ํด๋ผ์ด์–ธํŠธ๋Š” ์„œ๋ฒ„๊ฐ€ ๋ฏฟ์„ ๋งŒํ•œ ์„œ๋ฒ„์ธ์ง€ ํ™•์ธํ•œ๋‹ค.(Certificate ๋ณด์žฅ ๋ถ€๋ถ„)

4> Server key exchange

ํ‚ค ๊ตํ™˜์— ํ•„์š”ํ•œ ์ •๋ณด๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

  • ํ•„์š”ํ•˜์ง€ ์•Š์œผ๋ฉด ์ด ๊ณผ์ •์„ ์ƒ๋žต์ด ๊ฐ€๋Šฅ
    • ์˜ˆ๋ฅผ ๋“ค์–ด ํ‚ค๊ตํ™˜ ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด Diffie-Hellman์œผ๋กœ ์‚ฌ์šฉํ•œ๋‹ค๋ฉด ์†Œ์ˆ˜, ์›์‹œ๊ทผ ๋“ฑ์ด ํ•„์š”ํ•จ

5> Certificate request

์„œ๋ฒ„ ์—ญ์‹œ ํด๋ผ์ด์–ธํŠธ๋ฅผ ์ธ์ฆํ•ด์•ผํ•  ๋•Œ ์ธ์ฆ์„œ๋ฅผ ์š”๊ตฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

  • ํ•„์š” ์ ˆ์ฐจ๋Š” ์•„๋‹˜

6> Server Hello Done

์„œ๋ฒ„์˜ ์ธ์‚ฌ๊ฐ€ ๋๋‚จ

7> Certificate

๋ฐฉ๊ธˆ ์ „ ์„œ๋ฒ„๊ฐ€ ์š”์ฒญํ–ˆ๋˜ ์ธ์ฆ์„œ๋ฅผ ์ค„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

  • ์„œ๋ฒ„๊ฐ€ ์š”์ฒญํ•˜์ง€ ์•Š์•˜์œผ๋ฉด ์ƒ๋žต๋จ

8> Client key exchange

ํ‚ค ๊ตํ™˜์— ํ•„์š”ํ•œ ์ •๋ณด(pre-master-secret)๋ฅผ ์„œ๋ฒ„์— ์ œ๊ณต

  • ์ ˆ๋Œ€ ๋…ธ์ถœ๋˜์–ด์„œ๋Š” ์•ˆ๋จ
  • ์„œ๋ฒ„๋กœ ๋ฐ›์€ random ๊ฐ’์„ ์žฌ๋ฃŒ๋กœ ํด๋ผ์ด์–ธํŠธ๊ฐ€ ์ƒ์„ฑํ•œ ๋žœ๋ค๊ฐ’์„ ์กฐํ•ฉํ•˜์—ฌ ์„œ๋ฒ„์— ์ „์†ก
    • ์ด ์ •๋ณด๋Š” ์ธ์ฆ์„œ์•ˆ์˜ ๊ณต๊ฐœํ‚ค๋กœ ์•”ํ˜ธํ™” ํ•ด์„œ ์ „์†กํ•œ๋‹ค.
    • ์•”ํ˜ธํ™”๋œ ์ •๋ณด๋ฅผ ์„œ๋ฒ„๊ฐ€ ๊ฐœ์ธํ‚ค๋กœ ๋ณตํ˜ธํ™” ํ•œ๋‹ค.
    • ์ด์ œ ๊ณต์œ ํ•˜๊ณ  ์žˆ๋Š” pre-master secret์„ ์ผ๋ จ์˜ ๊ณผ์ •์„ ๊ฑฐ์ณ master secret์œผ๋กœ ๋งŒ๋“ฌ
    • ์ด ํ‚ค๋ฅผ ๋Œ€์นญํ‚ค๋กœ ์‚ฌ์šฉ

9> Certificate verify

ํด๋ผ์ด์–ธํŠธ์— ๋Œ€ํ•œ Certificate request๋ฅผ ๋ฐ›์•˜๋‹ค๋ฉด ๋ณด๋‚ธ ์ธ์ฆ์„œ์— ๋Œ€ํ•œ ๊ฐœ์ธํ‚ค๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค๋Š” ๊ฒƒ์„ ์ฆ๋ช…

  • handshake ๊ณผ์ •์—์„œ ์ฃผ๊ณ  ๋ฐ›์€ ๋ฉ”์‹œ์ง€ + master secret์„ ์กฐํ•ฉํ•œ hash๊ฐ’์— ๊ฐœ์ธํ‚ค๋กœ ๋””์ง€ํ„ธ ์„œ๋ช…ํ•˜์—ฌ ์ „์†ก

10> Change cipher spec

ํ˜‘์ƒ๋œ ๋ณด์•ˆ ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ์ ์šฉํ•˜๊ฑฐ๋‚˜ ๋ณ€๊ฒฝ๋ ๋•Œ ์„œ๋ฒ„์—๊ฒŒ ์•Œ๋ฆฝ๋‹ˆ๋‹ค.

11> Client Finished

ํด๋ผ์ด์–ธํŠธ ๋

12> change cipher spec

ํด๋ผ์ด์–ธํŠธ์—๊ฒŒ ๋ณด์•ˆ ํŒŒ๋ผ๋ฏธํ„ฐ ๋ณ€๊ฒฝ์„ ์•Œ๋ฆฝ๋‹ˆ๋‹ค.

13> Finished

์„œ๋ฒ„๋„ ๋

This post is licensed under CC BY 4.0 by the author.

Golang Slice

Spring AOP