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); |