Skip to content

Commit

Permalink
Merge pull request #2 from WTTJ/feat/add-basic-ssl-options
Browse files Browse the repository at this point in the history
feat: add basic SSL options
  • Loading branch information
davidjulien authored Sep 11, 2023
2 parents c5ad31d + 3e77cd7 commit 568ce8e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

They can be used with modules relying on ssl options like `:ssl` or `:hackney`.

Current version provides a configuration based on [EEF Security WG recommandations](https://github.com/erlef/security-wg/blob/master/docs/secure_coding_and_deployment_hardening/ssl.md).
Current version provides:
- a basic configuration: `ExSslOptions.basic_options()`
- a configuration based on [EEF Security WG recommandations](https://github.com/erlef/security-wg/blob/master/docs/secure_coding_and_deployment_hardening/ssl.md): `ExSslOptions.eef_options()`

## Installation

Expand Down
14 changes: 14 additions & 0 deletions lib/ex_ssl_options.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@ defmodule ExSslOptions do
This module returns SSL options
"""

@doc """
Very simple SSL configuration
"""
def basic_options() do
[
verify: :verify_peer,
depth: 5,
cacerts: :certifi.cacerts(),
customize_hostname_check: [
{:match_fun, :public_key.pkix_verify_hostname_match_fun(:https)}
]
]
end

@doc """
SSL options according to [EEF Security WG recommandations](https://github.com/erlef/security-wg/blob/master/docs/secure_coding_and_deployment_hardening/ssl.md).
"""
Expand Down
6 changes: 6 additions & 0 deletions test/ex_ssl_options_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,10 @@ defmodule ExSslOptionsTest do
assert is_list(options)
assert Keyword.keys(options) == @allowed_keys
end

test "should return basic SSL options" do
options = ExSslOptions.basic_options()
assert is_list(options)
assert Keyword.keys(options) -- @allowed_keys == []
end
end

0 comments on commit 568ce8e

Please sign in to comment.