sergot / openssl

OpenSSL bindings for Perl 6
MIT License
14 stars 31 forks source link

Cannot locate native library 'libssl.so' #59

Open shalomb opened 6 years ago

shalomb commented 6 years ago

I'm not sure if this is a problem with NativeCall or OpenSSL but I get the following error when trying out the examples in the README.

Cannot locate native library 'libssl.so': libssl.so: cannot open shared object file: No such file or directory         

But as far as I can see, I do have libssl.so provided by libssl-dev on debian. What would cause this then?

(ins)13862360000735 gitlab-api - $ cat openssl-test.p6                                                                                                                                                                                                                          
#!/usr/bin/env perl6                                                                                                                                                                                                                                                            

use OpenSSL;                                                                                                                                                                                                                                                                    

my $ssl = OpenSSL.new(:version(3), :client);                                                                                                                                                                                                                                    
my $host = 'google.com';                                                                                                                                                                                                                                                        
my $s = IO::Socket::INET.new(:host, :port(443));                                                                                                                                                                                                                                
$ssl.set-socket($s);                                                                                                                                                                                                                                                            
$ssl.set-connect-state;                                                                                                                                                                                                                                                         
$ssl.connect         

(ins)13892390000748 gitlab-api - $ perl6 -e 'use OpenSSL'                                                                                                                                                                                                                       
(ins)13902400000801 gitlab-api - $ perl6 openssl-test.p6                                                                                                                                                                                                                        
Cannot locate native library 'libssl.so': libssl.so: cannot open shared object file: No such file or directory                                                                                                                                                                  
  in method setup at /usr/share/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03 (NativeCall) line 289                                                                                                                                                                    
  in method CALL-ME at /usr/share/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03 (NativeCall) line 576                                                                                                                                                                  
  in method new at /home/unop/.perl6/sources/B2CD7D22415C565B8F3970B6E14983C0C9854FF9 (OpenSSL) line 36                                                                                                                                                                         
  in block <unit> at openssl-test.p6 line 5                                                                                                                                                                                                                                      

Environment info.

(ins)1388238127000742 gitlab-api - $ perl6 -v                                                                                                                                                                                                                                   
This is Rakudo version 2018.01 built on MoarVM version 2018.01                                                                                                                                                                                                                  
implementing Perl 6.c.              

# zef list --installed | grep -i ssl                                                                                                                                                                                                      
===> Found via /usr/share/perl6/site                                                                                                                                                                                                                                            
===> Found via /usr/share/perl6                                                                                                                                                                                                                                                 
IO::Socket::Async::SSL:ver<0.6.1>                                                                                                                                                                                                                                               
IO::Socket::SSL:ver<0.0.1>:auth<github:sergot>                                                                                                                                                                                                                                  
OpenSSL:ver<0.1.18>:auth<github:sergot>  

(ins)13912411000812 gitlab-api - $ dpkg -l | grep -i libssl                                                                                                                                                                                                                     
ii  libssl-dev:amd64                                               1.1.0f-3+deb9u2                      amd64                                Secure Sockets Layer toolkit - development files                                                                                   
ii  libssl1.0.0:amd64                                              1.0.1t-1+deb8u6                      amd64                                Secure Sockets Layer toolkit - shared libraries                                                                                    
ii  libssl1.0.2:amd64                                              1.0.2n-1                             amd64                                Secure Sockets Layer toolkit - shared libraries                                                                                    
ii  libssl1.1:amd64                                                1.1.0f-3+deb9u2                      amd64                                Secure Sockets Layer toolkit - shared libraries     

(ins)13922420000825 gitlab-api - $ find /usr/ -iname "libssl.so"                                                                                                                                                                                                                
/usr/lib/x86_64-linux-gnu/libssl.so       

(ins)13932430000853 gitlab-api - $ find /usr/ -iname "libssl.so" -ls                                                                                                                                                                                                            
 34621883      0 lrwxrwxrwx   1 root     root           13 Mar 29 12:51 /usr/lib/x86_64-linux-gnu/libssl.so -> libssl.so.1.1  

(ins)13982480001753 gitlab-api - $ cat /etc/ld.so.conf.d/                                                                                                                                                                                                                       
fakeroot-x86_64-linux-gnu.conf  libc.conf                       x86_64-linux-gnu.conf 

(ins)13982480001753 gitlab-api - $ cat /etc/ld.so.conf.d/x86_64-linux-gnu.conf                                                                                                                                                                                                  
# Multiarch support                                                                                                                                                                                                                                                             
/usr/local/lib/x86_64-linux-gnu                                                                                                                                                                                                                                                 
/lib/x86_64-linux-gnu                                                                                                                                                                                                                                                           
/usr/lib/x86_64-linux-gnu  
shalomb commented 6 years ago

Hmm, On upgrading to rakudo 2018.03 the error changes

unop@d0f805d56931:~/projects/gitlab-api$ cat openssl-test.p6                                                                                                                                                                                                                    
#!/usr/bin/env perl6                                                                                                                                                                                                                                                            

