Skip to content

Commit

Permalink
Fix ciphers again
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabian Zitter committed Nov 7, 2024
1 parent 3c28678 commit 0bf12a5
Showing 1 changed file with 36 additions and 10 deletions.
46 changes: 36 additions & 10 deletions lib/ibanity/configuration.ex
Original file line number Diff line number Diff line change
Expand Up @@ -165,19 +165,45 @@ defmodule Ibanity.Configuration do
end

defp extract_ssl_options(environment) do
ciphers =
:ssl.cipher_suites(:all, :"tlsv1.2")
|> :ssl.filter_cipher_suites(
key_exchange: &(&1 == :rsa),
cipher: &(&1 == :aes_128_cbc)
)
# Use [log_level: :all] to debug http calls on hackney level.
[]
|> maybe_add_ssl_ciphers()
|> add_certificate(environment)
|> add_key(environment)
end

defp maybe_add_ssl_ciphers(opts) do
case otp_version() do
version when version <= 25 ->
opts

version when version > 25 ->
add_rsa_ciphers(opts)
end
end

defp add_rsa_ciphers(opts) do
ciphers = [
%{key_exchange: :rsa, cipher: :aes_128_cbc, mac: :sha},
%{key_exchange: :rsa, cipher: :aes_128_gcm, mac: :aead, prf: :sha256}
| :ssl.cipher_suites(:all, :"tlsv1.2")
]

[
ciphers: ciphers,
verify: :verify_none
]
|> add_certificate(environment)
|> add_key(environment)
verify: :verify_none,
versions: [:"tlsv1.2"]
] ++ opts
end

defp otp_version do
{otp_version, _} =
:otp_release
|> :erlang.system_info()
|> to_string()
|> Integer.parse()

otp_version
end

defp add_ca_cert(ssl_options, environment) do
Expand Down

0 comments on commit 0bf12a5

Please sign in to comment.