SSL certificates error with websockets client connecting to localhost

Hey, I am getting an error when using the cohttp_async_websocket package. I am connecting to localhost

(monitor.ml.Error
 (Ssl_error ("error:0A000086:SSL routines::certificate verify failed")
  src/ssl.ml:201:20)
 ("Called from Core__Error.failwiths in file \"core/src/error.ml\", line 5, characters 2-50"
  "Caught by monitor ssl_pipe"))

I would do this in python to ignore SSL certificates for a particular connection. Is there anything similar?

ssl_context = ssl._create_unverified_context()

@jrfondren do you maybe know how to fix this?

With Merlin or an LSP you can have a key bound to take you to the implementation of a function. What I’d do is start there, copying Client.create into a new function that takes an Ssl.socket that can be set up appropriately.

Client.create as written doesn’t have a workaround. To put it nicely it’s a convenient and high-level interface with only the one override in hostname_for_ssl.

If you don’t want to do that, and if you only want this for testing, try testing with a VPS and a valid SSL.

I did the following:

  • I created my own certificate, i.e. ~/Downloads/unknown.pem
  • used Firefox to download it after opening my localhost page
  • run the following command:
export SSL_CERT_FILE=~/Downloads/unknown.pem
dune exec -- ./_build/default/bin/ws_client.exe

it worked