How can I make an SSL-enabled HTTP request in Julia?

Viewed 336

I need to make a request to an internal web service, and need to provide a custom SSL certificate chain.

In python + requests, I would set the REQUESTS_CA_BUNDLE environment variable to the path of the bundle, /etc/ssl/certs/ca-bundle.crt. What is the equivalent with Julia's HTTP.jl? It doesn't seem to be picking up the bundle automatically.

2 Answers

HTTP.jl uses MbedTLS to process certificates, so I wonder if your Julia install somehow is missing that library. You might try installing MbedTLS directly for you platform and see where it looks for certificates by default.

According to the docs you can pass an sslconfig object to the call. You can supply the certificate to this object:

Untested

using HTTP, MbedTLS

conf = MbedTLS.SSLConfig(cert_file, key_file)
resp = HTTP.get("https://httpbin.org/ip", sslconfig=conf)

println(resp)
Related