OSX + Java + OpenSSL + org.apache.commons:commons-crypto = SegFault in OpenSslNative:initIDs

I had a simple Java class using Apache:commons-crypto to do encryption/decryption that was SegFaulting on me.

On OSX, I used Homebrew to install the latest OpenSSL to use.

Tracing down the issue, it occurred in the OpenSslNative:initIDs JNI linked native code somewhere. I found the c code here:

https://github.com/apache/commons-crypto/blob/master/src/main/native/org/apache/commons/crypto/cipher/OpenSslNative.c https://github.com/apache/commons-crypto/blob/master/lib/include/config.h

Scanning through the code, I found that on OSX, the "libcrypto.dylib" is referenced. That library was correctly linked into the /usr/local/opt/openssl/lib directory.

1 answer

  • answered 2022-05-06 21:35 Chris

    Confident that the libs were not found, I updated my ~/.zshrc to include

    export DYLD_LIBRARY_PATH="/usr/local/opt/openssl/lib"

    My code worked again now that the library could be found.

    If there is a better way to make this work, I would be interested in knowing it.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum