I have a flask application(client) from where I need to send some data to a server(another flask application as of now) and get some corresponding data. I need to use REST because the server can be anything later(the current flask app is a dummy server for testing). I need to have SSL connection between client and server. I see that SSL works in several steps:
- Client requests for an encrypted connection.
- Server responds with an SSL Certificate which will have a public key.
- Client verifies the SSL Certificate
- Client creates a private key
- Client encrypts the private key with the public key and sends it to the server.
- Server decrypts it and gets the private key.
- Thus an encrypted connection is established between client and server. Further exchange of data between client and server happens by encrypting the data with the private key.
This is what I am trying to achieve. Please correct me if I got the SSL concept wrong.
I have seen below implementation and works perfectly for me.
Client side uses requests.get()
with verify=<path to server SSL certificate>
. I have generated SSL certificate for server using openssl
as follows.
openssl req -x509 -newkey rsa:4096 -nodes -out cert.pem -keyout key.pem -days 365
But I don't think all the above 7 steps are being covered here. What is the actual way of implementing SSL? Any help would be appreciated.