import requests import rsa import urllib3 # Open public key of the server with open("ssl/server_public.pem","r") as f_public: pubi_k = rsa.PublicKey.load_pkcs1(f_public.read()) message = "Hello World !".encode() # Encrypt the message with the public key of the server encrypt_message= rsa.encrypt(message,pubi_k) # Delete error in the terminal urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) # Send the request response = requests.post('https://localhost:5000/data',data=encrypt_message, verify="ssl/CA.crt") print(response.json()) ''' Generation clef (public_key, private_key) = rsa.newkeys(4096) with open("ssl/public.pem", "wb") as pub_file: pub_file.write(public_key.save_pkcs1("PEM")) with open("ssl/private.pem", "wb") as priv_file: priv_file.write(private_key.save_pkcs1("PEM")) '''