So I have a dynamically generated self signed certificate in python and I want to pass it to ssl.wrap_socket but it looks like that function only accepts a file name as a parameter.
I know I could write the file to disk and then read it back then delete it, I'm also running on Linux so I could write it to /run/user/1000/ so it doesn't have to touch a real drive but, this still feels wrong. Anyone got a way I can bypass the file generation step entirely?
httpd.socket = ssl.wrap_socket (httpd.socket, certfile="cert.pem", server_side=True)
Thanks!
No.
Unfortunately, it doesn't look like the SSL library supports it. You can view the source of the method you're calling here:
https://github.com/python/cpython/blob/master/Lib/ssl.py#L1131
and it appears the certfile name is being passed all the way along to the C code for handling SSL (you can follow the certfile parameter through a few function calls in the above file):
https://github.com/python/cpython/blob/master/Modules/_ssl.c#L3240
Sorry!!