Skip to content

Commit ab5c938

Browse files
authored
Merge pull request #214 from JuliaComputing/la/add-client-cert-info
add info to README on how to configure Mutual TLS
2 parents 7bfecc8 + 4309bac commit ab5c938

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,36 @@ garbage collected, whichever comes first. If the grace period is set to zero,
194194
all resources will be cleaned up immediately as soon as there are no more
195195
ongoing downloads in progress. If the grace period is set to `Inf` then
196196
resources are not cleaned up until `Downloader` is garbage collected.
197+
198+
199+
## Mutual TLS using Downloads
200+
201+
```jl
202+
using Downloads: Curl, Downloader, download
203+
204+
easy_hook = (easy, info) -> begin
205+
Curl.setopt(easy, Curl.CURLOPT_SSLKEY, "client.key")
206+
Curl.setopt(easy, Curl.CURLOPT_SSLCERT, "client.crt")
207+
end
208+
downloader = Downloader()
209+
downloader.easy_hook = easy_hook
210+
211+
download(url; downloader)
212+
```
213+
214+
Here, client.key and client.crt are the private and public keys for the client.
215+
216+
It’s also possible currently to make the default downloader use that hook by putting it into Downloads.EASY_HOOK. Here’s an example:
217+
218+
```jl
219+
using Downloads: Downloads, Curl, download
220+
221+
Downloads.EASY_HOOK[] = (easy, info) -> begin
222+
Curl.setopt(easy, Curl.CURLOPT_SSLKEY, "client.key")
223+
Curl.setopt(easy, Curl.CURLOPT_SSLCERT, "client.crt")
224+
end
225+
226+
download(url)
227+
```
228+
229+
There is no difference between usage on Windows, MacOS, and Linux.

0 commit comments

Comments
 (0)