fix(http): keep admin CAs, secure HTTPS proxies, make insecure explicit
- An admin-set cacerts no longer gets the CAStore cacertfile added; Hackney drops cacerts when both are set. - Set proxy_ssl_options too: with an HTTPS proxy, Hackney 4 uses them for the proxy connection and falls back to certifi. - Hackney 4 ignores the top-level insecure option and uses certifi. Turn it into an explicit verify_none.
This commit is contained in:
parent
accadd99f3
commit
302039e437
3 changed files with 42 additions and 16 deletions
|
|
@ -23,6 +23,13 @@ defmodule Pleroma.HTTP.TLSTest do
|
|||
assert partial_chain.([:certificate]) == :unknown_ca
|
||||
end
|
||||
|
||||
test "keeps CA certificates that the admin set" do
|
||||
opts = TLS.ssl_options(cacerts: [:private_ca])
|
||||
|
||||
assert opts[:cacerts] == [:private_ca]
|
||||
refute Keyword.has_key?(opts, :cacertfile)
|
||||
end
|
||||
|
||||
test "keeps the CA bundle when other options are given" do
|
||||
opts = TLS.ssl_options(versions: [:"tlsv1.2"])
|
||||
|
||||
|
|
@ -38,6 +45,7 @@ defmodule Pleroma.HTTP.TLSTest do
|
|||
|
||||
assert opts[:pool] == :media
|
||||
assert opts[:ssl_options] == TLS.ssl_options()
|
||||
assert opts[:proxy_ssl_options] == TLS.ssl_options()
|
||||
end
|
||||
|
||||
test "merges given ssl_options into the TLS options" do
|
||||
|
|
@ -46,8 +54,17 @@ defmodule Pleroma.HTTP.TLSTest do
|
|||
assert opts[:ssl_options] == TLS.ssl_options(versions: [:"tlsv1.2"])
|
||||
end
|
||||
|
||||
test "leaves insecure requests alone" do
|
||||
assert TLS.put_hackney_ssl_options(insecure: true) == [insecure: true]
|
||||
test "turns insecure into an explicit verify_none" do
|
||||
opts = TLS.put_hackney_ssl_options(insecure: true)
|
||||
|
||||
assert opts[:ssl_options] == [verify: :verify_none]
|
||||
refute Keyword.has_key?(opts, :proxy_ssl_options)
|
||||
end
|
||||
|
||||
test "secures the connection to an HTTPS proxy" do
|
||||
opts = TLS.put_hackney_ssl_options(proxy_ssl_options: [versions: [:"tlsv1.3"]])
|
||||
|
||||
assert opts[:proxy_ssl_options] == TLS.ssl_options(versions: [:"tlsv1.3"])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue