8000 SSL peers aren't verfied · Issue #1 · dominicletz/websockex · GitHub
[go: up one dir, main page]

Skip to content

SSL peers aren't verfied #1

Closed

Description

@Azolo

The Erlang :ssl module is very strict in its certification checking.

The result of that is that, if I understand correctly, verify_peer option works when everything is basically done correctly.

What I found out is that the internet is obviously broken everywhere, the :ssl module reliably connects to just about zero of the sites I tried when verifying the peer with CA certs from erlang-certifi.

So I tried using the verify_fun option with ssl_verify_fun.erl, plus the partial_chain based off of hackney's implementation... But it didn't work.

After that I tried a bunch of other stuff and made some progress, changed some more stuff only to find that it still didn't work. So I threw my hands up and made everything insecure by default.

TLDR;

I'm not smart enough to make the :ssl module's verify_peer work correctly.

Activity

  1. changed the title [-]SSL Connections aren't secure[/-] [+]SSL peers aren't verfied[/+] on Apr 21, 2017
  2. added this to the v1.0.0 milestone on Jun 6, 2017
  3. xlphs commented on Jun 13, 2017

    @xlphs

    Not sure what you are trying to accomplish but you could simply pass ssl options on. I wrote a short article on verify_fun that shows how to do certificate pinning, hopefully it helps.

  4. Azolo commented on Jun 13, 2017

    @Azolo
    CollaboratorAuthor

    @xlphs Cool, thanks for that article. It actually shows me a different way that the ssl module could be used and I need to keep that in mind.

    What I am trying to accomplish is just being able to open a tcp socket to a site like https://google.com and verify that I am in fact connecting to https://google.com through the certificate verification. Erlang's :ssl module seems super picky about how you do that.

  5. khodzha commented on Jul 9, 2017

    @khodzha

    maybe you should take a look at elixir-socket?
    i was trying to connect to wss://eu-central434.discord.gg:80, elixir-socket could connect, yet websockex returns %WebSockex.ConnError{original: {:tls_alert, 'record overflow'}}

  6. Azolo commented on Jul 9, 2017

    @Azolo
    CollaboratorAuthor

    @khodzha Thanks for the info. I think it's possible that elixir-socket is ignoring the :80 and using port 443 because of the wss protocol. I don't think that Discord is handle SSL connections on port 80.

  7. khodzha commented on Jul 9, 2017

    @khodzha

    yeah, sorry for trouble
    discord docs were quite confusing there, connecting without port and with some query params works as expected
    👌

  8. brian-petersen commented on Nov 22, 2021

    @brian-petersen

    I spent a good part of yesterday working with Erlang's :ssl to get it to work with [verify: :verify_peer]. I too found it a bit confusing and hard to work with. I followed Hackney's :ssl setup as best I could (as documented here).

    I got it working to a point -- but I'm not leveraging https://github.com/deadtrickster/ssl_verify_fun.erl like the Hackney project is. I'm not sure what state this puts it in -- but this is the workin 8000 g code I have so far:

    def start_link() do
      ssl_options = [
        verify: :verify_peer,
        depth: 99,
        cacertfile: CAStore.file_path(),
        customize_hostname_check: [match_fun: :public_key.pkix_verify_hostname_match_fun(:https)]
      ]
    
      WebSockex.start_link("wss://example.com/ws", __MODULE__, state, ssl_options: ssl_options) do
    end
    

    The CAStore.file_path() call comes from https://github.com/elixir-mint/castore.

    As far I can tell, the only thing really missing from this setup is something like this:

    ssl_options = [
      verify: :verify_peer,
      depth: 99,
      cacertfile: CAStore.file_path(),
      customize_hostname_check: [match_fun: :public_key.pkix_verify_hostname_match_fun(:https)],
      verify_fun: {&:ssl_verify_hostname.verify_fun/3, [check_hostname: 'URL HERE']},
    ]

    (Notice that check_hostname is a charlist.) Hope this helps someone!

  9. added a commit that references this issue on Dec 30, 2024
  10. added a commit that references this issue on Nov 25, 2025
  11. added a commit that references this issue on Oct 22, 2026
    b8f8604
  12. neilberkman commented on Oct 22, 2026

    @neilberkman
    Contributor

    PR #144 verifies peers by default: verify: :verify_peer with the OS trust store from :public_key.cacerts_get/0 on OTP 25+, :castore as a fallback, hostname matching with the :https match function, and insecure: true as the explicit opt-out. cacerts: and ssl_options: keep their precedence. On older OTP with no trust store available, open_socket/1 returns a ConnError that names the options instead of raising.

    Context for the timing: OTP 26 made verify_peer the ssl client default, so the library default is now the remaining gap, and it reached downstream users this week as req_llm's GHSA-6vww-5m28-f26v (API keys and OAuth tokens over unverified TLS). The PR also regenerates the test certificates with a subjectAltName, since OTP 29 rejects CN-only certificates and three TLS tests on master already fail for that reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0