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

public_key.hrl header cannot be found #12681

Closed
lpgauth opened this issue Jun 20, 2023 · 13 comments
Closed

public_key.hrl header cannot be found #12681

lpgauth opened this issue Jun 20, 2023 · 13 comments

Comments

@lpgauth
Copy link

lpgauth commented Jun 20, 2023

Elixir and Erlang/OTP versions

Erlang/OTP 26 [erts-14.0] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1] [jit]

Elixir 1.15.0 (compiled with Erlang/OTP 26)

Operating system

macOS 13.4

Current behavior

public_key/include/public_key.hrl header cannot be found.

To reproduce:

git clone https://github.com/deadtrickster/ssl_verify_fun.erl.git && cd ssl_verify_fun.erl && mix compile

Output:

Compiling 7 files (.erl)
src/ssl_verify_fingerprint.erl:15:14: can't find include lib "public_key/include/public_key.hrl"
%   15| -include_lib("public_key/include/public_key.hrl").
%     |              ^

src/ssl_verify_fingerprint.erl:27:26: record 'OTPCertificate' undefined
%   27| -spec verify_fun(Cert :: #'OTPCertificate'{},
%     |                          ^

src/ssl_verify_hostname.erl:16:14: can't find include lib "public_key/include/public_key.hrl"
%   16| -include_lib("public_key/include/public_key.hrl").
%     |              ^

src/ssl_verify_fingerprint.erl:29:39: record 'Extension' undefined
%   29|                           {extension, #'Extension'{}}, InitialUserState :: term()) ->
%     |                                       ^

src/ssl_verify_hostname.erl:28:26: record 'OTPCertificate' undefined
%   28| -spec verify_fun(Cert :: #'OTPCertificate'{},
%     |                          ^

src/ssl_verify_fingerprint.erl:44:39: record 'OTPCertificate' undefined
%   44| -spec verify_cert_fingerprint(Cert :: #'OTPCertificate'{}, Fingerprint :: fingerprint()) ->
%     |                                       ^

src/ssl_verify_hostname.erl:30:39: record 'Extension' undefined
%   30|                           {extension, #'Extension'{}}, InitialUserState :: term()) ->
%     |                                       ^

src/ssl_verify_fun_cert_helpers.erl:13:14: can't find include lib "public_key/include/public_key.hrl"
%   13| -include_lib("public_key/include/public_key.hrl").
%     |              ^

src/ssl_verify_pk.erl:14:14: can't find include lib "public_key/include/public_key.hrl"
%   14| -include_lib("public_key/include/public_key.hrl").
%     |              ^

src/ssl_verify_hostname.erl:46:36: record 'OTPCertificate' undefined
%   46| -spec verify_cert_hostname(Cert :: #'OTPCertificate'{}, Hostname :: hostname()) ->
%     |                                    ^

src/ssl_verify_fun_cert_helpers.erl:23:34: undefined macro 'id-ce-subjectAltName'
%   23|   AltSubject = select_extension(?'id-ce-subjectAltName', Extensions),
%     |                                  ^

src/ssl_verify_pk.erl:26:26: record 'OTPCertificate' undefined
%   26| -spec verify_fun(Cert :: #'OTPCertificate'{},
%     |                          ^

src/ssl_verify_hostname.erl:76:38: record 'OTPCertificate' undefined
%   76|                              Cert :: #'OTPCertificate'{},
%     |                                      ^

src/ssl_verify_fun_cert_helpers.erl:9:2: function extract_dns_names/1 undefined
%    9| -export([extract_dns_names/1,
%     |  ^

src/ssl_verify_pk.erl:28:39: record 'Extension' undefined
%   28|                           {extension, #'Extension'{}}, InitialUserState :: term()) ->
%     |                                       ^

src/ssl_verify_fun_cert_helpers.erl:19:2: spec for undefined function extract_dns_names/1
%   19| -spec extract_dns_names(Cert :: #'OTPCertificate'{}) -> [] | [string()].
%     |  ^

src/ssl_verify_pk.erl:51:30: record 'OTPCertificate' undefined
%   51| -spec verify_cert_pk(Cert :: #'OTPCertificate'{}, Pk :: pk()) ->
%     |                              ^

src/ssl_verify_fun_cert_helpers.erl:19:33: record 'OTPCertificate' undefined
%   19| -spec extract_dns_names(Cert :: #'OTPCertificate'{}) -> [] | [string()].
%     |                                 ^

src/ssl_verify_fun_cert_helpers.erl:32:26: record 'OTPCertificate' undefined
%   32| -spec extract_cn(Cert :: #'OTPCertificate'{}) -> {error, no_common_name} | {ok, string()} | {error, invalid}.
%     |                          ^

src/ssl_verify_fun_cert_helpers.erl:34:17: record 'OTPCertificate' undefined
%   34|   TBSCert = Cert#'OTPCertificate'.tbsCertificate,
%     |                 ^

src/ssl_verify_fun_cert_helpers.erl:35:32: record 'OTPTBSCertificate' undefined
%   35|   {rdnSequence, List} = TBSCert#'OTPTBSCertificate'.subject,
%     |                                ^

src/ssl_verify_fun_cert_helpers.erl:38:26: record 'OTPCertificate' undefined
%   38| -spec extract_pk(Cert :: #'OTPCertificate'{}) -> {error, no_common_name} | #'SubjectPublicKeyInfo'{}.
%     |                          ^

src/ssl_verify_fun_cert_helpers.erl:38:76: record 'SubjectPublicKeyInfo' undefined
%   38| -spec extract_pk(Cert :: #'OTPCertificate'{}) -> {error, no_common_name} | #'SubjectPublicKeyInfo'{}.
%     |                                                                            ^

src/ssl_verify_fun_cert_helpers.erl:40:17: record 'OTPCertificate' undefined
%   40|   TBSCert = Cert#'OTPCertificate'.tbsCertificate,
%     |                 ^

src/ssl_verify_fun_cert_helpers.erl:41:26: record 'OTPTBSCertificate' undefined
%   41|   PublicKeyInfo = TBSCert#'OTPTBSCertificate'.subjectPublicKeyInfo,
%     |                          ^

src/ssl_verify_fun_cert_helpers.erl:42:16: record 'OTPSubjectPublicKeyInfo' undefined
%   42|   PublicKeyInfo#'OTPSubjectPublicKeyInfo'.subjectPublicKey.
%     |                ^

src/ssl_verify_fun_cert_helpers.erl:48:24: record 'Extension' undefined
%   48| -spec extensions_list([#'Extension'{}] | asn1_NOVALUE) -> [] | [#'Extension'{}].
%     |                        ^

src/ssl_verify_fun_cert_helpers.erl:48:65: record 'Extension' undefined
%   48| -spec extensions_list([#'Extension'{}] | asn1_NOVALUE) -> [] | [#'Extension'{}].
%     |                                                                 ^

src/ssl_verify_fun_cert_helpers.erl:55:39: record 'Extension' undefined
%   55| -spec select_extension(Id :: term(), [#'Extension'{}]) -> undefined | #'Extension'{}.
%     |                                       ^

src/ssl_verify_fun_cert_helpers.erl:55:71: record 'Extension' undefined
%   55| -spec select_extension(Id :: term(), [#'Extension'{}]) -> undefined | #'Extension'{}.
%     |                                                                       ^

src/ssl_verify_fun_cert_helpers.erl:57:28: record 'Extension' undefined
%   57|   Matching = [Extension || #'Extension'{extnID = ExtId} = Extension <- Extensions, ExtId =:= Id],
%     |                            ^

src/ssl_verify_fun_cert_helpers.erl:57:84: variable 'ExtId' is unbound
%   57|   Matching = [Extension || #'Extension'{extnID = ExtId} = Extension <- Extensions, ExtId =:= Id],
%     |                                                                                    ^

src/ssl_verify_fun_cert_helpers.erl:75:15: record 'AttributeTypeAndValue' undefined
%   75| extract_cn2([[#'AttributeTypeAndValue'{type={2, 5, 4, 3},
%     |               ^

src/ssl_verify_fun_cert_helpers.erl:77:39: variable 'CN' is unbound
%   77|   ssl_verify_fun_encodings:get_string(CN);
%     |                                       ^

src/ssl_verify_fun_cert_helpers.erl:49:1: Warning: function extensions_list/1 is unused
%   49| extensions_list(E) ->
%     | ^

src/ssl_verify_fun_cert_helpers.erl:56:1: Warning: function select_extension/2 is unused
%   56| select_extension(Id, Extensions) ->
%     | ^

src/ssl_verify_fun_cert_helpers.erl:64:1: Warning: function extract_dns_names_from_alt_names/2 is unused
%   64| extract_dns_names_from_alt_names([ExtValue | Rest], Acc) ->
%     | ^

Expected behavior

Compiles as expected with Elixir 1.14.5.

Output:

Compiling 7 files (.erl)
Generated ssl_verify_fun app
@chgeuer
Copy link

chgeuer commented Jun 20, 2023

Same is true on Windows 11 x64

Erlang/OTP 26 [erts-14.0.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns]

Interactive Elixir (1.15.0) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)>
OS Name:     Microsoft Windows 11 Enterprise
OS Version:  10.0.22621 N/A Build 22621

When running

C:\ssl_verify_fun.erl>mix compile

Compiling 7 files (.erl)
src/ssl_verify_fun_cert_helpers.erl:13:14: can't find include lib "public_key/include/public_key.hrl"
%   13| -include_lib("public_key/include/public_key.hrl").
%     |              ^

src/ssl_verify_fun_cert_helpers.erl:23:34: undefined macro 'id-ce-subjectAltName'
%   23|   AltSubject = select_extension(?'id-ce-subjectAltName', Extensions),
...

The file C:\Program Files\Erlang OTP\lib\public_key-1.14\include\public_key.hrl exists. But the name of the public_key directory has a version number included.

@albertored
Copy link
Contributor

I think you should add public_key to your ’extra_applications’ section on ’mix.exs’

@chgeuer
Copy link

chgeuer commented Jun 20, 2023

@albertored Tried that, but doesn't help:

mix.exs

  def application do
    [
      mod: {LiveViewStudio.Application, []},
      extra_applications: [:logger, :runtime_tools, :os_mon, :public_key]
    ]
  end

Tracing which files/dirs are touched by mix.compile

Tracing the mix compile run under Windows using procmon64.exe shows that the following public_key-related locations are accessed by erl.exe:

  • C:\Program Files\Erlang OTP\lib\public_key-1.14.ez
  • C:\Program Files\Erlang OTP\lib\public_key-1.14\ebin
  • C:\Program Files\Erlang OTP\lib\public_key-1.14\ebin\public_key.app
  • ..myproject..\deps\ssl_verify_fun\include\public_key\include\public_key.hrl
  • ..myproject..\deps\ssl_verify_fun\public_key\include\public_key.hrl
  • ..myproject..\deps\ssl_verify_fun\src\public_key\include\public_key.hrl

However, the compilation never touches this:

  • C:\Program Files\Erlang OTP\lib\public_key-1.14\include\public_key.hrl

@SteffenDE
Copy link
Contributor

see #12653

@chgeuer
Copy link

chgeuer commented Jun 20, 2023

Thanks @SteffenDE,

adding this to my mix.exs helped:

  defp deps do
    [
      {:phoenix, "~> 1.7.2"},
      ...
      {:ssl_verify_fun, "~> 1.1.7", manager: :rebar3, override: true}
    ]
  end

I had to add the override: true, otherwise got

Unchecked dependencies for environment dev:
* ssl_verify_fun (Hex package)
  the dependency ssl_verify_fun in mix.exs is overriding a child dependency:

  > In mix.exs:
    {:ssl_verify_fun, "~> 1.1.7", [env: :prod, hex: "ssl_verify_fun", repo: "hexpm"]}

  > In deps/hackney/rebar.config:
    {:ssl_verify_fun, "~> 1.1.7", [env: :prod, hex: "ssl_verify_fun", repo: "hexpm", optional: false]}

  Ensure they match or specify one of the above in your deps and set "override: true"
** (Mix) Can't continue due to errors on dependencies

@josevalim
Copy link
Member

I will leave this open for guidance. :)

@josevalim
Copy link
Member

Note you can now upgrade ssl_verify_fun (for that one in particular).

@bit4bit
Copy link

bit4bit commented Jul 4, 2023

in my case, i fix with:

 mix deps.update hackney

@noozo
Copy link
Contributor

noozo commented Jul 14, 2023

Used this trick and even though it compiles on github actions i get a ton of these warnings:

/home/ec2-user/.mix/elixir/1-15/rebar3: /lib64/libtinfo.so.6: no version information available (required by /home/ec2-user/.mix/elixir/1-15/rebar3)

Elixir: 1.15.2-otp26
Erlang: 26.0.2

@josevalim
Copy link
Member

Closing this. A new ssl_verify_fun is out!

@icefoxen
Copy link

For future users, I had this error on Elixir 1.14.0 on Debian Bookworm stable. Updating ssl_verify_fun didn't resolve it but installing the erlang-dev apt package did.

@tzugen
Copy link

tzugen commented Mar 2, 2024

For future users, I had this error on Elixir 1.14.0 on Debian Bookworm stable. Updating ssl_verify_fun didn't resolve it but installing the erlang-dev apt package did.

@icefoxen This is now mentioned on the website, thanks for the pointer!

@bighunter513
Copy link

@albertored Tried that, but doesn't help:

mix.exs

  def application do
    [
      mod: {LiveViewStudio.Application, []},
      extra_applications: [:logger, :runtime_tools, :os_mon, :public_key]
    ]
  end

Tracing which files/dirs are touched by mix.compile

Tracing the mix compile run under Windows using procmon64.exe shows that the following public_key-related locations are accessed by erl.exe:

  • C:\Program Files\Erlang OTP\lib\public_key-1.14.ez
  • C:\Program Files\Erlang OTP\lib\public_key-1.14\ebin
  • C:\Program Files\Erlang OTP\lib\public_key-1.14\ebin\public_key.app
  • ..myproject..\deps\ssl_verify_fun\include\public_key\include\public_key.hrl
  • ..myproject..\deps\ssl_verify_fun\public_key\include\public_key.hrl
  • ..myproject..\deps\ssl_verify_fun\src\public_key\include\public_key.hrl

However, the compilation never touches this:

  • C:\Program Files\Erlang OTP\lib\public_key-1.14\include\public_key.hrl

This is very helpful, thanks so much .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

11 participants