Hello POE fans,

I just released the modul POE::Filter::SSL to allow a feature
rich, well working and flexible SSL solution to POE. During this
I got the following two questions:

Thought use of SSL in POE
=========================

There has been already a discussion about this problem on the
mailing list, see http://www.mail-archive.com/poe@perl.org/msg04006.html.
It resulted in a release of the modules Data::Transform,
Data::Transform::SSL and Data::Transform::POE. David Davis agreed
in the mentioned mail to modify Wheel::ReadWrite to support this module,
but it seems that it never got integrated. So Data::Transform::POE is
now a completly unknown, undfindable and unexpected release of an
POE::Wheel::ReadWrite overloader to do SSL in POE... Since about
two years now!

Next there is a release of POE::Component::SSLify, which does not
allow to access the socket by POE itself because OpenSSL gets it
and it is tied to map the read and write requests. Anyway that it
has been a long time just blocking and the lack of support of TLS
on a already established connection (e.g. STARTTLS), the module
POE::Component::Client::TCP is refering to on the PreConnect function
description. Until today it don't allow certification verification
and other features of ssl, so I released a improved version as
POE::Component::SSLify::NonBlock. To integrate the support of TLS
on a already established connection, I now released the
POE::Filter::SSL module...

At least there is a further POE::Component::Client::HTTP::SSL module,
which also seems seems to be nonblocking and fixes the long problems
of blocking mode by POE::Component::SSLify...

MY QUESTION: What is it the thought way to do SSL on POE?

Need to write back on read in POE::Filter
=========================================

POE::Filter::SSL needs to send data back to the server if it has
read data, because the SSL handshake has to read and write multiple
times without before data can flow over it. Currently, POE::Filter
can't write data if something has been read. I solved this problem
at the moment in POE::Filter::SSL by indicating the receive handler
of the incomming data that I need to write (I return an empty data
string), so it can do a put() and the POE::Filter:SSL can write data
back to the remote side:

  POE::Component::Client::TCP->new(
    RemoteAddress => ...,
    Filter => [ "POE::Filter::SSL", client => 1 ],
    ServerInput   => sub {
# Here comes the workaround!
      return $_[HEAP]{server}->put() unless $_[ARG0];
      ...
    },
    ...

... here a little bit more nice-looking:

   POE::Session->create(
      inline_states => {
        _start       => sub {
          $heap->{socket_wheel} = POE::Wheel::ReadWrite->new(
            Filter     => POE::Filter::SSL->new(client => 1),
            ...
        );
      },
      socket_input => sub {
        ...
# Here comes the workaround!
        return $_[HEAP]{socket_wheel}->put()
unless $heap->{socket_wheel}->get_input_filter()->handshakeDone();
        ...

I think it would be the best to allow a filter to indicate that it needs
to write if it has read data from the socket side of POE::Wheel::ReadWrite,
so the running of put() in the incomming handler isn't needed anymore.
Currently the filter has only the ability to write data to the remote side
if the put() function has been called.

MY QUESTION: What do you think about a (optional) function which
POE::Wheel::ReadWrite looks for and calls (of course only if it
is defined) everytime a get() or put() has been run and as
long as it returns data, to fetch data that needs wo be
written to the socket side? What do you thing about the names
"get_pending_put" and "get_pending_get" ?

Cheers,
Markus

Reply via email to