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

Will not compile on El Capitan #10

Open
steveswinsburg opened this issue Nov 5, 2016 · 11 comments
Open

Will not compile on El Capitan #10

steveswinsburg opened this issue Nov 5, 2016 · 11 comments

Comments

@steveswinsburg
Copy link

$ gcc keychaindump.c -o keychaindump -lcrypto
keychaindump.c:12:10: fatal error: 'openssl/des.h' file not found
#include <openssl/des.h>
^
1 error generated.

@SailReal
Copy link

Same problem running on macOS Sierra.

@henno
Copy link

henno commented Nov 30, 2016

Same here

@henno
Copy link

henno commented Nov 30, 2016

This worked:

brew install openssl
gcc keychaindump.c -o keychaindump -lcrypto -I /usr/local/opt/openssl/include

@m0yellow
Copy link

the same works with macports:
gcc keychaindump.c -o keychaindump -lcrypto -I /opt/local/include

@F1LT3R
Copy link

F1LT3R commented Jul 7, 2017

Not building here using any of the above methods.

For example: working from @henno's comment: gcc keychaindump.c -o keychaindump -lcrypto -I /usr/local/opt/openssl/include I get:

keychaindump.c:449:9: warning: implicit declaration of function 'geteuid' is invalid in C99 [-Wimplicit-function-declaration]
    if (geteuid()) {
        ^
keychaindump.c:490:21: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
        if (key_len = dump_wrapping_key(key, g_master_candidates[i], buffer, sz)) {
            ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
keychaindump.c:490:21: note: place parentheses around the assignment to silence this warning
        if (key_len = dump_wrapping_key(key, g_master_candidates[i], buffer, sz)) {
                    ^
            (                                                                   )
keychaindump.c:490:21: note: use '==' to turn this assignment into an equality comparison
        if (key_len = dump_wrapping_key(key, g_master_candidates[i], buffer, sz)) {
                    ^
                    ==
2 warnings generated.
ld: library not found for -lcrypto

@barrett092
Copy link

I get the above error too, any ideas?

@danpolanco
Copy link

Assuming you have used home-brew to install openssl, if you run brew link openssl it gives you the correct method for fixing this.

➜  Downloads brew link openssl
Warning: Refusing to link: openssl
Linking keg-only openssl means you may end up linking against the insecure,
deprecated system OpenSSL while using the headers from Homebrew's openssl.
Instead, pass the full include/library paths to your compiler e.g.:
  -I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib

So the correct command (for now) is gcc keychaindump.c -o keychaindump -lcrypto -I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib.

Related: Homebrew/brew#612

@ghost
Copy link

ghost commented Mar 6, 2019

Not building here using any of the above methods.

For example: working from @henno's comment: gcc keychaindump.c -o keychaindump -lcrypto -I /usr/local/opt/openssl/include I get:

keychaindump.c:449:9: warning: implicit declaration of function 'geteuid' is invalid in C99 [-Wimplicit-function-declaration]
    if (geteuid()) {
        ^
keychaindump.c:490:21: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
        if (key_len = dump_wrapping_key(key, g_master_candidates[i], buffer, sz)) {
            ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
keychaindump.c:490:21: note: place parentheses around the assignment to silence this warning
        if (key_len = dump_wrapping_key(key, g_master_candidates[i], buffer, sz)) {
                    ^
            (                                                                   )
keychaindump.c:490:21: note: use '==' to turn this assignment into an equality comparison
        if (key_len = dump_wrapping_key(key, g_master_candidates[i], buffer, sz)) {
                    ^
                    ==
2 warnings generated.
ld: library not found for -lcrypto

Had the same issue, but after executing brew reinstall SSL, brew gave me the following path for openssl : /usr/local/Cellar/openssl/

So using the right path would give : gcc keychaindump.c -o keychaindump -lcrypto -I /usr/local/Cellar/openssl/1.0.2q/include -L /usr/local/Cellar/openssl/1.0.2q/lib

1.0.2q may be another version depending on your system.

Worked with 2 warnings; Hope this will help

@thehappydinoa
Copy link

@mrRobotSAS I went ahead and fixed those warnings in #11

@JonathanAnderson
Copy link

I needed to apply the following diff to get it to compile for me with home-brew's openssl.

diff --git a/keychaindump.c b/keychaindump.c
index f00bf4c..970598e 100644
--- a/keychaindump.c
+++ b/keychaindump.c
@@ -1,5 +1,6 @@
 // Build instructions:
 // $ gcc keychaindump.c -o keychaindump -lcrypto
+// $ gcc keychaindump.c -o keychaindump -lcrypto -I /usr/local/opt/openssl/include -L /usr/local/opt/openssl/lib

 // Usage:
 // $ sudo ./keychaindump [path to keychain file, leave blank for default]
@@ -12,6 +13,8 @@
 #include <openssl/des.h>
 #include <sys/sysctl.h>

+#define C_Block DES_cblock
+
 // This structure's fields are pieced together from several sources,
 // using the label as an identifier. See find_or_create_credentials.
 typedef struct t_credentials {

@Castle-Oak
Copy link

Castle-Oak commented Dec 25, 2020

@JonathanAnderson 's solution worked on Big Sur
gcc-10 keychaindump.c -o keychaindump -lcrypto -I/usr/local/Cellar/[email protected]/1.1.1i/include -L/usr/local/Cellar/[email protected]/1.1.1i/lib

However, no bueno. Looks like Apple finally fixed the issue that allowed this tool to work.

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

No branches or pull requests

10 participants