ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/lib/AnyEvent/Handle.pm
(Generate patch)

Comparing AnyEvent/lib/AnyEvent/Handle.pm (file contents):
Revision 1.24 by root, Sat May 24 15:11:46 2008 UTC vs.
Revision 1.25 by root, Sat May 24 15:19:43 2008 UTC

673 673
674 # all others are fine for our purposes 674 # all others are fine for our purposes
675 } 675 }
676} 676}
677 677
678=item $handle->starttls ($tls[, $tls_ctx])
679
680Instead of starting TLS negotiation immediately when the AnyEvent::Handle
681object is created, you can also do that at a later time by calling
682C<starttls>.
683
684The first argument is the same as the C<tls> constructor argument (either
685C<"connect">, C<"accept"> or an existing Net::SSLeay object).
686
687The second argument is the optional C<Net::SSLeay::CTX> object that is
688used when AnyEvent::Handle has to create its own TLS connection object.
689
690=cut
691
678# TODO: maybe document... 692# TODO: maybe document...
679sub starttls { 693sub starttls {
680 my ($self, $ssl, $ctx) = @_; 694 my ($self, $ssl, $ctx) = @_;
695
696 $self->stoptls;
681 697
682 if ($ssl eq "accept") { 698 if ($ssl eq "accept") {
683 $ssl = Net::SSLeay::new ($ctx || TLS_CTX ()); 699 $ssl = Net::SSLeay::new ($ctx || TLS_CTX ());
684 Net::SSLeay::set_accept_state ($ssl); 700 Net::SSLeay::set_accept_state ($ssl);
685 } elsif ($ssl eq "connect") { 701 } elsif ($ssl eq "connect") {
710 Net::SSLeay::BIO_write ($_[0]{tls_rbio}, ${$_[1]}); 726 Net::SSLeay::BIO_write ($_[0]{tls_rbio}, ${$_[1]});
711 &_dotls; 727 &_dotls;
712 }; 728 };
713} 729}
714 730
731=item $handle->stoptls
732
733Destroys the SSL connection, if any. Partial read or write data will be
734lost.
735
736=cut
737
738sub stoptls {
739 my ($self) = @_;
740
741 Net::SSLeay::free (delete $self->{tls}) if $self->{tls};
742 delete $self->{tls_rbio};
743 delete $self->{tls_wbio};
744 delete $self->{tls_wbuf};
745 delete $self->{filter_r};
746 delete $self->{filter_w};
747}
748
715sub DESTROY { 749sub DESTROY {
716 my $self = shift; 750 my $self = shift;
717 751
718 Net::SSLeay::free (delete $self->{tls}) if $self->{tls}; 752 $self->stoptls;
719} 753}
720 754
721=item AnyEvent::Handle::TLS_CTX 755=item AnyEvent::Handle::TLS_CTX
722 756
723This function creates and returns the Net::SSLeay::CTX object used by 757This function creates and returns the Net::SSLeay::CTX object used by

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines