Im making a messaging server and client in python for uni. We have to implement SSL/TLS encryption.
So i use this code to create a context, but come up with a problem when i try to pass certificate and key files to it
def setup_SSL_context():
#uporabi samo TLS, ne SSL
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
# certifikat je obvezen
context.verify_mode = ssl.CERT_REQUIRED
#nalozi svoje certifikate
context.load_cert_chain(certfile="luka.pem", keyfile="lukakey.pem") # the line that confuses python
# nalozi certifikate CAjev (samopodp. cert.= svoja CA!)
context.load_verify_locations('server.pem')
# nastavi SSL CipherSuites (nacin kriptiranja)
context.set_ciphers('AES128-SHA')
return context
if i directly pass the files like that, its all working properly, but well, i want this client to support more than one user, so my solution was to pass filenames as formatted strings like this
username = input() # yes i did input luka...
#foo
context.load_cert_chain(certfile="[].pem".format(username), keyfile="[]key.pem".format(username))
which threw a FileNotFound Exception, but only on the lukakey.pem file...
Does anyone have any idea why it does that?