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

SSL certificates from relative symbolic links broken since OTP 25.1 #6328

Closed
laurglia opened this issue Sep 27, 2022 · 6 comments
Closed

SSL certificates from relative symbolic links broken since OTP 25.1 #6328

laurglia opened this issue Sep 27, 2022 · 6 comments
Assignees
Labels
bug Issue is reported as a bug team:PS Assigned to OTP team PS

Comments

@laurglia
Copy link

laurglia commented Sep 27, 2022

Describe the bug

Starting SSL connections fails in cases where certificates are read from files that are relative symbolic links.

To Reproduce

  1. Create directory foo: mkdir foo
  2. Enter directory foo: cd foo
  3. Generate arbitrary certificate: openssl req -x509 -newkey rsa:4096 -out cert.pem -days 365 -nodes
  4. Create relative symbolic link to the certificate: ln -s cert.pem cert2.pem
  5. Leave directory foo: cd ..
  6. Start Erlang shell and run the following code:
ssl:start().
ssl:connect('google.com', 443, [{cacertfile, "foo/cert2.pem"}, {verify, verify_none}]).
  1. Observe that you get back the following error about file not existing even though it does exist.
{error,{options,{cacertfile,"cert.pem",{error,enoent}}}}

Expected behavior

The SSL connection should establish.

Affected versions

25.1

Additional context

I think this bug started in #6287

More specifically, I believe this piece of code is the culprit:

unambiguous_path(Value) ->
    AbsName = filename:absname(Value),
    case file:read_link(AbsName) of
        {ok, PathWithNoLink} ->
            PathWithNoLink;
        _ ->
            AbsName
    end.

This code looks up the path of the file but it does not properly resolve the path of the symbolic link. For example, if the symbolic link points to cert.pem, then it always returns the path cert.pem, regardless of where the symbolic link is located.

@u3s
Copy link
Contributor

u3s commented Sep 28, 2022

Thanks for reporting. Fix is planned to be included in OTP 25.1.1 and released this week.

@pjk25
Copy link
Contributor

pjk25 commented Sep 29, 2022

This also affected 24.3.4.5, correct?

@u3s
Copy link
Contributor

u3s commented Sep 29, 2022

yes 24.3.4.5 will be corrected as well, but a little later probably.

@u3s
Copy link
Contributor

u3s commented Sep 30, 2022

OTP25.1.1 will be delayed until Monday, sorry for inconvenience.

@u3s
Copy link
Contributor

u3s commented Oct 3, 2022

OTP-25.1.1 is released
https://github.com/erlang/otp/releases/tag/OTP-25.1.1

@u3s
Copy link
Contributor

u3s commented Oct 5, 2022

OTP-24 fix is released as well.
https://github.com/erlang/otp/releases/tag/OTP-24.3.4.6

thanks for the report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is reported as a bug team:PS Assigned to OTP team PS
Projects
None yet
Development

No branches or pull requests

3 participants