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

Fix ca certificate decoding #71

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions lib/ibanity/configuration.ex
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ defmodule Ibanity.Configuration do
Keyword.put_new(ssl_options, :cacertfile, :certifi.cacertfile())

cert ->
Keyword.put_new(ssl_options, :cacerts, [der_encoded_certificate(cert)])
Keyword.put_new(ssl_options, :cacerts, der_encoded_certificate(cert))
end
end

Expand All @@ -222,7 +222,7 @@ defmodule Ibanity.Configuration do
ssl_options

cert ->
Keyword.put_new(ssl_options, :cert, der_encoded_certificate(cert))
Keyword.put_new(ssl_options, :cert, der_encoded_certificate(cert) |> List.first())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not List.first. This is exactly the issue (that we take only the first one)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe :cert is not the right key? cacerts? To be verified

end
end

Expand All @@ -247,12 +247,9 @@ defmodule Ibanity.Configuration do
end

defp der_encoded_certificate(pem_certificate) do
{:Certificate, cert, :not_encrypted} =
pem_certificate
|> :public_key.pem_decode()
|> List.first()

cert
pem_certificate
|> :public_key.pem_decode()
|> Enum.map(fn {:Certificate, cert, :not_encrypted} -> cert end)
end

# See https://elixirforum.com/t/using-client-certificates-from-a-string-with-httposion/8631/7
Expand Down
Loading