Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I have this code that I made so far but I don't know how to complete it . I have to: At the browser /
I have this code that I made so far but I don't know how to complete it I have to:
At the browserclient side:
Validate the selfsigned certificate
Generate a random session key for AES
Use RSA to encrypt the session key using the servers public key extracted from the certificate
Send the encrypted session key to the server
At the server side:
Use the servers private key to decrypt the ession key
Print out Now both parties have the session key
The server uses AES to encrypt a message saying Hello Browser
At the browserclient side:
The Client received the encrypted message and check that it says Hello Browser
The client uses AES to encrypt a message saying Hello Browser
At the server side:
The server decrypts the message and check that it says Hello Browser
Print out Secure communicate can start now
The code:
from OpenSSL import crypto, SSL
from socket import gethostname
from pprint import pprint
from time import gmtime, mktime
CERTFILE "selfsigned.crt
KEYFILE "private.key"
def createselfsignedcert:
# create a key pair
k crypto.PKey
kgeneratekeycryptoTYPERSA,
# create a selfsigned cert
cert crypto.X
cert.getsubjectC UK #The country of the entity
cert.getsubjectST "Buckinghshire" #State Or Province Name
cert.getsubjectL "Buckingham" #locality Name
cert.getsubjectO "The University of Buckignham" #Organization Name
cert.getsubjectOU "Computing School" #organizational Unit Name
cert.getsubjectCN "Kiundae Tuzo" # commonName.. you could use gethostname
cert.getsubjectemailAddress"hisham.alassam@buckingham.acuk
cert.setserialnumber
cert.gmtimeadjnotBefore #time before which the certificate is not valid
cert.gmtimeadjnotAfter #time after which the certificate is not validcert.setissuercertgetsubject
cert.setpubkeyk
cert.signk 'sha
openCERTFILE, wbwrite crypto.dumpcertificatecryptoFILETYPEPEM, cert
openKEYFILE, wbwritecryptodumpprivatekeycryptoFILETYPEPEM, k
createselfsignedcert
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started