Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TLS 1.2 ssl doesn't work for hackney (httpoison) #105

Open
joshuataylor opened this issue May 31, 2017 · 3 comments
Open

TLS 1.2 ssl doesn't work for hackney (httpoison) #105

joshuataylor opened this issue May 31, 2017 · 3 comments

Comments

@joshuataylor
Copy link

Something like:

    data = []
    options = [ssl: [{:versions, [:'tlsv1.2']}]]
    page = HTTPoison.post("https://example.com", {:form, data}, [], options)

Results in:

  1) test Can get an auth token (foo.Test.AuthTest)
     test/auth_test.exs:5
     ** (ArgumentError) cannot convert the given list to a string.
     
     To be converted to a string, a list must contain only:
     
       * strings
       * integers representing Unicode codepoints
       * or a list containing one of these three elements
     
     Please check the given list or call inspect/1 to get the list representation, got:
     
     [versions: [:"tlsv1.2"]]
     
     stacktrace:
       (elixir) lib/list.ex:709: List.to_string/1
       (exvcr) lib/exvcr/adapter/hackney/converter.ex:6: ExVCR.Adapter.Hackney.Converter.do_parse_options/2
       (exvcr) lib/exvcr/adapter/hackney/converter.ex:30: ExVCR.Adapter.Hackney.Converter.request_to_string/1
       (exvcr) lib/exvcr/adapter/hackney/converter.ex:6: ExVCR.Adapter.Hackney.Converter.convert_to_string/2
       (exvcr) lib/exvcr/handler.ex:141: ExVCR.Handler.get_response_from_server/2
       (hackney) :hackney.request(:post, "https://example.com/something", [], {:form, []}, [ssl_options: [versions: [:"tlsv1.2"]]])
       (httpoison) lib/httpoison/base.ex:432: HTTPoison.Base.request/
parroty added a commit that referenced this issue Jun 4, 2017
@parroty
Copy link
Owner

parroty commented Jun 4, 2017

Thanks for the report. The stringify of the option is not handled properly.
The above is a trial fix, and I'll be looking some more before pushing to hex. In case if you have chance to verify (wiht the following), that would be great too.

{:exvcr, github: "parroty/exvcr", branch: "fix/issue_105", only: :test}

@mpinkston
Copy link

mpinkston commented Jun 5, 2017

This looks pretty good to me!
I'm using the proxy option as well (which was also broken), but this seems to work.
The only side-effect is the way it converts charlists. eg:
{:socks5, '127.0.0.1', 8157}
becomes

"proxy": [
  "socks5",
  [
    49,
    50,
    55,
    46,
    48,
    46,
    48,
    46,
    49
  ],
  8157
]

but considering how lists work, that's probably unavoidable.

parroty added a commit that referenced this issue Jun 5, 2017
@parroty
Copy link
Owner

parroty commented Jun 5, 2017

Thanks for the confirmation and comment. There has been issues around string(binary) and charlist, but please let me take this as separate item.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants