Home > Network > 2024 > ๐ŸŒ[Network] WSS(WebSocket Secure) ํ”„๋กœํ† ์ฝœ์ด๋ž€ ๋ฌด์—‡์ผ๊นŒ์š”?

๐ŸŒ[Network] WSS(WebSocket Secure) ํ”„๋กœํ† ์ฝœ์ด๋ž€ ๋ฌด์—‡์ผ๊นŒ์š”?
Network

๐ŸŒ[Network] WSS(WebSocket Secure) ํ”„๋กœํ† ์ฝœ์ด๋ž€ ๋ฌด์—‡์ผ๊นŒ์š”?

  • WSS(WebSocket Secure)๋Š” WebSocket ํ”„๋กœํ† ์ฝœ์˜ ๋ณด์•ˆ๋ฒ„์ „์ž…๋‹ˆ๋‹ค.
  • WebSocket์€ ํด๋ผ์ด์–ธํŠธ์™€ ์„œ๋ฒ„ ๊ฐ„์˜ ์–‘๋ฐฉํ–ฅ ํ†ต์‹ ์„ ์œ„ํ•œ ํ”„๋กœํ† ์ฝœ๋กœ, ws://๋Š” ๋ณด์•ˆ์ด ์ ์šฉ๋˜์ง€ ์•Š์€ ์ผ๋ฐ˜ WebSocket ์—ฐ๊ฒฐ์„ ์˜๋ฏธํ•˜๋ฉฐ, wss://๋Š” TLS(Transport Layer Security) ์•”ํ˜ธํ™”๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋ณด์•ˆ WebSocket ์—ฐ๊ฒฐ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค.

1๏ธโƒฃ WSS(WebSocket Secure)์˜ ํŠน์ง•.

1๏ธโƒฃ TLS(Transport Layer Security) ์•”ํ˜ธํ™” ์ง€์›.

  • WSS(WebSocket Secure)๋Š” HTTPS(Hypertext Transfer Protocol Secure)๊ณผ ์œ ์‚ฌํ•˜๊ฒŒ TLS/SSL ์ธ์ฆ์„œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ฐ์ดํ„ฐ๋ฅผ ์•”ํ˜ธํ™”ํ•ฉ๋‹ˆ๋‹ค.
    • ์ด๋ฅผ ํ†ตํ•ด ํด๋ผ์ด์–ธํŠธ์™€ ์„œ๋ฒ„ ๊ฐ„์˜ ํ†ต์‹ ์„ ๋ณดํ˜ธํ•˜๊ณ , ๋ฐ์ดํ„ฐ๊ฐ€ ๋„์ฒญ, ๋ณ€์กฐ๋˜์ง€ ์•Š๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.

