If we want the communication between the browser and the server to be encrypted we need to handle HTTPS request. HTTPS is often used to protect highly confidential online transactions like online banking and online shopping order forms.

Akka-HTTP supports TLS (Transport Layer Security).

For handling the HTTPS request, we need to have the SSL certificate and the KeyStore. Once you have generated both, you can go through the example.

In this example, you will see how easily you can handle HTTPS requests. Akka HTTP provides support for low-level and high-level HTTP server APIs. I’ve used a high-level API in this example.

We need KeyManagerFactory and TrustManagerFactory to initialize SSLContext.

TrustManager determines whether a remote connection should be trusted or not (whether a remote party is who it claims to be) and KeyManager decides which authentication credentials should be sent to the remote host for authentication during the SSL handshake.

You can download Postman or any other REST client for making the request on your server.