Search code examples
pythonwsgi

Store private key for python wsgi application using ligthttpd server


I am implementing ECDH algorighm using python wsgi application using lighttpd server. What is the conventional way to store the private key from my python script?


Solution

  • If you want to store it permanently, you can store it to a file

    with open('file', 'rw') as f:
        f.write(private_key_variable)
    

    if you want to keep it as an environment variable you can do it as such

    import os
    
    # Set environment variables
    os.environ['PRIVATE_KEY'] = private_key_variable