Post

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


โœ… 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.