Skip to content
Ameen Abozaid
MID-054

Secrets and cryptography

  • 6 Lessons
  • 2 h practice (estimate)
On this page 8 topics

Overview

Topics

  • Encryption in transit/at rest
  • key management concepts
  • rotation

Learn first

2 h of practice (estimate)

Learning outcomes

  1. Explain symmetric vs asymmetric encryption, hashing, and signatures, and when each is used.
  2. Configure TLS correctly, including for service-to-service and database connections.
  3. Store and rotate secrets with a secrets manager (Vault or cloud equivalent).
  4. Explain envelope encryption and key management services, and encrypt sensitive columns.

Lessons

  1. 01Cryptography for engineers
  2. 02TLS in practice
  3. 03Encryption at rest
  4. 04Key management and envelope encryption
  5. 05Secrets managers and rotation
  6. 06Demo: rotating a database password without downtime

Lab and exercises

Lab

MID-054-LAB1 · Secrets in Shop

Outcomes: 1–4 · Time: ~2 h Move every Shop secret into a secrets manager (Vault or the cloud equivalent), fetched by workload identity. Rotate the database credentials live under load. Encrypt stored customer phone numbers with envelope encryption. Enable TLS to the database with certificate verification. Add a secret scanner to CI. Acceptance: no secret in images, manifests, or Git; live rotation with no failed requests.

Exercises (assessment: quiz plus lab)

IDOutcomeTask
MID-054-EX011Choose hash, symmetric, asymmetric, or signature for: passwords, a phone column, a JWT, key exchange.
MID-054-EX022Write the JDBC URL and explain each part for a verified TLS connection to PostgreSQL.
MID-054-EX032A teammate sets trustAll=true in a dev client. Explain the risk and the correct fix.
MID-054-EX044Describe envelope encryption and how rotating the master key affects stored data.
MID-054-EX053Write the rotation steps for a database password with two valid credentials.
MID-054-EX063Find a leaked secret in a sample repository history and state the response.
Show solutions
  • EX01 Passwords: slow salted hash. Phone column: symmetric (AES-GCM) via envelope encryption. JWT: signature (asymmetric or HMAC). Key exchange: asymmetric.
  • EX02 ?sslmode=verify-full&sslrootcert=/certs/ca.pem: encrypt, verify the certificate chain and host name against the given CA.
  • EX03 Man-in-the-middle exposure; add the CA to the trust store or use the proper dev certificate.
  • EX04 Data key encrypts data, KMS key encrypts the data key; rotating the master key re-wraps data keys only, not the data.
  • EX05 Create credential B, store it, let the app reload, verify, revoke credential A, repeat later in the other direction.
  • EX06 Treat as compromised: rotate the secret first, then remove it from history and add a scanner; deleting the commit alone is not enough.

Outcome 3 is also covered by lab criterion "live rotation with no failed requests" and quiz Q07–Q09.

Quiz

Outcomes: O1 primitives · O2 TLS · O3 secrets managers and rotation · O4 envelope encryption and KMS.

A self-check for you: nothing is graded, saved or sent anywhere. Choose an answer, then check it. You can try again as often as you like.

  1. 1For storing passwords use:O1
  2. 2A digital signature proves:O1
  3. 3Which is a correct approach to algorithms?O1
  4. 4Disabling certificate validation:O2
  5. 5sslmode=verify-full makes PostgreSQL clients:O2
  6. 6Safe rotation order is:O3
  7. 7Which place is worst for a secret?O3
  8. 8Environment variables are risky for secrets because:O3
  9. 9In envelope encryption the master key:O4
  10. 10Disk encryption does NOT protect against:O4

Practical part

Quiz plus lab MID-054-LAB1. Pass: quiz at least 8/10, no secret in images, manifests, or Git, and a live database credential rotation without failed requests.

Common mistakes

Inventing crypto; disabling certificate validation; secrets in environment dumps.

Assessment

Quiz plus lab.

Career relevance

Security architecture (ARC-028).

Type to search levels, phases, modules and lessons.