noxxi / p5-io-socket-ssl

IO::Socket::SSL Perl Module
36 stars 59 forks source link

out of filehandles #71

Closed ufobat closed 3 years ago

ufobat commented 6 years ago

Hello,

I am not sure if this is even a bug or a documentation issue.

I was creating a couple of ssl connections with IO::Socket::SSL->new(...). unfortunatelly I was running out of open file descriptors. Of course the related files need to be read out but the code examples in the documentation lead to the assumption that you "just" need to check the return value of IO::Socket::SSL->new().

SSL_cert_file ../var/certs/server.crt can't be used: Too many open files at /opt/perl/lib/site_perl/5.26.0/IO/Socket/SSL.pm line 2258.
    IO::Socket::SSL::SSL_Context::new("IO::Socket::SSL::SSL_Context", HASH(0x95c3c00)) called at /opt/perl/lib/site_perl/5.26.0/IO/Socket/SSL.pm line 641
    IO::Socket::SSL::configure_SSL(IO::Socket::SSL=GLOB(0x95dcb38), HASH(0x95c3c00)) called at /opt/perl/lib/site_perl/5.26.0/IO/Socket/SSL.pm line 607
    IO::Socket::SSL::configure(IO::Socket::SSL=GLOB(0x95dcb38), HASH(0x95c3c00)) called at /opt/perl/lib/site_perl/5.26.0/x86_64-linux-multi/IO/Socket.pm line 48
    IO::Socket::new(...) called at /opt/perl/lib/site_perl/5.26.0/IO/Socket/IP.pm line 369

Would it make sense to catch this error inside the API and just return undef for IO::Socket::SSL->new() and set the error variable?

noxxi commented 3 years ago

I don't think it is possible to handle lack of ressources in a sane way. For example lack of file handles might also result in failed certificate verification of the openssl library cannot open CA certificates for checking. Lack of memory will also cause strange problems. Lack of CPU resources again others. I think one need to make sure that sufficient ressources are available for the application to run.