Skip to content

Commit d812eeb

Browse files
Fabian Zitterdamienbr
authored andcommitted
Fix ciphers again
1 parent 6524753 commit d812eeb

File tree

1 file changed

+36
-10
lines changed

1 file changed

+36
-10
lines changed

lib/ibanity/configuration.ex

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -165,19 +165,45 @@ defmodule Ibanity.Configuration do
165165
end
166166

167167
defp extract_ssl_options(environment) do
168-
ciphers =
169-
:ssl.cipher_suites(:all, :"tlsv1.2")
170-
|> :ssl.filter_cipher_suites(
171-
key_exchange: &(&1 == :rsa),
172-
cipher: &(&1 == :aes_128_cbc)
173-
)
168+
# Use [log_level: :all] to debug http calls on hackney level.
169+
[]
170+
|> maybe_add_ssl_ciphers()
171+
|> add_certificate(environment)
172+
|> add_key(environment)
173+
end
174+
175+
defp maybe_add_ssl_ciphers(opts) do
176+
case otp_version() do
177+
version when version <= 25 ->
178+
opts
179+
180+
version when version > 25 ->
181+
add_rsa_ciphers(opts)
182+
end
183+
end
184+
185+
defp add_rsa_ciphers(opts) do
186+
ciphers = [
187+
%{key_exchange: :rsa, cipher: :aes_128_cbc, mac: :sha},
188+
%{key_exchange: :rsa, cipher: :aes_128_gcm, mac: :aead, prf: :sha256}
189+
| :ssl.cipher_suites(:all, :"tlsv1.2")
190+
]
174191

175192
[
176193
ciphers: ciphers,
177-
verify: :verify_none
178-
]
179-
|> add_certificate(environment)
180-
|> add_key(environment)
194+
verify: :verify_none,
195+
versions: [:"tlsv1.2"]
196+
] ++ opts
197+
end
198+
199+
defp otp_version do
200+
{otp_version, _} =
201+
:otp_release
202+
|> :erlang.system_info()
203+
|> to_string()
204+
|> Integer.parse()
205+
206+
otp_version
181207
end
182208

183209
defp add_ca_cert(ssl_options, environment) do

0 commit comments

Comments
 (0)