Interview_HTTP/HTTPS/Digital Signature/TLS/SSL/DNS/JWT
๐ HTTP
HTTP, HTTPS ์ ๋ฆฌ๊ธ https://soheeparklee.github.io/posts/n-6httphttps/
โ What is HTTP?
Hypertext Transport Protocol- allow data transfer in WWW
- client-server
- HTTP request: method
- HTTP response: status code
- message: status line + header + body
- connectionless
- stateless: cookie, session
- HTTP 1.0: non-persistent
- HTTP 1.1: persistent, pipelining
- HTTP 2: multiplexing, server push
- HTTP 3: UDP
- pipelining ๐ multiplexing
โ How is the request of HTTP? And its message format?
- HTTP requst: method- GET
- POST
- HEAD
- PUT
- PATCH
- DELETE
- CONNECT
- OPTIONS
- TRACE
- message format: status line + header + body
- header: host, user-agent, accept-languge, encoding, charset
โ What is inside status line?
- HTTP version, HTTP method(request) or status code(response)โ What is the difference between GET and POST?
- GET: fetch data from server, data on HTTP packet header- POST: send client data to server, data on HTTP packet body
โ Why is data on header for GET and body for POST?
- visibility: data in header(GET) are part of URL parameters- security: header visible in URL param โก๏ธ less secure, shows
- length limitation: URL has limit
- GET on header will be cacheable
- data in POST will be secure in body
โ What is the difference between PUT and PATCH?
- PUT: change all data on server- PATCH: change part of data on server
โ How is the response of HTTP? And its message format?
- HTTP response: status code- 200: get success
- 201: post success
- 3xx: redirect
- 4xx: client error
- 400: bad request
- 401: unauthorized
- 404: cannot find resource
- 5xx: server error
- 500: internal server error
- 502: gateway error
- message format: status line + header + body
- header: data, server, last-modified, content-type
โ What is HTTP header?
- Part of HTTP request, response message with information about the message- Request: host, user-agent, keep-alive, accept language, charset, encoding that browser can accept
- Response: date, server, last modified, content-type, cache-control
โ What is HTTP keep-alive?
- HTTP is connectionless- HTTP connection: persistent, non-persistent
- HTTP/1.0: non-persistent
- From HTTP/1.1: can keep connection
- keep-alive: feature of HTTP/1.1
- header to set timeout, maximum of requests(limit pipelining)
โ What is pipelining? Benefits and disadvantages?
- From HTTP/1.1- persistent connection
- do not have to wait for response, can send several request
- however, recieve response in order (123 โก๏ธ 123)
- ๐๐ป network latency lower
- ๐๐ป head of line blocking
โ What is multiplexing?
- From HTTP/2- like pipelining, but dont have to recieve in order (123 โก๏ธ ์ค๋น๋๋ response๋ถํฐ ๋ฐ์)
โ Evolution of HTTP?
- HTTP/1.0: TCP, non-persistent- HTTP/1.1: persistent, pipelining
- HTTP/2: multiplexing, server push
- HTTP/3: UDP
โ What is HTTP/2 server push?
- server proactively sends resource even before client requests!โ What is HTTP stateless?
- HTTP server will not remember the client request- need session, cookie
๐ cookie, session, JWT
โ why do we neeed cookie, session, JWT?
- Bc HTTP is statelessโ What is a cookie, what is session?
Cookie:
- purpose: for server to distinguish client
- track user behavior
- server issue cookie, give to client
- client holds cookie, send to request to server with cookie
- ๐๐ป Malicious user can alter, forge cookie
Session:
- authenticate user
- saved on server DB, memory
- ๐๐ป Can kickout user if maicious behavior
- ๐๐ป Difficult to scale server
- ๐๐ป Burden on server(need to save user session)
โ What is token?
- stateless, server does not remember user- server issue token to cient
- client will use this token to verify himself
- issued by server with digital signature(with server's private key)
- user shows this JWT everytime requesting to server
- server verifies JWT with public key
โ What are the benefits of using token?
- ๐๐ป server burden โฌ๏ธ- ๐๐ป server scalability โฌ๏ธ
- ๐๐ป oauth
โ What is JWT?
- token used for authorization- JSON, string
- server authenticates client
- when authenticated, issue token with [header+payload] + digital signature
- client sends JWT every time it makes a request
- server verify token with public key
โ How is JWT structure?
- Header.Payload.Signature- Header: algorithm, type, key for digital signature
- Payload: JWT information(claim). client information, token created date...
- Signature: encode [Header+Payload] and sign with private key
Session ๐ Cookie ๐ JWT
๐ session, cookie, token๐ HTTPS, SSL/TLS
โ What is HTTPS?
- HTTP over SSL- send data encrypted
- use symmetric, assymetric encryption
โ How does HTTPS work?
- server asks CA to issue digital certificate- CA issues digital certificate with server's public key
- client has CA's public key
- client asks server for server's certificate and decrypts with CA's public key
- now client has server's public key
- โญ๏ธ when verified, client creates symmetric key and encrypts with server's public key
- server decrypts symmetric key with server's private key
- now server and client can communicate with symmetric key
โ What is symmetric key? Algorithm?
- same key for encryption, decryption- private key
- DES, IDEA, AES, RC Cipher Suite
โญ๏ธ What is asymmetric key? Two ways to use asymmetric keys? Algorithm?
- public key, private key- encrypt with public key, decrypt with private key: when sharing symmetric key in HTTPS
- encrypt with private key, decrypt with public key: digital signature
- Diffie Hellman, RSA, ECC
โ What is digital signature? Benefits? Algorithm?
- non-repudiation: it is me who encrypted this file!- data integrity
- DSA, RSA
๐ Symmetric, assymetric, digital signature
โ What is TLS/SSL?
- provide network transport security- operate at session layer(layer 5)
- TLS: improved SSL
- handshake, use CA, certificate, symmetric, assymetric encryption, digital signature
โ What is TLS/SSL handshake?
- client hello- server hello
- client verify, create symmetric key
- client encrypt symmetric key with server's public key
- server decrypts symmetric key with private key
- create master secret and session key
- communication encrypted with session key
๐ TLS/SSL
โ Why not only use assymetric/public key?
- public key uses a lot of computer powerโ Why not only use symetric/private key?
- client and server needs to share private key- in order to do this, need encryption, thus need public key
โ Why use SSL/TLS over HTTP?
- HTTP: application layer- SSL/TLS: sesison layer
- HTTP exchange data with plain text
- SSL, TLS encrypt data
โ Cases where digital signature is used?
- HTTPS authentication- DKIM(Domain Keys Identified Mail):
- Add digital signature to email header
- can verify sender of the email
- code signing
๐ DNS
https://soheeparklee.github.io/posts/n-6httphttps/
โ What is domain name?
- IP address in human readable formatโ What is DNS?
- Domain Name System: domain name โก๏ธ IP address- distributed database, has hierarchy
- application layer
- UDP
- port 53
โ What are the benefits of DNS being hierarchical, distributed?
- manage requests more efficiently- more scalable
โ What is the benefit of one domain name being corresponded to several IP addresses?
- can distribute the loadโ Why does DNS operate with UDP?
- prioritize speed over reliability- DNS has lots of users! lots of request
- DNS requests are small enough to fit in UDP
โ How is DNS hierarchy?
- Root DNS server- Top Level Domain server (.com)
- Authoritative Domain server (google, apple)
โ What is DNS recursor? Local DNS server?
- recursive recursor- server that responds wo DNS query
- ask another DNS server for IP address
- local DNS server
โ Types of DNS service?
- Recusive DNS resolver- Authoritative DNS server
โ Types of DNS queries? Disadvantages of recursive query?
- Non-recursive query- Recursive query: ๐๐ป DNS resolver burden โฌ๏ธ
- Iterative query
โ What is DNS record?
- information on database that linkes URL to IP address- A, AAA, CNAME, TXT
โ What is DNS cache? Benefit?
frequently visited site IP address saved on device- ๐๐ป speed up DNS request
- ๐๐ป reduce bandwidth
โ How does DNS work?
- request domain name- check local DNS cache
- contact DNS resolver
- recursive server lookup
- query root name server
- query TLD name server
- query authoritative name server
- get IP address
- client access website
๐ URI/URN/URL
โ What is difference between URI, URL, URN?
- URI โ URL, URN- URL = protocol + URI
โ What are the disadvantages of URL, and how can we overcome?
- when location of resource changes, URL will change- URN will remain fixed
๐ What happens when I type URL in web browser?
โ What happens when I type URL in web browser?
- type URL, enter - browser translate, encode URL - check if HTTPS is needed on HSTS list - check local cache for IP address - If cache does not have, get IP address of domain name from DNS - get MAC address from IP address with ARP - browser initiate TCP connection - If HTTPS needed, make SSL/TLS handshake - send HTTP request to server - server sends response - browser rendering, show response to user: DOM tree๐ VPN/ SSL/TLS encryption
โ VPN and SSL/TLS both serves encryption. How are they different?
- VPN: enables encryption between computer and private network (remote access to company network from home) - use various types of tunneling protocols - SSL/TLS: encryption between applications - use symmetric, assymetric encryption in SSL handshake๐ Session
โ What is session in OSI 7 Layer? and what is session to remeber the user?
- although name session is same, they serve different functions - session in OSI 7 Layer: controls connection between two computers - web application session: as HTTP is statelss, use session to remember the user๐ TLS
โ On what OSI7 layer does TLS function, and why?
- Although TLS has name transport layer, - TLS is used on OSI session layer(layer 5) - as it's job is to encrypt session between client and server - OSI transport layer(layer 4): reliable transport of data between client and server(TCP, UDP)โ 23/Aug Feedback
์ํฌ๋ 9:44 ~ 9:59 - ๋ณด์ ์ง๋ฌธ * ๋์นญํค ๋น๋์นญํค -> ๋ต๋ณ์ ์กฐ๊ธ ์ ๋ฆฌํ๋ฉด ์ข์ ๊ฒ ๊ฐ์ต๋๋ค! * ๊ฐ๋ฐ์๋ก์์ ๋จ์ - ์ข์ ์ * ํค ์ค ๋งค๋ 100์ * ๊ธด์ฅํ์ง ์๊ณ ํธ์ํ๊ฒ ๋งํ๋ ์ ์ ๋ณธ ๋ฐ๊ณ ์ถ์ต๋๋ค. * ์ง๋ฌธ์ ๋ํ ๋ต๋ณ๋ง ์ค๋นํ ๊ฒ์ด ์๋๋ผ ์ฒด๋ดํํ ์ง์์ ๊ธฐ๋ฐ์ผ๋ก ๋ต๋ณํ๋ ๊ฒ ๊ฐ์ ๋งค์ฐ ๋๋ํด๋ณด์ ๋๋ค. * ๊ฐ๋ฐ์๊ฐ ๋๋ ค๋ ์ด์ ๋ต๋ณ ๊ตฌ์ฑ์ด ์ข์์ต๋๋ค. * (์ฌ๊ณ ๋ฅผ ํ ์ ์๋ ์ธ์ฌ๋ผ๋ ๋๋์ ๋ฐ์์ ์ฑ์ฉํ๊ณ ์ถ์์ต๋๋ค) - ์ชผ๊ธ ๋ณด์ํ๋ฉด ์ข์ ์ * ์กฐ๊ธ๋ง ์ฒ์ฒํ ๋ง์ํ์ ๋ ์ข์ ๊ฒ ๊ฐ์ต๋๋ค! * ๊ด๋ จ ๊ฐ๋ ์ ๋ํด์ ์์ธํ๊ฒ ์ค๋ช ํด์ฃผ์ ์ ์ ๊ฐ์๋ฅผ ๋ฃ๋ ๊ฒ์ฒ๋ผ ์ ๋ง ์ข์์ง๋ง ๋ฉด์ ์ด๋ผ๋ ์ํฉ์ ๊ณ ๋ คํ๋ฉด ๋ต๋ณ์ ์กฐ๊ธ ์ค์ฌ๋ ๊ด์ฐฎ์ ๊ฒ ๊ฐ์ต๋๋ค! This post is licensed under CC BY 4.0 by the author.