2๏ธโƒฃ ๋ณด์•ˆ ๊ฐ•ํ™”.

  • WSS๋Š” ์ผ๋ฐ˜ WebSocket(ws://)๋ณด๋‹ค ๋ณด์•ˆ ์ˆ˜์ค€์ด ๋†’์œผ๋ฉฐ, ๋„คํŠธ์›Œํฌ ํŠธ๋ž˜ํ”ฝ์„ ๊ฐ์‹œํ•˜๊ฑฐ๋‚˜ ๊ณต๊ฒฉ์ž๊ฐ€ ๋ฐ์ดํ„ฐ๋ฅผ ๊ฐ€๋กœ์ฑ„๋Š” ๊ฒƒ์„ ๋ฐฉ์ง€ํ•ฉ๋‹ˆ๋‹ค.

3๏ธโƒฃ HTTPS ํ™˜๊ฒฝ๊ณผ ํ•จ๊ป˜ ์‚ฌ์šฉ.

  • WSS๋Š” HTTPS ํ™˜๊ฒฝ์—์„œ ์‚ฌ์šฉ๋˜๋ฉฐ, HTTPS๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ์›น์‚ฌ์ดํŠธ์—์„œ ๋ฐ˜๋“œ์‹œ WSS๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
    • ๋ธŒ๋ผ์šฐ์ €๋Š” HTTPS ์‚ฌ์ดํŠธ์—์„œ ws:// ์—ฐ๊ฒฐ์„ ํ—ˆ์šฉํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

2๏ธโƒฃ WSS ์‚ฌ์šฉ ์‚ฌ๋ก€.

  • ์‹ค์‹œ๊ฐ„ ์ฑ„ํŒ… ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜.
    • ์˜ˆ: Slack, Discord ๊ฐ™์€ ์„œ๋น„์Šค์—์„œ ์‚ฌ์šฉ์ž ๊ฐ„ ์‹ค์‹œ๊ฐ„ ๋ฉ”์‹œ์ง€ ์ „์†ก.
  • ๋ผ์ด๋ธŒ ๋ฐ์ดํ„ฐ ์ŠคํŠธ๋ฆฌ๋ฐ.
    • ์˜ˆ: ์ฃผ์‹ ๊ฐ€๊ฒฉ ์—…๋ฐ์ดํŠธ, ์Šคํฌ์ธ  ๊ฒฝ๊ธฐ ์Šค์ฝ”์–ด.
  • ๊ฒŒ์ž„ ์„œ๋ฒ„.
    • ์˜ˆ: ์‹ค์‹œ๊ฐ„ ๋ฉ€ํ‹ฐํ”Œ๋ ˆ์ด์–ด ๊ฒŒ์ž„์—์„œ์˜ ๋น ๋ฅธ ๋ฐ์ดํ„ฐ ๊ตํ™˜.
  • IoT ๊ธฐ๊ธฐ ๊ด€๋ฆฌ.
    • IoT ์žฅ์น˜์™€ ์„œ๋ฒ„ ๊ฐ„์˜ ์•ˆ์ „ํ•œ ๋ฐ์ดํ„ฐ ์ „์†ก.

3๏ธโƒฃ WSS์™€ HTTPS์˜ ์ฐจ์ด.

ํŠน์ง• HTTPS WSS
์‚ฌ์šฉ ํ”„๋กœํ† ์ฝœ HTTP over TLS WebSocket over TLS
ํฌํŠธ ๋ฒˆํ˜ธ 443 443(๋Œ€๋ถ€๋ถ„์˜ ๊ฒฝ์šฐ)
ํ†ต์‹  ๋ฐฉ์‹ ์š”์ฒญ-์‘๋‹ต(Request-Response) ์–‘๋ฐฉํ–ฅ(Full-Duplex, Real-Time)
์‚ฌ์šฉ ๋ชฉ์  ์ผ๋ฐ˜ ์›น ๋ธŒ๋ผ์šฐ์ง• ๋ฐ API ํ†ต์‹  ์‹ค์‹œ๊ฐ„ ๋ฐ์ดํ„ฐ ๊ตํ™˜

4๏ธโƒฃ WSS๋ฅผ ์„ค์ •ํ•˜๋ ค๋ฉด?

1๏ธโƒฃ ์„œ๋ฒ„์—์„œ SSL/TLS ์ธ์ฆ์„œ ์„ค์น˜.

  • ์ธ์ฆ์„œ๋Š” Letโ€™s Encrypt, DigiCert ๋“ฑ์—์„œ ๋ฐœ๊ธ‰๋ฐ›์•„์•ผ ํ•ฉ๋‹ˆ๋‹ค.
  • ์˜ˆ: Nginx๋‚˜ Apache์— TLS๋ฅผ ์„ค์ •.

2๏ธโƒฃ WebSocket ์„œ๋ฒ„ ๊ตฌํ˜„.

  • Node.js, Java, Python ๋“ฑ์—์„œ WebSocket ์„œ๋ฒ„๋ฅผ ๊ตฌํ˜„ํ•˜๊ณ , TLS ์ธ์ฆ์„œ๋ฅผ ์ ์šฉํ•ฉ๋‹ˆ๋‹ค.

3๏ธโƒฃ ํด๋ผ์ด์–ธํŠธ์—์„œ WSS ์—ฐ๊ฒฐ ์‚ฌ์šฉ.

  • ํด๋ผ์ด์–ธํŠธ ์ฝ”๋“œ๋Š” wss://๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ WebSocket ์„œ๋ฒ„์™€ ์—ฐ๊ฒฐํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
    • ์˜ˆ(JavaScript)
        const socket = new WebSocket('wss://example.com/socket');
        socket.onopen = () => console.log('Connected');
        socket.onmessage = (event) => console.log(event.data);
      

5๏ธโƒฃ ์š”์•ฝ.

  • WSS๋Š” WebSocket์˜ ๋ณด์•ˆ ๋ฒ„์ „์œผ๋กœ, ํด๋ผ์ด์–ธํŠธ์™€ ์„œ๋ฒ„ ๊ฐ„ ๋ฐ์ดํ„ฐ๋ฅผ ์•”ํ˜ธํ™”ํ•˜์—ฌ ์•ˆ์ „ํ•˜๊ฒŒ ์ „๋‹ฌํ•ฉ๋‹ˆ๋‹ค.
  • ws://๋Š” HTTP์™€ ๊ฐ™์ด ๋ณด์•ˆ์ด ์—†๋Š” ํ™˜๊ฒฝ์—์„œ ์‚ฌ์šฉ๋˜๊ณ , wss://๋Š” HTTPS์ฒ˜๋Ÿผ TLS๋ฅผ ์ ์šฉํ•œ ํ™˜๊ฒฝ์—์„œ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.
  • HTTPS ์›น์‚ฌ์ดํŠธ๋Š” ๋ฐ˜๋“œ์‹œ wss://๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.