Spring Boot: how to secure REST API with HTTPS

Raouf Makhlouf
Quick Code
Published in
4 min readJun 3, 2020

--

Security should be a key consideration throughout the development process, including for REST APIs. HTTPS is now a standard for securing applications, so it is important to understand HTTPS before implementing it in a Spring Boot application.

1. How Does HTTPS Work?

HTTPS ensures there is a level of security involved in communication between two parties. In contrast, HTTP is insecure, and an attacker of type “man-in-the-middle” can breach the security.

HTTP vs HTTPS

With HTTPS, every packet transferred between client and server is encrypted using Asymmetric Cryptography: data is encrypted using the Public Key distributed. Only the holder of the paired Private Key can decrypt the data.
This asymmetric key encryption is much stronger and tougher to crack.

In layman's terms, HTTPS is a secured version of HTTP.

So should I encrypt/decrypt the data manually?
Obviously not. Secure Sockets Layer (SSL) and Transport Layer Security (TLS) are protocols that provide data encryption over a computer network or link. They are commonly used in web browsing and email.

--

--

Raouf Makhlouf
Quick Code

😎 Curious and passionate Web developer. Software Engineer | Blogger | Football Player | Music Fan | Traveler Stories: https://medium.com/@makhlouf.raouf