uvicorn.Config
does not allow to pass string/byte objects to ssl_keyfile
or ssl_certfile
#2339
Unanswered
Torxed
asked this question in
Potential Issue
Replies: 2 comments
-
At a glance, this sounds related but isn't due to the lack of ability to create a context from in-memory: #806 |
Beta Was this translation helpful? Give feedback.
0 replies
-
Why not allow the uvicorn programmatic API to receive an ssl.SSLContext directly? Then lots of customizations like this become easier to support. I had to monkey-patch create_ssl_context to work around this currently in the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Due to the nature of how the SSL context is called:
uvicorn/uvicorn/config.py
Lines 400 to 408 in 14ffba8
And created:
uvicorn/uvicorn/config.py
Lines 111 to 113 in 14ffba8
There's no way to pass a certificate and private key object into the TLS context creation.
Albeit a some what niche, there are some use cases where certificates and more importantly private keys are loaded from vaults/stores or during startup of certain applications - where there's no possibility for writing to disk (read-only file systems etc).
It would in such cases, be desirable to either:
uvicorn.Config
ssl.SSLContex()
directly and letuvicorn
consume said context without questions. (also useful for TLS debugging)A minimal example to produce option 1 would be:
To work around the current implementation to facilitate the second option, we could attempt to use
OpenSSL.SSL.Context
which would allow us to create our own TLS context from strings using load_certificate.uvicorn
would however need to push a change touvloop
(at least on Linux, not sure what loop is used on windows) to bypass:Here's how that could look like:
Beta Was this translation helpful? Give feedback.
All reactions