Secrets and cryptography
17 questions in 5 subtopics.
Secret management and Vault
How does a Spring Boot application read secrets fromHashiCorp Vault with Spring Cloud Vault, and why is that better than putting them in application.yml or environment variables?Design database credential handling for a Spring Boot service using Vault dynamic secrets. What happens when a lease expires, and how does the connection pool cope?Secret scanning found 1,200 credentials in your company's Git history and CI logs. How would you run the clean-up and change practices?Your security strategy aims to eliminate long-lived static secrets (database passwords, API keys, cloud keys) from applications. How would you plan this over several years?Encryption at rest and in transit
Configure a Spring Boot 3.1 or later service to serve HTTPS using a PKCS12 keystore and to call another service with mutual TLS. Which feature lets you reuse the configuration?A service stores national ID numbers and bank details in PostgreSQL. The database volume is already encrypted. What else would you do, and how would you implement field-level encryption in a Spring Data JPA application?Define the encryption-in-transit standard for 100 services in a Kubernetes environment. Would you rely on a service mesh for mTLS or on application-level TLS?Enterprise customers ask to control the encryption keys for their data in your SaaS product (customer-managed keys). How would you decide whether to offer this and what would it mean for the architecture?Java cryptography APIs
Explain the difference betweenMessageDigest, Mac, Signature and Cipher in the Java Cryptography Architecture, and when to use SecureRandom.Review this code and explain what is wrong:Cipher c = Cipher.getInstance("AES");
c.init(Cipher.ENCRYPT_MODE, key, new IvParameterSpec(FIXED_IV));
byte[] out = c.doFinal(data);
Key rotation
Why should applications rotate secrets regularly, and why does rotation often cause outages in practice?You must rotate the AES key used to encrypt customer data in a database with 500 million rows, without downtime. Describe the approach.Write a key and credential rotation policy for your organisation, covering signing keys, encryption keys, database passwords and API keys. What makes such a policy work in practice?Base64 encoding
A colleague stores API keys in the database 'encrypted with Base64'. Explain what Base64 is, why that is not encryption, and what to use instead.Encode a 32-byte random token for use in a URL and decode it back in Java. Which Base64 variant do you choose and why?A signature check fails for some requests: the client sends an HMAC as Base64 in a query parameter, and about 1 in 10 requests fail. What is the likely cause?No question matches these choices.