mirror of
https://github.com/ollama/ollama-python.git
synced 2026-07-21 09:05:23 -04:00
Unable to connect to proxied model from python api with self-signed SSL certificate #288
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @s-andrews on GitHub (Aug 8, 2025).
I'm running an ollama model on a linux system which I'm proxying through an apache server to a subdirectory, so the model will is running on
http://localhost:12345..is proxied to
https://webserver/ABCDEF/This all works, and I can see the correct responses in the web server api, eg
https://webserver/ABCDEF/api/tagsreturns a valid json document.I can connect to the command line client OK and get the results from that.
I can also use the same URL to connect to page assist and that works.
When I try the same thing in the python API I can't get it to work though.
...fails with...
The same script works on the linux host machine if I point to the http://localhost:12345 address, so it's something about the use of the proxy which is causing the failure.
Any suggestions for how to fix or debug this some more would be appreciated. Thanks!
@s-andrews commented on GitHub (Aug 28, 2025):
I figured this out. It turns out it wasn't the proxy which was the issue, it was our site's security system which generates fake SSL certificates to screen https content and then installs a new root certificate so that everything works. The httpx client in ollama doesn't use the site certificate store, so the SSL doesn't verify.
If I add a breakpoint into
_client.pyI can grab the actual connect error where I see:ConnectError('[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1028)')The fix for this is in the httpx documentation where it shows how you can force the use of the system certificate store rather than the bundled one.
In my case the fixed code is below, and this works as expected.