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
Uh oh!
There was an error while loading. Please reload this page.
-
Due to the nature of how the SSL context is called: https://github.com/encode/uvicorn/blob/14ffba8316eb606cd026d1a3b01d9d90e47e868c/uvicorn/config.py#L400-L408
And created: https://github.com/encode/uvicorn/blob/14ffba8316eb606cd026d1a3b01d9d90e47e868c/uvicorn/config.py#L111-L113
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.Configssl.SSLContex()directly and letuvicornconsume 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.Contextwhich would allow us to create our own TLS context from strings using load_certificate.uvicornwould 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