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

undefined reference error in compiling #311

Closed
quanchentg opened this issue Oct 16, 2023 · 9 comments
Closed

undefined reference error in compiling #311

quanchentg opened this issue Oct 16, 2023 · 9 comments

Comments

@quanchentg
Copy link

What's your question?

undefined reference error in compiling

Additional Context

I used centoOS 7 and openssl version is OpenSSL 1.0.2k-fips 26 Jan 2017.
get error while compiling
/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: librestpp_lib.a(auth.cpp.o): in function jwt::algorithm::rsa::verify(std::string const&, std::string const&, std::error_code&) const': *****/jwt-cpp/jwt.h:957: undefined reference to EVP_MD_CTX_destroy'
/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: *****/jwt/jwt-cpp/jwt.h:957: undefined reference to `EVP_MD_CTX_create'
collect2: error: ld returned 1 exit status

@prince-chrismc
Copy link
Collaborator

What version of jwt-cpp are you using?

@quanchentg
Copy link
Author

quanchentg commented Oct 16, 2023

0.6.0 thanks for your reply @prince-chrismc

@prince-chrismc
Copy link
Collaborator

🤔 hmm are you sure about that version of openssl is the one being pulled into your build scripts and being linked against?
I've not used devtoolset-9 but perhaps it has a never version? You could run scl enable devtoolset-9 "openssl --version" to check.


I wanted to double check the docs but I am only getting a 404 https://www.openssl.org/docs/man1.0.2/man3/EVP_MD_CTX_destroy.html

This should be the correct logic, in 1.1.0 they changed everything to free

std::unique_ptr<EVP_MD_CTX, decltype(&EVP_MD_CTX_destroy)>(EVP_MD_CTX_create(), &EVP_MD_CTX_destroy);

You can check the CI but we compile from source and test each one

@quanchentg
Copy link
Author

i used the command scl enable devtoolset-9 "openssl --version"
it returns OpenSSL 1.0.2k-fips 26 Jan 2017.

@quanchentg
Copy link
Author

more info
if i use auto verify = jwt::verify().allow_algorithm(jwt::algorithm::hs512{jwt_secret}).with_issuer("auth0"); in my project, it compiles OK.
but i add the other verify = jwt::verify().allow_algorithm(jwt::algorithm::rs256(private_key, "", "", ""))
.with_issuer("auth0"); in my project, then it returns undefined reference error by compiler.

I think it may related to rs256 algorighm?

@prince-chrismc
Copy link
Collaborator

Can you comment out the library code and print OPENSSL_VERSION_TEXT https://www.openssl.org/docs/manmaster/man3/OPENSSL_VERSION_NUMBER.html

How are you linking to OpenSSL? What build system are you using?

@prince-chrismc
Copy link
Collaborator

I think it may related to rs256 algorighm?

Yes the cryptographic keys use the evp context, the hmac is very basic (and insecure) so it doesn't use APIs that have changed

@quanchentg
Copy link
Author

seems like i use openssl 1.1.0 version for linker but i have another openssl 1.0.2 version installed on my machine.

@prince-chrismc
Copy link
Collaborator

I highly recommend using a package manager to manage 3rd party dependencies.

Unfortunately there is jot much I can , I will mark this as closed. Bestnof luck!

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

No branches or pull requests

2 participants