SOAP::Lite and SSL

Once I found the solution how to create Perl SOAP server with SSL. Here is a path for a module SOAP::Transport::HTTP::Daemon:

392c392,399
- sub new { require HTTP::Daemon;
---
+ sub SSL {
+ my $self = shift->new;
+ @_ ? ($self->{_SSL} = shift, return $self) : return
$self->{_SSL};
+ }
+
+ sub http_daemon_class { shift->SSL ? 'HTTP::Daemon::SSL' : 'HTTP::Daemon' }
+
+ sub new {
401c408,415
- $self->{_daemon} = HTTP::Daemon->new(@params) or Carp::croak "Can't create daemon: $!";
---
+
+ # use SSL if there is any parameter with SSL_* in the name
+ $self->SSL(1) if !$self->SSL && grep /^SSL_/, @params;
+ my $http_daemon = $self->http_daemon_class;
+ eval "require $http_daemon" or Carp::croak $@ unless UNIVERSAL::can($http_daemon => 'new');
+ $self->{_daemon} = $http_daemon->new(@params) or Carp::croak "Can't create daemon: $!";

Now, the server can be created like that:

my $daemon = SOAP::Transport::HTTP::Daemon->new(
LocalPort => 81,
Listen => 1,
SSL_use_cert => 1,
SSL_key_file => 'soap_server.key',
SSL_cert_file => 'soap_server.cert');

and client should use https instead of HTTP.
Unfortunatelly, I didn’t have a necessity to use it but may be in the future it’ll help me.

Published by

Michael Stepanov

Site owner and admin :)

Leave a Reply

Your email address will not be published. Required fields are marked *