Google Answers Logo
View Question
 
Q: Perl Socket programming and SSL ( No Answer,   0 Comments )
Question  
Subject: Perl Socket programming and SSL
Category: Computers > Programming
Asked by: mactac-ga
List Price: $35.00
Posted: 07 Jun 2004 11:36 PDT
Expires: 11 Jun 2004 10:55 PDT
Question ID: 357674
I am a perl programmer, but do not quite grasp what needs to be done
to set up SSL sockets.  I am trying to set up a server to receive
incoming TCP requests on a port & respond to them.  I have it set up
right now using IO::sockets::INET, but want to add encryption so
sensitive data may be passed back and forth.

my questions are:

1.  I have looked into certificates, and I see self-signed and ones
from verisign, etc.  do I *need* one from verisign, etc, or can I use
a self-signed?  is there a difference?  I'm not trying to set up
https.  I have actually set up a self-signed cert based on what I read
here:  http://www.modssl.org/docs/2.8/ssl_faq.html#ToC24   I *think* I
did it corrently, but there are so many variables at work here that I
can't tell if it's 'working'

2.  I need to know how to correctly us IO:SOCKET::SSL  with my
certificate.  I can't create the socket.  I read that IO::SOCKET::SSL
is a drop in replacement for IO:SOCKET::INET, but when i replaced it,
it didn't function (I think I need to make reference tothe cert or
something, can't find good docs on this).  I need to make my script
work with my cert (or new cert if I have to buy one)

3.  I've read all sorts of things about closing sockets properly, esp
with SSL.  am I doing this right?

4.  I want this app to be able to accept multiple sockets at once. 
mine waits for each socket until the prev is done.

I would like my code modified to incorporate all of these 4 problems. 
here is what I have currently (in the non-ssl version, and it is
working correctly...except for threading):

#!/usr/bin/perl

use IO::Socket::INET;

$server_port=11194;     #this is the port to listen on !

#  open a socket, start listening for connections, for some reason
changing this to IO::SOCKET::SSL doesn't work.. prob needs more
parameters?

$server = IO::Socket::INET->new(LocalPort => $server_port,
                                Type      => SOCK_STREAM, 
                                Reuse     => 1,
                                Listen    => 10 )
or die "Couldn't be a tcp server on port $server_port: $!\n";

while ($client = $server->accept()) {
    # $client is the new connection   
    $text=<$client>;
    
    #  do some stuff with $text
    
    # send to the client whatever I did in $return
    print $client $return;
    close($client);
    
    # clear query because it seems to keep old stuff in $text
    $text="";
    undef($text);
}   
close($server);

Clarification of Question by mactac-ga on 08 Jun 2004 17:23 PDT
I actually have purchased an sll certificate, so the part of my
question about self-signed certificates is no longer needed.

i need:
 - for this script to work with IO::SOCKET::SSL
 - for the script to thread properly
 - for the socket to close properly when closed (I heard there were
specific ways of doing this with IO::SOCKET::SSL)
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy