commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Benedikt Ritter (JIRA)" <>
Subject [jira] [Commented] (CRYPTO-132) Instructions in BUILDING.txt don't work on MacOS
Date Sat, 26 Nov 2016 11:57:58 GMT


Benedikt Ritter commented on CRYPTO-132:

I've changed Makefile.common like so:

diff --git a/Makefile.common b/Makefile.common
index 0f50098..df44fe8 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -172,18 +172,18 @@ Linux-armhf_COMMONS_CRYPTO_FLAGS:=
 Mac-x86_CC        := gcc -arch i386
 Mac-x86_CXX       := g++ -arch i386
 Mac-x86_STRIP     := strip -x
-Mac-x86_CFLAGS    := -Ilib/inc_mac -I$(JAVA_HOME)/include -O2 -fPIC -mmacosx-version-min=10.4
-fvisibility=hidden -I/usr/local/include
-Mac-x86_CXXFLAGS  := -Ilib/inc_mac -I$(JAVA_HOME)/include -O2 -fPIC -mmacosx-version-min=10.4
-fvisibility=hidden -I/usr/local/include
-Mac-x86_LINKFLAGS := -dynamiclib -static-libgcc -L/usr/local/lib
+Mac-x86_CFLAGS    := -Ilib/inc_mac -I$(JAVA_HOME)/include -O2 -fPIC -mmacosx-version-min=10.4
-fvisibility=hidden -I/usr/local/opt/openssl101/include
+Mac-x86_CXXFLAGS  := -Ilib/inc_mac -I$(JAVA_HOME)/include -O2 -fPIC -mmacosx-version-min=10.4
-fvisibility=hidden -I/usr/local/opt/openssl101/include
+Mac-x86_LINKFLAGS := -dynamiclib -static-libgcc -L/usr/local/opt/openssl101/lib
 Mac-x86_LIBNAME   := libcommons-crypto.jnilib
 Mac-x86_64_CC        := gcc -arch $(OS_ARCH)
 Mac-x86_64_CXX       := g++ -arch $(OS_ARCH)
 Mac-x86_64_STRIP     := strip -x
-Mac-x86_64_CFLAGS    := -Ilib/inc_mac -I$(JAVA_HOME)/include -O2 -fPIC -mmacosx-version-min=10.5
-fvisibility=hidden -I/usr/local/include
-Mac-x86_64_CXXFLAGS  := -Ilib/inc_mac -I$(JAVA_HOME)/include -O2 -fPIC -mmacosx-version-min=10.5
-fvisibility=hidden -I/usr/local/include
-Mac-x86_64_LINKFLAGS := -dynamiclib -L/usr/local/lib
+Mac-x86_64_CFLAGS    := -Ilib/inc_mac -I$(JAVA_HOME)/include -O2 -fPIC -mmacosx-version-min=10.5
-fvisibility=hidden -I/usr/local/opt/openssl101/include
+Mac-x86_64_CXXFLAGS  := -Ilib/inc_mac -I$(JAVA_HOME)/include -O2 -fPIC -mmacosx-version-min=10.5
-fvisibility=hidden -I/usr/local/opt/openssl101/include
+Mac-x86_64_LINKFLAGS := -dynamiclib -L/usr/local/opt/openssl101/lib
 Mac-x86_64_LIBNAME   := libcommons-crypto.jnilib

With this changes, the native build works again. However the tests are now failing with errors
like this: {{java.lang.UnsatisfiedLinkError: Cannot find AES-CTR support, is your version
of Openssl new enough?}}

Running the main method of the {{org.apache.commons.crypto.Crypto}} class for diagnostics
results in the following:

Apache Commons Crypto 1.1.0-SNAPSHOT
Native code loaded OK 1.1.0-SNAPSHOT
Native Name Apache Commons Crypto
Native Built Nov 26 2016
OpenSSL library loaded OK, version: 0x9081df
OpenSSL 0.9.8zh 14 Jan 2016
Exception in thread "main" CryptoRandom: [org.apache.commons.crypto.random.OpenSslCryptoRandom]
failed with java.lang.reflect.InvocationTargetException
	at org.apache.commons.crypto.random.CryptoRandomFactory.getCryptoRandom(
	at org.apache.commons.crypto.Crypto.main(
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
	at java.lang.reflect.Method.invoke(
	at com.intellij.rt.execution.application.AppMain.main(
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
	at org.apache.commons.crypto.utils.ReflectionUtils.newInstance(
	at org.apache.commons.crypto.random.CryptoRandomFactory.getCryptoRandom(
	... 6 more
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
	at java.lang.reflect.Constructor.newInstance(
	at org.apache.commons.crypto.utils.ReflectionUtils.newInstance(
	... 7 more
Caused by: Native library could not be initialised
	at org.apache.commons.crypto.random.OpenSslCryptoRandom.<init>(
	... 12 more
Caused by: java.lang.UnsatisfiedLinkError: ENGINE_load_rdrand
	at org.apache.commons.crypto.random.OpenSslCryptoRandomNative.initSR(Native Method)
	at org.apache.commons.crypto.random.OpenSslCryptoRandom.<clinit>(
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(
	at org.apache.commons.crypto.utils.ReflectionUtils.getClassByNameOrNull(
	at org.apache.commons.crypto.utils.ReflectionUtils.getClassByName(
	at org.apache.commons.crypto.random.CryptoRandomFactory.getCryptoRandom(
	... 6 more

So the native libraries have been compiled against OpenSSL 0.9.8zh, which is shipped with
MacOS. To find out whether the build is falling back to the System OpenSSL, I removed the
{{-I}} and {{-L}} flags for OpenSSL from Makefile.common. Now the build native build is failing,
which indicates to me, that the flags are needed by the compiler (there does not seem to be
a fallback without passing those flags). I'm puzzled, since the build configuration seems
to be correct, but it pulls in OpenSSL 0.9.8 nevertheless.

> Instructions in BUILDING.txt don't work on MacOS
> ------------------------------------------------
>                 Key: CRYPTO-132
>                 URL:
>             Project: Commons Crypto
>          Issue Type: Bug
>          Components: Build
>            Reporter: Benedikt Ritter
> When using HomeBrew to link openssl with the --force, HomeBrew refuses to do this, indicating
that our docs are not following best practices:
> {code}
> ~/w/a/c/commons-crypto git:(upstream ⚡ CRYPTO-131) 1A > brew link openssl --force
> 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
> {code}
> Adapt the build so that it is no longer necessary to use link --force on MacOs

This message was sent by Atlassian JIRA

View raw message