commons-issues mailing list archives

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

    [ https://issues.apache.org/jira/browse/CRYPTO-132?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15697811#comment-15697811
] 

Benedikt Ritter commented on CRYPTO-132:
----------------------------------------

I've changed Makefile.common like so:

{code}
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_COMMONS_CRYPTO_FLAGS  :=
 
 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
 Mac-x86_64_COMMONS_CRYPTO_FLAGS  :=
{code}

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:

{code}
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" java.security.GeneralSecurityException: CryptoRandom: [org.apache.commons.crypto.random.OpenSslCryptoRandom]
failed with java.lang.reflect.InvocationTargetException
	at org.apache.commons.crypto.random.CryptoRandomFactory.getCryptoRandom(CryptoRandomFactory.java:217)
	at org.apache.commons.crypto.Crypto.main(Crypto.java:140)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
	at org.apache.commons.crypto.utils.ReflectionUtils.newInstance(ReflectionUtils.java:90)
	at org.apache.commons.crypto.random.CryptoRandomFactory.getCryptoRandom(CryptoRandomFactory.java:198)
	... 6 more
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
	at org.apache.commons.crypto.utils.ReflectionUtils.newInstance(ReflectionUtils.java:88)
	... 7 more
Caused by: java.security.GeneralSecurityException: Native library could not be initialised
	at org.apache.commons.crypto.random.OpenSslCryptoRandom.<init>(OpenSslCryptoRandom.java:88)
	... 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>(OpenSslCryptoRandom.java:56)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:274)
	at org.apache.commons.crypto.utils.ReflectionUtils.getClassByNameOrNull(ReflectionUtils.java:138)
	at org.apache.commons.crypto.utils.ReflectionUtils.getClassByName(ReflectionUtils.java:103)
	at org.apache.commons.crypto.random.CryptoRandomFactory.getCryptoRandom(CryptoRandomFactory.java:197)
	... 6 more
{code}

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: https://issues.apache.org/jira/browse/CRYPTO-132
>             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
(v6.3.4#6332)

Mime
View raw message