http://qs1969.pair.com?node_id=1083858

jonadab has asked for the wisdom of the Perl Monks concerning the following question:

$d = HTTP::Daemon::SSL->new( LocalPort => $bkportnum, LocalAddr => '10.0.0.1', ) or carp("Unable to create new HTTP::Daemon::SSL object" . Dumper(+{ port => $bkportnum, strbang => $!, SSL_ERROR => $SSL_ERROR, retval => $d, strat => $@, }) . ".");

This used to work just fine. Then it stopped working, and there's no error message. $! and $@ are both empty strings, and $d and $SSL_ERROR are both undef.

Is there a good way to debug something like this, other than by ripping out HTTP::Daemon::SSL and replacing it with an entirely different module?

And if I did want to replace it with a different module (say, with one that produces error messages when appropriate), does anybody have a recommendation?

Update: I ended up throwing the whole thing out and using Net::OpenSSH instead, making the problem moot and also nicely circumventing the need to listen on an extra port into the bargain.

Replies are listed 'Best First'.
Re: How to debug failure in HTTP::Daemon::SSL->new()
by zentara (Archbishop) on Apr 26, 2014 at 14:48 UTC
    I have seen this old tip.
    #!/usr/bin/perl #The trick here is simply to dynamically change the #inheritance of HTTP::Daemon to make it an heir #of IO::Socket::SSL instead of IO::Socket::INET use HTTP::Daemon; use IO::Socket::SSL; @HTTP::Daemon::ISA = qw/ IO::Socket::SSL /; @HTTP::Daemon::ClientConn::ISA = qw/ IO::Socket::SSL /; my $server = new HTTP::Daemon SSL_cert_file => 'cert.pem', SSL_cert_file => 'key.pm', LocalPort => 443, ReuseAddr => 1, ; while ( my $client = $server->accept() ) { # do stuff ... $client->close(SSL_no_shutdown => 1); } $server->close(SSL_no_shutdown => 1);

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
Re: How to debug failure in HTTP::Daemon::SSL->new()
by Anonymous Monk on Apr 25, 2014 at 22:24 UTC

    Just some debugging ideas:

    Then it stopped working

    What changed? I guarantee you something changed. New version of Perl, update of the module or a related module, OS updates, ...?

    You can step through the code with the debugger.

      Since we live in a completely deterministic universe, something has surely changed.

      The OP doesn't mention whether the remote server was validated. Maybe it is no longer at 10.0.0.1. Maybe the server has been updated due to some enormous flaw in a widely used library. Maybe the server has a new certificate and there are trust issues. When looking for what has changed, remember that it may not be something you did.

      NB: I find it handy to leave comments in my code on how to test external resources (usually needed during development anyway). I prefer commands I can use from a shell prompt as they tend to be more stable over time (IMO).

        The OP doesn't mention whether the remote server was validated. Maybe it is no longer at 10.0.0.1.

        This is the server code. (The client just uses wget.) And yes, 10.0.0.1 is correct.

      I guarantee you something changed.

      Doubtless.

      Unfortunately, it was several weeks before I noticed that it had stopped working, so tracking down exactly what had changed at that precise moment is not entirely straightforward.

        Oh. Any luck with the debugger?

        HTTP::Daemon::SSL inherits its new() method pretty much directly from IO::Socket::SSL, so the problem should be coming from there. That module had a release just a few days ago, perhaps you could try pulling the latest version of that and opening a socket with that, maybe that'll get you an improvement, or at least an error message?

Re: How to debug failure in HTTP::Daemon::SSL->new()
by karlgoethebier (Abbot) on Apr 26, 2014 at 10:26 UTC

    I just guess: Everything OK with IO::Socket::SSL and and HTTP::Daemon?

    Please note also that HTTP::Daemon::SSL seems to be unmaintained for about 4 years.

    Best regards, Karl

    «The Crux of the Biscuit is the Apostrophe»