use OpenSSL;                                                                                                                                                                                                                                                                    

my $ssl = OpenSSL.new(:version(3), :client);                                                                                                                                                                                                                                    
my $host = 'google.com';                                                                                                                                                                                                                                                        
my $s = IO::Socket::INET.new(:host, :port(443));                                                                                                                                                                                                                                
$ssl.set-socket($s);                                                                                                                                                                                                                                                            
$ssl.set-connect-state;                                                                                                                                                                                                                                                         
$ssl.connect                                                                                                                                                                                                                                                                    

unop@d0f805d56931:~/projects/gitlab-api$ perl6 openssl-test.p6                                                                                                                                                                                                                   
Cannot locate symbol 'SSLv3_client_method' in native library 'libssl.so'                                                                                                                                                                                                        
  in method setup at /usr/share/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03 (NativeCall) line 290                                                                                                                                                                    
  in method CALL-ME at /usr/share/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03 (NativeCall) line 577                                                                                                                                                                  
  in method new at /usr/share/perl6/site/sources/B2CD7D22415C565B8F3970B6E14983C0C9854FF9 (OpenSSL) line 53                                                                                                                                                                     
  in block <unit> at openssl-test.p6 line 5    
samcv commented 6 years ago

@shalomb Can you try installing libssl1.0-dev and see if it fixes your issue? That resolved it for me.

awgrover commented 4 years ago

Same error. Should raku be more tolerant of versions of the library?

Installing: OpenSSL:ver<0.1.23>:auth Cannot locate native library 'libssl.so': libssl.so: cannot open shared object file: No such file or directory

Ubuntu 18.04

packages installed: libssl1.0.0, libssl1.1

ldconfig -p | grep libssl.so

libssl.so.1.0.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libssl.so.1.0.0

I note the difference in file name ".so" vs ".so.1.0.0".

This work around fixes it: ln -s /lib/x86_64-linux-gnu/libssl.so.1.0.0 /lib/x86_64-linux-gnu/libssl.so

niner commented 4 years ago

No, raku shouldn't be more tolerant. Native library's versions are just not optional but have to be specified like I did in https://github.com/niner/openssl/commit/407ceace86510676e0a4c664eb623493bd404bd8

Skarsnik commented 2 years ago

This is still an (annoying) issue. Having to install the -dev package of openssl is really bad x)

sergot commented 2 years ago

Hi @Skarsnik , as far as I remember I always had to install the libssl-dev for ssl related packages, for example in Python: https://www.pyopenssl.org/en/stable/install.html#supported-openssl-versions .

I am not sure how we can approach this issue to make it more user friendly, I'm open for ideas, thanks in advance!

❤️

niner commented 2 years ago

@sergot the solution is simple and already implemented in: https://github.com/sergot/openssl/pull/76

That PR is the correct solution and fixes this issue. It's just a bit outdated, but all the required pieces (e.g. in zef) are now in place.

melezhik commented 1 year ago

I have the same issue after building raku-OpenSSL for alpine:

/ # cat openssl-test.raku 
use OpenSSL;

my $host = "ci.sparrowhub.io";

my $ssl = OpenSSL.new(:version(3), :client);
my $s = IO::Socket::INET.new(:$host, :port(443));
$ssl.set-socket($s);
$ssl.set-connect-state;
$ssl.connect
# $ssl.write, etc
/ # raku openssl-test.raku 
Cannot locate symbol 'SSLv3_client_method' in native library 'libssl.so'
  in method setup at /usr/share/rakudo/core/sources/947BDAB9F96E0E5FCCB383124F923A6BF6F8D76B (NativeCall) line 319
  in method setup at /usr/share/rakudo/core/sources/947BDAB9F96E0E5FCCB383124F923A6BF6F8D76B (NativeCall) line 366
  in sub raku-nativecall at /usr/share/rakudo/core/sources/07D7A4E6581D1C9421412E7D2A0586F9FED3D9B5 (NativeCall::Dispatcher) line 46
  in method new at /usr/share/rakudo/vendor/sources/F83A1D278296155E6CD343A7149423E8E138F165 (OpenSSL) line 53
  in block <unit> at openssl-test.raku line 5

/ # apk info -vv|grep raku-OpenSSL
raku-OpenSSL-0.2.0-r4 - OpenSSL bindings for Raku
/ # apk info -vv|grep ssl
libcrypto1.1-1.1.1q-r0 - Crypto library from openssl
libssl1.1-1.1.1q-r0 - SSL shared libraries
ssl_client-1.35.0-r17 - EXternal ssl_client for busybox wget
openssl-1.1.1q-r0 - toolkit for transport layer security (TLS) - version 1.1
openssl-dev-1.1.1q-r0 - toolkit for transport layer security (TLS) - version 1.1 (development files)
melezhik commented 1 year ago

The package descriptor could be found here - https://github.com/melezhik/raku-alpine-repo/blob/main/.tom/packages.raku#L206-L220

melezhik commented 1 year ago

the code works just fine after removing "version(3)"