GeezerVison is showing github.com — Document explicit certificate stores for restricted CA trust (#61) · lostisland/faraday-net_http@94304c8
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: README.md +19Lines changed: 19 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -31,6 +31,25 @@ conn = Faraday.new(...) do |f| |
31 | 31 | end |
32 | 32 | ``` |
33 | 33 |
|
| 34 | +### Restricting trusted certificate authorities |
| 35 | + |
| 36 | +By default, `ca_file` and `ca_path` add certificate authorities to the system |
| 37 | +trust store. They do not restrict trust to only the supplied authorities. |
| 38 | +To restrict trust, provide an explicit certificate store. An empty store lets |
| 39 | +you trust only the authorities supplied through `ca_file` or `ca_path`: |
| 40 | + |
| 41 | +```ruby |
| 42 | +require 'openssl' |
| 43 | + |
| 44 | +conn = Faraday.new('https://example.com', ssl: { |
| 45 | + ca_file: '/path/to/trusted-ca.pem', |
| 46 | + cert_store: OpenSSL::X509::Store.new |
| 47 | +}) |
| 48 | +``` |
| 49 | + |
| 50 | +Certificate and hostname verification remain enabled. Alternatively, populate |
| 51 | +the explicit store yourself with `add_file` or `add_cert` and omit `ca_file`. |
| 52 | + |
34 | 53 | ### SOCKS proxy |
35 | 54 |
|
36 | 55 | A `socks://` proxy is supported when the optional [socksify][socksify] gem (`~> 1.8`) is installed. It is not a dependency of this gem, so add it to your Gemfile: |
|