[CS 인터뷰 기초] HTTP / SSL

Donghun Seol·2023년 3월 13일
0

HTTP

HTTP / 1.0

한 연결당 하나의 요청 처리

  • 요청당 3way handshake 수행하므로 연결의 오버헤드가 크다

성능개선 방법

  • 이미지를 Base64인코딩 : 이미지에 대해 따로 연결설정할 필요없이 텍스트로 받는다.
  • 코드 압축 : 개행문자 등을 제거해서 코드용량을 줄인다.
  • 이미지 스플리팅 : 많은 이미지가 합쳐있는 하나의 이미지를 다운받고 클라이언트에서 분할해서 사용한다.

HTTP / 1.1

Keep Alive

  • 한번 TCP 초기화 후에 keep-alive 옵션으로 추가적인 핸드셰이크 없이 여러개의 파일이 송수신 가능해졌다.

HOL Blocking

  • Head of Line Blocking
  • 네트워크 큐 앞에 무거운 파일이 존재할 경우, 뒤쪽 파일이 수신되지 않아 로딩이 느려지는 현상

무거운 헤더 구조

  • 헤더에는 쿠키등의 메타데이터가 많이 들어있고, 압축되지 않아 무거웠다.

HTTP / 2.0

지연시간을 줄이고 응답시간을 더 빠르게 할 수있게 개선한 프로토콜

멀티플렉싱, 헤더압축, 서버푸시, 요청의 우선순위 처리를 지원한다.

멀티플렉싱

  • 여러개의 스트림을 활용해서 송수신하는 것
  • 병렬적인 스트림을 통해 데이터를 송수신할 수 있다.
  • HOL Blocking을 해결 가능하다.

헤더압축

  • 허프만 코딩을 활용해서 헤더압축을 수행한다.

서버 푸시

  • 클라이언트의 요청없이 서버에서 리소스를 푸시 가능하다.
  • html을 요청하면 자동으로 css파일을 푸시해준다.

HTTPS

HTTP/2 는 HTTPS 위에서 동작한다.

HTTPS란 애플리케이션 계층과 전송 계층 사이에 신뢰계층인 SSL/TLS 계층을 넣은 HTTP 요청을 말한다. 보안세션, 인증매커니즘, 키 교환 암호화 알고리즘, 해싱 알고리즘이 사용된다.

보안세션

  • 세션이란 OS가 특정 사용자에게 자원 사용을 허락하는 일정한 기간을 의미한다.
  • 보안세션은 보안이 시작되고 끝나는 동안 유지되는 세션을 의미한다.

암호화 알고리즘

  • 디피헬만 방식의 키 교환 알고리즘을 사용한다.

해싱 알고리즘

  • SHA-256를 주로 활용한다.

The SSL (Secure Sockets Layer) process

  1. Client hello: The SSL handshake begins when the client sends a hello message to the server, indicating its intention to establish a secure connection. The client includes information about the SSL/TLS version it supports and a random number.
  2. Server hello: The server responds with a hello message, indicating that it supports SSL/TLS and providing information about the SSL/TLS version it will use. The server also includes a random number and a digital certificate that contains its public key.
  3. Certificate verification: The client verifies the server's digital certificate by checking that it is issued by a trusted Certificate Authority (CA) and that it has not expired or been revoked.
  4. Key exchange: The client generates a new random number, called the pre-master secret, and encrypts it with the server's public key obtained from the digital certificate. The client sends the encrypted pre-master secret to the server.
  5. Session keys: The server decrypts the pre-master secret using its private key and uses it to generate session keys, which are symmetric encryption keys used to encrypt and decrypt data during the SSL session. The server sends an encrypted message to the client, indicating that the session keys have been established.
  6. Finished: Both the client and server send a "finished" message to confirm that the SSL handshake has been completed successfully. The SSL session is now established, and data can be transmitted securely between the client and server.

The SSL handshake is a crucial component of SSL/TLS security, as it ensures that the client and server are communicating securely and that sensitive data is protected from unauthorized access.

HTTP / 3

QUIC이라는 계층에서 돌아가며 TCP가 아닌 UDP 기반으로 돌아간다. 따라서 3way handshake가 없다.

전진오류정정 매커니즘이 적용되어 수신측에서 오류를 검출하고 수정하는 방식이다. 따라서 열악한 네트워크 환경에서도 낮은 패킷 손실률을 자랑한다.

profile
I'm going from failure to failure without losing enthusiasm

0개의 댓글