1

I am running Fedora 26 in my PC and python version is 2.7. I have already installed

openssl-devel

package. Now I am trying to install

M2Crypto==0.25.1

package inside python virtual environment using the command

pip install M2Crypto==0.25.1

. Installation always fails with following log statement.

Collecting M2Crypto==0.25.1
  Using cached M2Crypto-0.25.1.tar.gz
Requirement already satisfied: typing in ./site-packages (from M2Crypto==0.25.1)
Building wheels for collected packages: M2Crypto
  Running setup.py bdist_wheel for M2Crypto ... error
  Complete output from command /home/udara/Projects/Dev/moota/ENV/new_env/bin/python2 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-NIhR7v/M2Crypto/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmptqERYXpip-wheel- --python-tag cp27:
  running bdist_wheel
  running build
  running build_py
  copying M2Crypto/util.py -> build/lib.linux-x86_64-2.7/M2Crypto
  -----
  -----
  copying M2Crypto/PGP/PublicKey.py -> build/lib.linux-x86_64-2.7/M2Crypto/PGP
  running build_ext
  building 'M2Crypto.__m2crypto' extension
  swigging SWIG/_m2crypto.i to SWIG/_m2crypto_wrap.c
  swig -python -D__x86_64__ -I/usr/include/python2.7 -I/usr/include -I/usr/include/openssl -includeall -modern -builtin -outdir build/lib.linux-x86_64-2.7/M2Crypto -o SWIG/_m2crypto_wrap.c SWIG/_m2crypto.i
  /usr/include/sys/cdefs.h:175: Warning 305: Bad constant value (ignored).
  /usr/include/bits/wchar.h:38: Warning 490: Fragment 'SWIG_From_wchar_t' not found.
  /usr/include/stdint.h:274: Warning 490: Fragment 'SWIG_From_wchar_t' not found.
  SWIG/_bio.i:64: Warning 454: Setting a pointer/reference variable may leak memory.
  -----
  -----
  SWIG/_engine.i:168: Warning 454: Setting a pointer/reference variable may leak memory.
  creating build/temp.linux-x86_64-2.7
  creating build/temp.linux-x86_64-2.7/SWIG
  gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python2.7 -I/usr/include -I/usr/include/openssl -I/tmp/pip-build-NIhR7v/M2Crypto/SWIG -c SWIG/_m2crypto_wrap.c -o build/temp.linux-x86_64-2.7/SWIG/_m2crypto_wrap.o -DTHREADING
  SWIG/_m2crypto_wrap.c:4185:35: error: ‘CRYPTO_NUM_LOCKS’ undeclared here (not in a function); did you mean ‘CRYPTO_UNLOCK’?
   static PyThread_type_lock lock_cs[CRYPTO_NUM_LOCKS];
                                     ^~~~~~~~~~~~~~~~
                                     CRYPTO_UNLOCK
  SWIG/_m2crypto_wrap.c: In function ‘lib_init’:
  SWIG/_m2crypto_wrap.c:4590:5: warning: implicit declaration of function ‘SSLeay_add_all_algorithms’; did you mean ‘SSLeay_add_ssl_algorithms’? [-Wimplicit-function-declaration]
       SSLeay_add_all_algorithms();
       ^~~~~~~~~~~~~~~~~~~~~~~~~
       SSLeay_add_ssl_algorithms
  SWIG/_m2crypto_wrap.c: In function ‘bn_rand’:
  SWIG/_m2crypto_wrap.c:5029:12: error: storage size of ‘rnd’ isn’t known
       BIGNUM rnd;
              ^~~
  SWIG/_m2crypto_wrap.c:5033:5: warning: implicit declaration of function ‘BN_init’; did you mean ‘bio_init’? [-Wimplicit-function-declaration]
       BN_init(&rnd);
       ^~~~~~~
       bio_init
  SWIG/_m2crypto_wrap.c:5029:12: warning: unused variable ‘rnd’ [-Wunused-variable]
       BIGNUM rnd;
              ^~~
  SWIG/_m2crypto_wrap.c: In function ‘bn_rand_range’:
  SWIG/_m2crypto_wrap.c:5058:12: error: storage size of ‘rnd’ isn’t known
       BIGNUM rnd;
              ^~~
  SWIG/_m2crypto_wrap.c:5058:12: warning: unused variable ‘rnd’ [-Wunused-variable]
  SWIG/_m2crypto_wrap.c: In function ‘rand_pseudo_bytes’:
  SWIG/_m2crypto_wrap.c:5209:5: warning: ‘RAND_pseudo_bytes’ is deprecated [-Wdeprecated-declarations]
       ret = RAND_pseudo_bytes(blob, n);
       ^~~
  In file included from /usr/include/openssl/opensslconf.h:42:0,
                   from /usr/include/openssl/crypto.h:32,
                   from /usr/include/openssl/bio.h:20,
                   from /usr/include/openssl/err.h:21,
                   from SWIG/_m2crypto_wrap.c:3828:
  /usr/include/openssl/rand.h:47:1: note: declared here
   DEPRECATEDIN_1_1_0(int RAND_pseudo_bytes(unsigned char *buf, int num))
HDJEMAI
  • 9,436
  • 46
  • 67
  • 93
Udara Seneviratne
  • 2,303
  • 1
  • 33
  • 49
  • Why in the world you want to use outdated and buggy version of M2Crypto? 0.28.2 is the last release. If that doesn't work for you, please, file a bug report at https://gitlab.com/m2crypto/m2crypto/issues/new – mcepl Feb 13 '18 at 09:14

1 Answers1

2

Try using compat-openssl10-devel:

sudo dnf install compat-openssl10-devel --allowerasing

You may have to remove open-ssl if this conflicts with it. You can reinstall open-ssl after installing M2Crypto

piet.t
  • 11,718
  • 21
  • 43
  • 52
  • That shouldn't be necessary. The latest M2Crypto is compatible with OpenSSL 1.1.*. – mcepl Feb 13 '18 at 09:16
  • @mcepl I am working with a legacy system and latest M2Crypto may not be compatible with that. We need to keep the system stable with known versions – Udara Seneviratne Feb 14 '18 at 04:28
  • @UdaraSeneviratne M2Crypto is now being tested and supported on same platforms as all previous versions of M2Crypto. I do testing on everything from RHEL-6 upwards. If you have in reality something older than that, let me know, and I can test on it as well. – mcepl Feb 14 '18 at 10:02
  • @UdaraSeneviratne If you have Python older 2.6 or OpenSSL < 1.0.1e I am not sure there is any hope for you, though. I won't port to Python 2.4, but I don't think 0.25.1 will help you there anyway (and it will be the least of your problems, I am afraid). – mcepl Feb 14 '18 at 10:10
  • @UdaraSeneviratne Of course, I hope you do some testing before deploying to production, but we tried to be extremely conservative about keeping API stable, so the latest M2Crypto should feel your apps the same as 0.25.1. File bugs if it doesn't and I will jump on it immediately, I consider API-bugs the highest priority. – mcepl Feb 22 '18 at 11:12