Dear Perl Monks,

Intro

(NOTE: after this one seemed solved, I hit another snag trying to marry IO::Multiplex and IO::Socket::SSL, which is described here)

I'm trying to build a non-blocking, SSL capable thingie around IO::Multiplex (basically a kind of application proxy, playing the roles of HTTP server and HTTP client).

The non-SSL part is working nicely, now I'm trying to get the SSL part up (just in the client role).

Out of the bewildering array of possibilities I settled fot IO::Socket::SSL. It seems that Multiplex.pm explicitly supports "pseudo" SSL sockets with their somewhat strange behaviour.

As an extra difficulty, I'm behind a proxy, so I have to first send a CONNECT request to the proxy in clear text (this part works).

The Case of the Disappearing fileno

Where I'm stuck is at the attempt to "upgrade" the socket to SSL. That's what I am trying:

sub _sslproxy_done { my($self, $response, $callback) = @_; # We expect here "200 Connection established" unless($response->is_success) { $logger->log(WARN, "Proxy request failed: ", $response->status_line); return; } $logger->log(DEBUG, "Proxy CONNECTed: sock=", $self->{proxy_requestor}->sock, " fileno=", fileno($self->{proxy_requestor}->sock)); $self->{sslsock} = $self->{proxy_requestor}->sock; unless(IO::Socket::SSL->start_SSL($self->{sslsock}, SSL_startHandshake => 0)) { $logger->log(DEBUG, "start_SSL returns false"); return; } for(;;) { # Later do asynchronously! $logger->log(DEBUG, "connect_SSL..."); $self->{sslsock}->connect_SSL && last; $logger->log(DEBUG, "connect_SSL: $SSL_ERROR"); } $logger->log(DEBUG, "_sslproxy_done() sslsock=", $self->{sslsock}, " opened=", $self->{sslsock} && $self->{sslsock}->opened); goto &$callback if($self->{sslsock}); $logger->log(WARN, "start_SSL error: ", IO::Socket::SSL::errstr() || "Unknown"); }

Before calling IO::Socket::SSL->start_SSL(...) above, the debugging function dutifully says:

1337867878.449198 [Mumble::Backend::query]: Proxy CONNECTed: sock=bles +s( \*Symbol::GEN2, 'IO::Socket::INET' ) fileno=7 at Mumble::Backend:: +query line 582

Note the fileno=7 there?

But within IO::Socket::SSL::start_SSL (I have a local copy which I can augment with DEBUG calls as needed), I see:

DEBUG: .../IO/Socket/SSL.pm:991: socket = IO::Socket::INET=GLOB(0x18e1 +dc0) fileno=

EEEK! This looks completely different! Besides: where's my fileno?

Needles to say, we run into problems when trying to "connect_SSL" that:

DEBUG: .../IO/Socket/SSL.pm:1546: new ctx 26143712 DEBUG: .../IO/Socket/SSL.pm:1017: dont start handshake: IO::Socket::SS +L=GLOB(0x18e1dc0) DEBUG: .../IO/Socket/SSL.pm:349: ssl handshake not started 1337867878.451761 [Mumble::Backend::query]: connect_SSL... at Mumble:: +Backend::query line 589 DEBUG: .../IO/Socket/SSL.pm:1277: Socket has no filenoerror:00000000:l +ib(0):func(0):reason(0)

Shared file handles for select?

One more question:

When I upgrade a IO::Socket::INET to an SSL they will share the file handle? I.e. for IO::Multiplex they are the same?

If yes, I'd better detach the "old, plain socket" from IO::Multiplex before I attach the upgraded SSL socket, right?

Are there any examples out there for this combination?


In reply to IO::Multiplex, IO::Socket::SSL, file globs by oldtomas

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.