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

Issue in building dependencies #2

Open
gitrohit opened this issue Feb 18, 2020 · 14 comments
Open

Issue in building dependencies #2

gitrohit opened this issue Feb 18, 2020 · 14 comments

Comments

@gitrohit
Copy link

Hi,
I'm trying to build dependencies before compiling the BlackIceConnect Connector but OpenSSL build is failing with error.

Environment:
RHEL 7.6

Error:
make[2]: Entering directory /home/bcadmin/blackiceconnect/openssl-1.0.2n/apps' make[2]: warning: jobserver unavailable: using -j1. Add +' to parent make rule.
( :; LIBDEPS="${LIBDEPS:--L.. -lssl -L.. -lcrypto -ldl -L/home/bcadmin/blackiceconnect/zlib-1.2.11/libs/linux/zlib/release/x86/lib -lz}"; LDCMD="${LDCMD:-gcc -m32}"; LDFLAGS="${LDFLAGS:--DZLIB -DDSO_DLFCN -DHAVE_DLFCN_H -m32 -fPIC -static -Wa,--noexecstack -DL_ENDIAN -O3 -fomit-frame-pointer -Wall -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DRC4_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DVPAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM}"; LIBPATH=for x in $LIBDEPS; do echo $x; done | sed -e 's/^ *-L//;t' -e d | uniq; LIBPATH=echo $LIBPATH | sed -e 's/ /:/g'; LD_LIBRARY_PATH=$LIBPATH:$LD_LIBRARY_PATH ${LDCMD} ${LDFLAGS} -o ${APPNAME:=openssl} openssl.o verify.o asn1pars.o req.o dgst.o dh.o dhparam.o enc.o passwd.o gendh.o errstr.o ca.o pkcs7.o crl2p7.o crl.o rsa.o rsautl.o dsa.o dsaparam.o ec.o ecparam.o x509.o genrsa.o gendsa.o genpkey.o s_server.o s_client.o speed.o s_time.o apps.o s_cb.o s_socket.o app_rand.o version.o sess_id.o ciphers.o nseq.o pkcs12.o pkcs8.o pkey.o pkeyparam.o pkeyutl.o spkac.o smime.o cms.o rand.o engine.o ocsp.o prime.o ts.o srp.o ${LIBDEPS} )
/bin/ld: cannot find -ldl
/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status
make[2]: *** [link_app.] Error 1
make[2]: Leaving directory /home/bcadmin/blackiceconnect/openssl-1.0.2n/apps' make[1]: *** [openssl] Error 2 make[1]: Leaving directory /home/bcadmin/blackiceconnect/openssl-1.0.2n/apps'
make: *** [build_apps] Error 1
[bcadmin@bc-05-phx openssl-1.0.2n]$ cd apps/
[bcadmin@bc-05-phx apps]$ ll

@gbalsa
Copy link
Collaborator

gbalsa commented Feb 18, 2020

Hi @gitrohit,

What architecture are you trying to build OpenSSL for? From your log output it seems that you have selected 32bit. Is your system 64bit? In that case maybe you are missing some libraries to be able to generate 32bit binaries. Try running the following command to see if it solves the issue:

$ yum install glibc-devel.i686 libgcc.i686 libstdc++-devel.i686 ncurses-devel.i686 glibc-static.i686 gcc-c++.i686 binutils-devel.i686 glibc-devel.i686

I tested the compilation in a 64bit CentOS 7.6 Docker container after installing those packages and it worked.

I also found this stackoverflow answer that states that "static linking is explicity unsupported on Red Hat Enterprise Linux", which is your current OS. BlackICE Connect is designed to be statically linked, so you'll need to check if the before statement is true or not. In case you are not able to build BlackICE Connet statically you could try one of the available releases.

Also I found an error in the configuration of the dependency zlib for the 32 bit case and I've just corrected it. In case you've already built it, please do it again because the configure step was pointing the install directory of zlib to the 64 bit path.

Please let me know if you were able to solve the issue. Thank you.

@gitrohit
Copy link
Author

Hi,

Yes my machine is 64 bit. I got same error even after running yum install command you shared. It didn't help.

I didn't get what you meant by following statement

"...In case you are not able to build BlackICEConncet statically you could try one of the available releases."

I got error while building Linux Dependencies as per the steps mentioned
https://github.com/Gradiant/BlackICE_Connect/blob/master/Building_Linux_dependencies.md).

I have not yet started compiling BlackICEConnect package. I downloaded the BlackICEConnect package from same location which you shared. Does the package downloaded from this location not required to be build? Your statement
"..In case you are not able to build BlackICE Connet statically you could try one of the available releases."
https://github.com/Gradiant/BlackICE_Connect/releases

Thanks

@gbalsa
Copy link
Collaborator

gbalsa commented Feb 19, 2020

You only need to build it if you download the source code package, but if you don't want (or can't) build it you can download one of the precompiled versions GradiantBlackIceConnect_PKCS11_linux_x64.tar.gz or GradiantBlackIceConnect_PKCS11_linux_x86.tar.gz

@gitrohit
Copy link
Author

I downloaded GradiantBlackIceConnect_PKCS11_linux_x86.tar.gz from https://github.com/Gradiant/BlackICE_Connect/releases.

Is it tested/work on RHEL ?

@gbalsa
Copy link
Collaborator

gbalsa commented Feb 19, 2020

No, it is not tested on RHEL. The Linux version was built and tested only on Ubuntu, but it might work on other Linux distributions. I don't have a RHEL machine to test it on. If it works on your RHEL I would appreciate if you told me.

