Skip to content

Commit 8b76cd9

Browse files
committed
Document the new :tls options for certificate verification
1 parent 6257b2c commit 8b76cd9

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,38 @@ is an optional hash containing any of these keys:
198198
These are passed along to EventMachine and you can find
199199
[more details here](http://rubydoc.info/gems/eventmachine/EventMachine%2FConnection%3Astart_tls)
200200

201+
### Secure sockets
202+
203+
Starting with version 0.11.0, `Faye::WebSocket::Client` will verify the server
204+
certificate for `wss` connections. This is not the default behaviour for
205+
EventMachine's TLS interface, and so our defaults for the `:tls` option are a
206+
little different.
207+
208+
First, `:verify_peer` is enabled by default. Our implementation checks that the
209+
chain of certificates sent by the server is trusted by your root certificates,
210+
and that the final certificate's hostname matches the hostname in the request
211+
URL.
212+
213+
By default, we use your system's root certificate store by invoking
214+
`OpenSSL::X509::Store#set_default_paths`. If you want to use a different set of
215+
root certificates, you can pass them via the `:root_cert_file` option, which
216+
takes a path or an array of paths to the certificates you want to use.
217+
218+
```ruby
219+
ws = Faye::WebSocket::Client.new('wss://example.com/', [], :tls => {
220+
:root_cert_file => ['path/to/certificate.pem']
221+
})
222+
```
223+
224+
If you want to switch off certificate verification altogether, then set
225+
`:verify_peer` to `false`.
226+
227+
```ruby
228+
ws = Faye::WebSocket::Client.new('wss://example.com/', [], :tls => {
229+
:verify_peer => false
230+
})
231+
```
232+
201233
## WebSocket API
202234

203235
Both the server- and client-side `WebSocket` objects support the following API:

0 commit comments

Comments
 (0)