2-way-ssl (Mutual TLS) with HTTPoison and Hackney

Hello,

I have to do requests to some APIs with 2-way-ssl, so every request has to by signed with our cert and private key. We uploaded our certificate to 3rd party servers which provide these APIs.

We put this options into HTTPoison call:

[{:Certificate, cert_der, :not_encrypted}] =
      File.read!("/cert/cert.pem") |> :public_key.pem_decode()

    key = File.read!("/cert/key.pem") |> :public_key.pem_decode() |> hd |> Tuple.delete_at(2)

    [
      ssl: [
        versions: [:"tlsv1.2"],
        verify: :verify_peer,
        cacertfile: CAStore.file_path(),
        cert: cert_der,
        key: key,
        depth: 3,
        customize_hostname_check: [
          match_fun: :public_key.pkix_verify_hostname_match_fun(:https)
        ]
      ]
    ]

When we do request, it looks like server doesn’t know how to process it. Because their api should response error in json format and we got only this:

<html>\n<body>\n<h1>Fault</h1>env:Receiverfault:MessageBlocked</body>\n</html>\n

I tried make request with Postman (NodeJS) with same certificate and private key and it works without problem.

Any ideas where can be problem? I asked on slack and @voltone gave me some good advice but I’m a little bit lost and looks like I did something wrong.

Thanks for any help or suggeston