Andrew Beverley
2015-08-19 14:34:44 UTC
Dear all,
I'm writing a small client/server application that communicates over SSL. I've
successfully created a simple test program, whereby a client can read data from
the server.
I'm considering doing certificate-based authentication, but am not sure if/how
this is possible using IO::Socket::SSL. I've generated self-signed certificates
for the client and server, both signed by the same self-generated CA certificate.
This works fine.
However, how can I ensure that only certificates signed by that particular CA
certificate are allowed to connect?
(hopefully I've got the terminology correct and it makes sense).
This is the server program:
use strict;
use warnings;
use IO::Socket::SSL;
my $server = IO::Socket::SSL->new(
LocalPort => 8080,
Listen => 10,
SSL_cert_file => 'cert.pem', # Contains both CA and client cert
SSL_key_file => 'mykey.key',
);
while (1) {
my $client = $server->accept;
print $client "Random data\n";
}
$server->close();
And the client program:
use strict;
use warnings;
use IO::Socket::SSL;
my $client = IO::Socket::SSL->new(
SSL_ca_file => 'ca-cert.pem',
PeerHost => "testhost.com",
PeerPort => "8080",
);
my $serverdata = <$client>;
print "Message from Server : $serverdata \n";
$client->close();
I'm writing a small client/server application that communicates over SSL. I've
successfully created a simple test program, whereby a client can read data from
the server.
I'm considering doing certificate-based authentication, but am not sure if/how
this is possible using IO::Socket::SSL. I've generated self-signed certificates
for the client and server, both signed by the same self-generated CA certificate.
This works fine.
However, how can I ensure that only certificates signed by that particular CA
certificate are allowed to connect?
(hopefully I've got the terminology correct and it makes sense).
This is the server program:
use strict;
use warnings;
use IO::Socket::SSL;
my $server = IO::Socket::SSL->new(
LocalPort => 8080,
Listen => 10,
SSL_cert_file => 'cert.pem', # Contains both CA and client cert
SSL_key_file => 'mykey.key',
);
while (1) {
my $client = $server->accept;
print $client "Random data\n";
}
$server->close();
And the client program:
use strict;
use warnings;
use IO::Socket::SSL;
my $client = IO::Socket::SSL->new(
SSL_ca_file => 'ca-cert.pem',
PeerHost => "testhost.com",
PeerPort => "8080",
);
my $serverdata = <$client>;
print "Message from Server : $serverdata \n";
$client->close();