@gitrohit
Copy link
Author

Sure. Let me test

@gitrohit
Copy link
Author

As suggested by you I am able to install pre-compiled version but while running the test I get following error

[bcadmin@bc-05-phx akv_pkcs11.Test]$ ./compilation.sh -c -t
Cleaning /home/bcadmin/blackiceconnect/Test_Projects/akv_pkcs11.Test/build since --clean was specified
./compilation.sh: line 92: mcs: command not found
./compilation.sh: line 98: mono: command not found

Mono and NUnit package available screenshot uploaded along with configuration snapshot
BlackICEconnect cnf
Mono-NUnit Pkg

@gitrohit
Copy link
Author

After resolving mono issue mentioned above, not sure why it throws following error when running test script. Since I'm running it in RHEL, it shouldn't ask for .exe file.

Cannot open assembly '/root/software/nunit-3.9/tools/NUnit.ConsoleRunner/tools/nunit3-console.exe': No such file or directory.

Is the test script supposed to run on Windows?

@gbalsa
Copy link
Collaborator

gbalsa commented Feb 27, 2020

Hi,

The tests for the PKCS#11 library are written in C# and run with the framework NUnit. In order to compile them in linux mono-devel package and the nunit framework are needed.

The script compilation.sh has the following line:

console_runner="$HOME/software/nunit-3.9/tools/NUnit.ConsoleRunner/tools/nunit3-console.exe"

This binary is a .NET binary and is used to run the tests. It can be run in Linux using mono. From the error you are getting:

Cannot open assembly '/root/software/nunit-3.9/tools/NUnit.ConsoleRunner/tools/nunit3-console.exe': No such file or directory.

I suppose this is happening because you don't have the NUnit framework in that path. As stated here you can install the needed NUnit framework with the following commands:

mkdir $HOME/software # Directory where nunit will be installed, change to your own needs. In case of changing it you need to change the variable console_runner from the script compilation.sh
cd $HOME/software
wget https://github.com/nunit/nunit/archive/3.9.tar.gz
tar xzvf 3.9.tar.gz
cd nunit-3.9/
./build.sh

Also from your second screenshot I guess you have installed mono manually. If you want you can install it from the Mono RHEL repo following these instructions.

The PCKS#11 library tests are designed to be run only against the 64bit library. From your previous posts I assume you are using the 32bit version. So if you want to run the tests you can follow these steps:

Download the 64 bit version of the PKCS#11 library. Uncompress and install it:
wget https://github.com/Gradiant/BlackICE_Connect/releases/download/1.0.0/GradiantBlackIceConnect_PKCS11_linux_x64.tar.gz
tar xvf GradiantBlackIceConnect_PKCS11_linux_x64.tar.gz
cd GradiantBlackIceConnect_release_x64
./setup.sh

Follow the steps of the installation procedure. After the installation is finished run the following commands:
source ~/.bashrc # this is used to load an env variable
cp GradiantBlackICEConnect_release_x64.so libBlackICEConnect_x64.so # this is needed because the tests use that libname

Edit the following line of the file compilation.sh:
blackICE_lib_path="${base_path}/../../BIC_PKCS11/PKCS11_Connector/bin/linux-debug/x64

To point to the directory where the file libBlackICEConnect_x64.so is.

After these steps go to the directory Test_Projects\akv_pkcs11.Test\ and create the file BlackICEconnect.cnf from the template using the same values you entered in the library setup process (I suppose you already did that as you provided a screenshot of the file contents). Then run the command:

./compilation.sh -c -t

Please let me know if you are able to run the tests or if some of these steps are not clear.

@gitrohit
Copy link
Author

Hi,
I'll try downloading NUnit as per your suggestion and update in case there is any challenge.

As for mono, I did it manually and was able to resolve mono related error posted earlier.

My machine is 64 bit and I'm using 'GradiantBlackIceConnect_PKCS11_linux_x86.tar.gz'. Is that 32 bit version as mentioned by you?

@gbalsa
Copy link
Collaborator

gbalsa commented Feb 27, 2020

Yes, GradiantBlackIceConnect_PKCS11_linux_x86.tar.gz is the 32 bit version and GradiantBlackIceConnect_PKCS11_linux_x64.tar.gz is the 64 bit version.

@gitrohit
Copy link
Author

After downloading nunit and running buil script it throws error
Error:
The assembly mscorlib.dll was not found or could not be loaded.
It should have been installed in the `/usr/local/lib/mono/4.5/mscorlib.dll' directory.

Does it needs mono 4.5 only as my installed version is 4.6.2.?

@gbalsa
Copy link
Collaborator

gbalsa commented Mar 2, 2020

Could you try the mono version from here instead the manual installed one to see if it resolves the issue?

@gitrohit
Copy link
Author

Build script of NUnit gives following error. Modified build file to echo nuget.exe path. Not sure why it's throwing ' Could not restore NuGet tools' error.

Error:
[bcadmin@bc-05-phx nunit-3.12]$ ./build.sh
libc
value of NUGET EXE /home/bcadmin/blackiceconnect/nunit-3.12/tools/nuget.exe.
Could not restore NuGet tools.
[bcadmin@bc-05-phx nunit-3.12]$

As for mono installation I can't do yum install because I'm behind firewall. I did manual installation of 4.6.2.
For latest mono version(mono-6.8.0.105) you referred to, is there some other way to get all the dependencies in same package instead of yum install.

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

No branches or pull requests

2 participants