|
NAMESocket::Class::SSL::CTX - Shared context for Socket::Class::SSL SYNOPSISuse Socket::Class::SSL; $ctx = Socket::Class::SSL::CTX->new( ... ); $ssl = Socket::Class::SSL->new( 'use_ctx' => $ctx, ... ); $ssl = Socket::Class::SSL->startssl( $sock, 'use_ctx' => $ctx, ... ); DESCRIPTIONThe module creates shared ssl context for improved performance. Functions in alphabetical ordercheck_private_key, enable_compatibility, new,
set_certificate, set_cipher_list, set_client_ca, set_private_key,
set_ssl_method, set_verify_locations,
EXAMPLESSSL Server using forkthanks to J. Nick Koston use Socket::Class::SSL;
%ssl_args = (
'private_key' => '/path/to/server.key.pem',
'certificate' => '/path/to/server.crt.pem',
'cipher_list' => 'ALL:!ADH:+HIGH:+MEDIUM:-LOW:-SSLv2:-EXP'
);
# create shared context
$ssl_ctx = Socket::Class::SSL::CTX->new(
'server' => 1,
%ssl_args
) or die $@;
# create listen socket
$server = Socket::Class->new (
'listen' => 45,
'proto' => 'tcp',
'local_port' => 10001,
'reuseaddr' => 1,
);
while( 1 ) {
# test readability
$server->select( 1, undef, undef, 5 ) or next;
# accept client
$socket = $server->accept() or next;
if( fork() ) {
# whats going on here?
$socket->close();
}
else {
# start ssl
$ssl_socket = Socket::Class::SSL->startssl(
$socket,
'server' => 1,
'use_ctx' => $ssl_ctx,
%ssl_args
) or die "Could not start ssl: $@";
# speak to the client
$ssl_socket->write( "SSL SERVER CONNETED OK\n" );
# ...
exit();
}
}
METHODS
Return Values Returns a TRUE value on success or UNDEF on failure.
Return Values Returns a TRUE value on success or UNDEF on failure.
Return Values Returns a true value on success or undef on failure. Note The CAs listed do not become trusted (list only contains the names, not the complete certificates); use set_verify_locations() to additionally load them for verification. These function is only useful for TLS/SSL servers.
When looking up CA certificates, the OpenSSL library will search the certificates in $ca_file first, then those in $ca_path. Certificate matching is done based on the subject name, the key identifier (if present), and the serial number as taken from the certificate to be verified. If these data do not match, the next certificate will be tried. The verification process will be performed on the first matching certificate. In case of failure no other certificates with the same parameters are searched. Return Values Returns a true value on success or undef on failure. Note In server mode, when requesting a client certificate, the server must send the list of CAs to accept client certificates. This list is not influenced by the contents of $ca_file or $ca_path and must explicitly be set using the set_client_ca() function.
Return Values Returns a true value on success or undef on failure.
Return Values Returns a true value on success or undef on failure. SEE ALSOThe Socket::Class::SSL manpage OpenSSL, <http://www.openssl.org/> AUTHORSChristian Mueller, <http://www.alien-heads.org/> COPYRIGHT AND LICENSEThis module is part of the Socket::Class::SSL module and stays under the same copyright and license agreements.
|