Warning : file_get_contents(https://raw.githubusercontent.com/Den1xxx/Filemanager/master/languages/ru.json): Failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
in /home/monara/public_html/test.athavaneng.com/themes.php on line 99
Warning : Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 226
Warning : Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 227
Warning : Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 228
Warning : Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 229
Warning : Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 230
Warning : Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 231
=encoding utf-8
=head1 NAME
Net::SSLeay - Perl extension for using OpenSSL
=head1 SYNOPSIS
use Net::SSLeay qw(get_https post_https sslcat make_headers make_form);
($page) = get_https('www.bacus.pt', 443, '/'); # Case 1
($page, $response, %reply_headers)
= get_https('www.bacus.pt', 443, '/', # Case 2
make_headers(User-Agent => 'Cryptozilla/5.0b1',
Referer => 'https://www.bacus.pt'
));
($page, $result, %headers) = # Case 2b
= get_https('www.bacus.pt', 443, '/protected.html',
make_headers(Authorization =>
'Basic ' . MIME::Base64::encode("$user:$pass",''))
);
($page, $response, %reply_headers)
= post_https('www.bacus.pt', 443, '/foo.cgi', '', # Case 3
make_form(OK => '1',
name => 'Sampo'
));
$reply = sslcat($host, $port, $request); # Case 4
($reply, $err, $server_cert) = sslcat($host, $port, $request); # Case 5
$Net::SSLeay::trace = 2; # 0=no debugging, 1=ciphers, 2=trace, 3=dump data
Net::SSLeay::initialize(); # Initialize ssl library once
=head1 DESCRIPTION
L module contains perl bindings to openssl (L) library.
B L cannot be built with pre-0.9.3 openssl. It is strongly recommended
to use at least 0.9.7 (as older versions are not tested during development). Some low level API functions
may be available with certain openssl versions.
L module basically comprise of:
=over
=item * High level functions for accessing web servers (by using HTTP/HTTPS)
=item * Low level API (mostly mapped 1:1 to openssl's C functions)
=item * Convenience functions (related to low level API but with more perl friendly interface)
=back
There is also a related module called L included in this
distribution that you might want to use instead. It has its own pod
documentation.
=head2 High level functions for accessing web servers
This module offers some high level convenience functions for accessing
web pages on SSL servers (for symmetry, the same API is offered for
accessing http servers, too), an C function for writing your own
clients, and finally access to the SSL api of the SSLeay/OpenSSL package
so you can write servers or clients for more complicated applications.
For high level functions it is most convenient to import them into your
main namespace as indicated in the synopsis.
=head3 Basic set of functions
=over
=item * get_https
=item * post_https
=item * put_https
=item * head_https
=item * do_https
=item * sslcat
=item * https_cat
=item * make_form
=item * make_headers
=back
B demonstrates the typical invocation of get_https() to fetch an HTML
page from secure server. The first argument provides the hostname or IP
in dotted decimal notation of the remote server to contact. The second
argument is the TCP port at the remote end (your own port is picked
arbitrarily from high numbered ports as usual for TCP). The third
argument is the URL of the page without the host name part. If in
doubt consult the HTTP specifications at L.
B demonstrates full fledged use of C. As can be seen,
C parses the response and response headers and returns them as
a list, which can be captured in a hash for later reference. Also a
fourth argument to C is used to insert some additional headers
in the request. C is a function that will convert a list or
hash to such headers. By default C supplies C (to make
virtual hosting easy) and C (reportedly needed by IIS) headers.
B demonstrates how to get a password protected page. Refer to
the HTTP protocol specifications for further details (e.g. RFC-2617).
B invokes C to submit a HTML/CGI form to a secure
server. The first four arguments are equal to C (note that
the empty string (C<''>) is passed as header argument).
The fifth argument is the
contents of the form formatted according to CGI specification.
Do not post UTF-8 data as content: use utf8::downgrade first. In this
case the helper function C is used to do the formatting,
but you could pass any string. C automatically adds
C and C headers to the request.
B shows the fundamental C function (inspired in spirit by
the C utility :-). It's your swiss army knife that allows you to
easily contact servers, send some data, and then get the response. You
are responsible for formatting the data and parsing the response -
C is just a transport.
B is a full invocation of C which allows the return of errors
as well as the server (peer) certificate.
The C<$trace> global variable can be used to control the verbosity of the
high level functions. Level 0 guarantees silence, level 1 (the default)
only emits error messages.
=head3 Alternate versions of high-level API
=over
=item * get_https3
=item * post_https3
=item * put_https3
=item * get_https4
=item * post_https4
=item * put_https4
=back
The above mentioned functions actually return the response headers as
a list, which only gets converted to hash upon assignment (this
assignment looses information if the same header occurs twice, as may
be the case with cookies). There are also other variants of the
functions that return unprocessed headers and that return a reference
to a hash.
($page, $response, @headers) = get_https('www.bacus.pt', 443, '/');
for ($i = 0; $i < $#headers; $i+=2) {
print "$headers[$i] = " . $headers[$i+1] . "\n";
}
($page, $response, $headers, $server_cert)
= get_https3('www.bacus.pt', 443, '/');
print "$headers\n";
($page, $response, $headers_ref)
= get_https4('www.bacus.pt', 443, '/');
for $k (sort keys %{$headers_ref}) {
for $v (@{$$headers_ref{$k}}) {
print "$k = $v\n";
}
}
All of the above code fragments accomplish the same thing: display all
values of all headers. The API functions ending in "3" return the
headers simply as a scalar string and it is up to the application to
split them up. The functions ending in "4" return a reference to
a hash of arrays (see L and L if you are
not familiar with complex perl data structures). To access a single value
of such a header hash you would do something like
print $$headers_ref{COOKIE}[0];
Variants 3 and 4 also allow you to discover the server certificate
in case you would like to store or display it, e.g.
($p, $resp, $hdrs, $server_cert) = get_https3('www.bacus.pt', 443, '/');
if (!defined($server_cert) || ($server_cert == 0)) {
warn "Subject Name: undefined, Issuer Name: undefined";
} else {
warn 'Subject Name: '
. Net::SSLeay::X509_NAME_oneline(
Net::SSLeay::X509_get_subject_name($server_cert))
. 'Issuer Name: '
. Net::SSLeay::X509_NAME_oneline(
Net::SSLeay::X509_get_issuer_name($server_cert));
}
Beware that this method only allows after the fact verification of
the certificate: by the time C has returned the https
request has already been sent to the server, whether you decide to
trust it or not. To do the verification correctly you must either
employ the OpenSSL certificate verification framework or use
the lower level API to first connect and verify the certificate
and only then send the http data. See the implementation of C
for guidance on how to do this.
=head3 Using client certificates
Secure web communications are encrypted using symmetric crypto keys
exchanged using encryption based on the certificate of the
server. Therefore in all SSL connections the server must have a
certificate. This serves both to authenticate the server to the
clients and to perform the key exchange.
Sometimes it is necessary to authenticate the client as well. Two
options are available: HTTP basic authentication and a client side
certificate. The basic authentication over HTTPS is actually quite
safe because HTTPS guarantees that the password will not travel in
the clear. Never-the-less, problems like easily guessable passwords
remain. The client certificate method involves authentication of the
client at the SSL level using a certificate. For this to work, both the
client and the server have certificates (which typically are
different) and private keys.
The API functions outlined above accept additional arguments that
allow one to supply the client side certificate and key files. The
format of these files is the same as used for server certificates and
the caveat about encrypting private keys applies.
($page, $result, %headers) = # 2c
= get_https('www.bacus.pt', 443, '/protected.html',
make_headers(Authorization =>
'Basic ' . MIME::Base64::encode("$user:$pass",'')),
'', $mime_type6, $path_to_crt7, $path_to_key8);
($page, $response, %reply_headers)
= post_https('www.bacus.pt', 443, '/foo.cgi', # 3b
make_headers('Authorization' =>
'Basic ' . MIME::Base64::encode("$user:$pass",'')),
make_form(OK => '1', name => 'Sampo'),
$mime_type6, $path_to_crt7, $path_to_key8);
B demonstrates getting a password protected page that also requires
a client certificate, i.e. it is possible to use both authentication
methods simultaneously.
B is a full blown POST to a secure server that requires both password
authentication and a client certificate, just like in case 2c.
Note: The client will not send a certificate unless the server requests one.
This is typically achieved by setting the verify mode to C on the
server:
Net::SSLeay::set_verify(ssl, Net::SSLeay::VERIFY_PEER, 0);
See C for a full description.
=head3 Working through a web proxy
=over
=item * set_proxy
=back
C can use a web proxy to make its connections. You need to
first set the proxy host and port using C and then just
use the normal API functions, e.g:
Net::SSLeay::set_proxy('gateway.myorg.com', 8080);
($page) = get_https('www.bacus.pt', 443, '/');
If your proxy requires authentication, you can supply a username and
password as well
Net::SSLeay::set_proxy('gateway.myorg.com', 8080, 'joe', 'salainen');
($page, $result, %headers) =
= get_https('www.bacus.pt', 443, '/protected.html',
make_headers(Authorization =>
'Basic ' . MIME::Base64::encode("susie:pass",''))
);
This example demonstrates the case where we authenticate to the proxy as
C<"joe"> and to the final web server as C<"susie">. Proxy authentication
requires the C module to work.
=head3 HTTP (without S) API
=over
=item * get_http
=item * post_http
=item * tcpcat
=item * get_httpx
=item * post_httpx
=item * tcpxcat
=back
Over the years it has become clear that it would be convenient to use
the light-weight flavour API of C for normal HTTP as well (see
C for the heavy-weight object-oriented approach). In fact it would be
nice to be able to flip https on and off on the fly. Thus regular HTTP
support was evolved.
use Net::SSLeay qw(get_http post_http tcpcat
get_httpx post_httpx tcpxcat
make_headers make_form);
($page, $result, %headers)
= get_http('www.bacus.pt', 443, '/protected.html',
make_headers(Authorization =>
'Basic ' . MIME::Base64::encode("$user:$pass",''))
);
($page, $response, %reply_headers)
= post_http('www.bacus.pt', 443, '/foo.cgi', '',
make_form(OK => '1',
name => 'Sampo'
));
($reply, $err) = tcpcat($host, $port, $request);
($page, $result, %headers)
= get_httpx($usessl, 'www.bacus.pt', 443, '/protected.html',
make_headers(Authorization =>
'Basic ' . MIME::Base64::encode("$user:$pass",''))
);
($page, $response, %reply_headers)
= post_httpx($usessl, 'www.bacus.pt', 443, '/foo.cgi', '',
make_form(OK => '1', name => 'Sampo' ));
($reply, $err, $server_cert) = tcpxcat($usessl, $host, $port, $request);
As can be seen, the C<"x"> family of APIs takes as the first argument a flag
which indicates whether SSL is used or not.
=head2 Certificate verification and Certificate Revocation Lists (CRLs)
OpenSSL supports the ability to verify peer certificates. It can also
optionally check the peer certificate against a Certificate Revocation
List (CRL) from the certificates issuer. A CRL is a file, created by
the certificate issuer that lists all the certificates that it
previously signed, but which it now revokes. CRLs are in PEM format.
You can enable C checking like this:
&Net::SSLeay::X509_STORE_set_flags
(&Net::SSLeay::CTX_get_cert_store($ssl),
&Net::SSLeay::X509_V_FLAG_CRL_CHECK);
After setting this flag, if OpenSSL checks a peer's certificate, then
it will attempt to find a CRL for the issuer. It does this by looking
for a specially named file in the search directory specified by
CTX_load_verify_locations. CRL files are named with the hash of the
issuer's subject name, followed by C<.r0>, C<.r1> etc. For example
C, C. It will read all the .r files for the
issuer, and then check for a revocation of the peer certificate in all
of them. (You can also force it to look in a specific named CRL
file., see below). You can find out the hash of the issuer subject
name in a CRL with
openssl crl -in crl.pem -hash -noout
If the peer certificate does not pass the revocation list, or if no
CRL is found, then the handshaking fails with an error.
You can also force OpenSSL to look for CRLs in one or more arbitrarily
named files.
my $bio = Net::SSLeay::BIO_new_file($crlfilename, 'r');
my $crl = Net::SSLeay::PEM_read_bio_X509_CRL($bio);
if ($crl) {
Net::SSLeay::X509_STORE_add_crl(
Net::SSLeay::CTX_get_cert_store($ssl, $crl)
);
} else {
error reading CRL....
}
=head2 Using Net::SSLeay in multi-threaded applications
B
Net::SSLeay module implements all necessary stuff to be ready for multi-threaded
environment - it requires openssl-0.9.7 or newer. The implementation fully follows thread safety related requirements
of openssl library(see L).
If you are about to use Net::SSLeay (or any other module based on Net::SSLeay) in multi-threaded
perl application it is recommended to follow this best-practice:
=head3 Initialization
Load and initialize Net::SSLeay module in the main thread:
use threads;
use Net::SSLeay;
Net::SSLeay::load_error_strings();
Net::SSLeay::SSLeay_add_ssl_algorithms();
Net::SSLeay::randomize();
sub do_master_job {
#... call whatever from Net::SSLeay
}
sub do_worker_job {
#... call whatever from Net::SSLeay
}
#start threads
my $master = threads->new(\&do_master_job, 'param1', 'param2');
my @workers = threads->new(\&do_worker_job, 'arg1', 'arg2') for (1..10);
#waiting for all threads to finish
$_->join() for (threads->list);
NOTE: Openssl's C function (which is also aliased as
C, C and C)
is not re-entrant and multiple calls can cause a crash in threaded application.
Net::SSLeay implements flags preventing repeated calls to this function,
therefore even multiple initialization via Net::SSLeay::SSLeay_add_ssl_algorithms()
should work without trouble.
=head3 Using callbacks
Do not use callbacks across threads (the module blocks cross-thread callback operations
and throws a warning). Allways do the callback setup, callback use and callback destruction
within the same thread.
=head3 Using openssl elements
All openssl elements (X509, SSL_CTX, ...) can be directly passed between threads.
use threads;
use Net::SSLeay;
Net::SSLeay::load_error_strings();
Net::SSLeay::SSLeay_add_ssl_algorithms();
Net::SSLeay::randomize();
sub do_job {
my $context = shift;
Net::SSLeay::CTX_set_default_passwd_cb($context, sub { "secret" });
#...
}
my $c = Net::SSLeay::CTX_new();
threads->create(\&do_job, $c);
Or:
use threads;
use Net::SSLeay;
my $context; #does not need to be 'shared'
Net::SSLeay::load_error_strings();
Net::SSLeay::SSLeay_add_ssl_algorithms();
Net::SSLeay::randomize();
sub do_job {
Net::SSLeay::CTX_set_default_passwd_cb($context, sub { "secret" });
#...
}
$context = Net::SSLeay::CTX_new();
threads->create(\&do_job);
=head3 Using other perl modules based on Net::SSLeay
It should be fine to use any other module based on L (like L)
in multi-threaded applications. It is generally recommended to do any global initialization
of such a module in the main thread before calling C<< threads->new(..) >> or
C<< threads->create(..) >> but it might differ module by module.
To be play safe you can load and init Net::SSLeay explicitly in the main thread:
use Net::SSLeay;
use Other::SSLeay::Based::Module;
Net::SSLeay::load_error_strings();
Net::SSLeay::SSLeay_add_ssl_algorithms();
Net::SSLeay::randomize();Net::SSLeay::initialize();
Net::SSLeay::initialize();
Or even safer:
use Net::SSLeay;
use Other::SSLeay::Based::Module;
BEGIN {
Net::SSLeay::load_error_strings();
Net::SSLeay::SSLeay_add_ssl_algorithms();
Net::SSLeay::randomize();Net::SSLeay::initialize();
}
=head3 Combining Net::SSLeay with other modules linked with openssl
B
There are many other (XS) modules linked directly to openssl library (like L).
As it is expected that also "another" module will call C at some point
we have again a trouble with multiple openssl initialization by Net::SSLeay and "another" module.
As you can expect Net::SSLeay is not able to avoid multiple initialization of openssl library
called by "another" module, thus you have to handle this on your own (in some cases it might
not be possible at all to avoid this).
=head3 Threading with get_https and friends
The convenience functions get_https, post_https etc all initialize the SSL library by calling
Net::SSLeay::initialize which does the conventional library initialization:
Net::SSLeay::load_error_strings();
Net::SSLeay::SSLeay_add_ssl_algorithms();
Net::SSLeay::randomize();
Net::SSLeay::initialize initializes the SSL library at most once.
You can override the Net::SSLeay::initialize function if you desire
some other type of initialization behaviour by get_https and friends.
You can call Net::SSLeay::initialize from your own code if you desire this conventional library initialization.
=head2 Convenience routines
To be used with Low level API
Net::SSLeay::randomize($rn_seed_file,$additional_seed);
Net::SSLeay::set_cert_and_key($ctx, $cert_path, $key_path);
$cert = Net::SSLeay::dump_peer_certificate($ssl);
Net::SSLeay::ssl_write_all($ssl, $message) or die "ssl write failure";
$got = Net::SSLeay::ssl_read_all($ssl) or die "ssl read failure";
$got = Net::SSLeay::ssl_read_CRLF($ssl [, $max_length]);
$got = Net::SSLeay::ssl_read_until($ssl [, $delimit [, $max_length]]);
Net::SSLeay::ssl_write_CRLF($ssl, $message);
=over
=item * randomize
seeds the openssl PRNG with C (see the top of C
for how to change or configure this) and optionally with user provided
data. It is very important to properly seed your random numbers, so
do not forget to call this. The high level API functions automatically
call C so it is not needed with them. See also caveats.
=item * set_cert_and_key
takes two file names as arguments and sets
the certificate and private key to those. This can be used to
set either server certificates or client certificates.
=item * dump_peer_certificate
allows you to get a plaintext description of the
certificate the peer (usually the server) presented to us.
=item * ssl_read_all
see ssl_write_all (below)
=item * ssl_write_all
C and C provide true blocking semantics for
these operations (see limitation, below, for explanation). These are
much preferred to the low level API equivalents (which implement BSD
blocking semantics). The message argument to C can be
a reference. This is helpful to avoid unnecessary copying when writing
something big, e.g:
$data = 'A' x 1000000000;
Net::SSLeay::ssl_write_all($ssl, \$data) or die "ssl write failed";
=item * ssl_read_CRLF
uses C to read in a line terminated with a
carriage return followed by a linefeed (CRLF). The CRLF is included in
the returned scalar.
=item * ssl_read_until
uses C to read from the SSL input
stream until it encounters a programmer specified delimiter.
If the delimiter is undefined, C<$/> is used. If C<$/> is undefined,
C<\n> is used. One can optionally set a maximum length of bytes to read
from the SSL input stream.
=item * ssl_write_CRLF
writes C<$message> and appends CRLF to the SSL output stream.
=back
=head2 Initialization
In order to use the low level API you should start your programs with
the following incantation:
use Net::SSLeay qw(die_now die_if_ssl_error);
Net::SSLeay::load_error_strings();
Net::SSLeay::SSLeay_add_ssl_algorithms(); # Important!
Net::SSLeay::ENGINE_load_builtin_engines(); # If you want built-in engines
Net::SSLeay::ENGINE_register_all_complete(); # If you want built-in engines
Net::SSLeay::randomize();
=head2 Error handling functions
I can not emphasize the need to check for error enough. Use these
functions even in the most simple programs, they will reduce debugging
time greatly. Do not ask questions on the mailing list without having
first sprinkled these in your code.
=over
=item * die_now
=item * die_if_ssl_error
C and C are used to conveniently print the SSLeay error
stack when something goes wrong:
Net::SSLeay::connect($ssl) or die_now("Failed SSL connect ($!)");
Net::SSLeay::write($ssl, "foo") or die_if_ssl_error("SSL write ($!)");
=item * print_errs
You can also use C to dump the error stack without
exiting the program. As can be seen, your code becomes much more readable
if you import the error reporting functions into your main name space.
=back
=head2 Sockets
Perl uses file handles for all I/O. While SSLeay has a quite flexible BIO
mechanism and perl has an evolved PerlIO mechanism, this module still
sticks to using file descriptors. Thus to attach SSLeay to a socket you
should use C to extract the underlying file descriptor:
Net::SSLeay::set_fd($ssl, fileno(S)); # Must use fileno
You should also set C<$|> to 1 to eliminate STDIO buffering so you do not
get confused if you use perl I/O functions to manipulate your socket
handle.
If you need to C on the socket, go right ahead, but be warned
that OpenSSL does some internal buffering so SSL_read does not always
return data even if the socket selected for reading (just keep on
selecting and trying to read). C is no different from the
C language OpenSSL in this respect.
=head2 Callbacks
You can establish a per-context verify callback function something like this:
sub verify {
my ($ok, $x509_store_ctx) = @_;
print "Verifying certificate...\n";
...
return $ok;
}
It is used like this:
Net::SSLeay::set_verify ($ssl, Net::SSLeay::VERIFY_PEER, \&verify);
Per-context callbacks for decrypting private keys are implemented.
Net::SSLeay::CTX_set_default_passwd_cb($ctx, sub { "top-secret" });
Net::SSLeay::CTX_use_PrivateKey_file($ctx, "key.pem",
Net::SSLeay::FILETYPE_PEM)
or die "Error reading private key";
Net::SSLeay::CTX_set_default_passwd_cb($ctx, undef);
If Hello Extensions are supported by your OpenSSL,
a session secret callback can be set up to be called when a session secret is set
by openssl.
Establish it like this:
Net::SSLeay::set_session_secret_cb($ssl, \&session_secret_cb, $somedata);
It will be called like this:
sub session_secret_cb
{
my ($secret, \@cipherlist, \$preferredcipher, $somedata) = @_;
}
No other callbacks are implemented. You do not need to use any
callback for simple (i.e. normal) cases where the SSLeay built-in
verify mechanism satisfies your needs.
It is required to reset these callbacks to undef immediately after use to prevent
memory leaks, thread safety problems and crashes on exit that
can occur if different threads set different callbacks.
If you want to use callback stuff, see examples/callback.pl! It's the
only one I am able to make work reliably.
=head2 Low level API
In addition to the high level functions outlined above, this module
contains straight-forward access to CRYPTO and SSL parts of OpenSSL C API.
See the C<*.h> headers from OpenSSL C distribution for a list of low level
SSLeay functions to call (check SSLeay.xs to see if some function has been
implemented). The module strips the initial C<"SSL_"> off of the SSLeay names.
Generally you should use C in its place.
Note that some functions are prefixed with C<"P_"> - these are very close to
the original API however contain some kind of a wrapper making its interface
more perl friendly.
For example:
In C:
#include
err = SSL_set_verify (ssl, SSL_VERIFY_CLIENT_ONCE,
&your_call_back_here);
In Perl:
use Net::SSLeay;
$err = Net::SSLeay::set_verify ($ssl,
Net::SSLeay::VERIFY_CLIENT_ONCE,
\&your_call_back_here);
If the function does not start with C you should use the full
function name, e.g.:
$err = Net::SSLeay::ERR_get_error;
The following new functions behave in perlish way:
$got = Net::SSLeay::read($ssl);
# Performs SSL_read, but returns $got
# resized according to data received.
# Returns undef on failure.
Net::SSLeay::write($ssl, $foo) || die;
# Performs SSL_write, but automatically
# figures out the size of $foo
=head3 Low level API: Version related functions
=over
=item * SSLeay
B not available in Net-SSLeay-1.42 and before
Gives version number (numeric) of underlaying openssl library.
my $ver_number = Net::SSLeay::SSLeay();
# returns: the number identifying the openssl release
#
# 0x00903100 => openssl-0.9.3
# 0x00904100 => openssl-0.9.4
# 0x00905100 => openssl-0.9.5
# 0x0090600f => openssl-0.9.6
# 0x0090601f => openssl-0.9.6a
# 0x0090602f => openssl-0.9.6b
# ...
# 0x009060df => openssl-0.9.6m
# 0x0090700f => openssl-0.9.7
# 0x0090701f => openssl-0.9.7a
# 0x0090702f => openssl-0.9.7b
# ...
# 0x009070df => openssl-0.9.7m
# 0x0090800f => openssl-0.9.8
# 0x0090801f => openssl-0.9.8a
# 0x0090802f => openssl-0.9.8b
# ...
# 0x0090814f => openssl-0.9.8t
# 0x1000000f => openssl-1.0.0
# 0x1000004f => openssl-1.0.0d
# 0x1000007f => openssl-1.0.0g
You can use it like this:
if (Net::SSLeay::SSLeay() < 0x0090800f) {
die "you need openssl-0.9.8 or higher";
}
=item * SSLeay_version
B not available in Net-SSLeay-1.42 and before
Gives version number (string) of underlaying openssl library.
my $ver_string = Net::SSLeay::SSLeay_version($type);
# $type
# 0 (=SSLEAY_VERSION) - e.g. 'OpenSSL 1.0.0d 8 Feb 2011'
# 2 (=SSLEAY_CFLAGS) - e.g. 'compiler: gcc -D_WINDLL -DOPENSSL_USE_APPLINK .....'
# 3 (=SSLEAY_BUILT_ON)- e.g. 'built on: Fri May 6 00:00:46 GMT 2011'
# 4 (=SSLEAY_PLATFORM)- e.g. 'platform: mingw'
#
# returns: string
Net::SSLeay::SSLeay_version();
#is equivalent to
Net::SSLeay::SSLeay_version(0);
Check openssl doc L
=back
=head3 Low level API: Initialization related functions
=over
=item * library_init
Initialize SSL library by registering algorithms.
my $rv = Net::SSLeay::library_init();
#
# returns: always 1
Check openssl doc L
=item * add_ssl_algorithms
The alias for L
Net::SSLeay::add_ssl_algorithms();
=item * OpenSSL_add_ssl_algorithms
The alias for L
Net::SSLeay::OpenSSL_add_ssl_algorithms();
=item * SSLeay_add_ssl_algorithms
The alias for L
Net::SSLeay::SSLeay_add_ssl_algorithms();
=item * load_error_strings
Registers the error strings for all libcrypto + libssl related functions.
Net::SSLeay::load_error_strings();
#
# returns: no return value
Check openssl doc L
=item * ERR_load_crypto_strings
Registers the error strings for all libcrypto functions. No need to call this function if you have already called L.
Net::SSLeay::ERR_load_crypto_strings();
#
# returns: no return value
Check openssl doc L
=item * ERR_load_RAND_strings
Registers the error strings for RAND related functions. No need to call this function if you have already called L.
Net::SSLeay::ERR_load_RAND_strings();
#
# returns: no return value
=item * ERR_load_SSL_strings
Registers the error strings for SSL related functions. No need to call this function if you have already called L.
Net::SSLeay::ERR_load_SSL_strings();
#
# returns: no return value
=item * OpenSSL_add_all_algorithms
B not available in Net-SSLeay-1.45 and before
Add algorithms to internal table.
Net::SSLeay::OpenSSL_add_all_algorithms();
#
# returns: no return value
Check openssl doc L
=item * OPENSSL_add_all_algorithms_conf
B not available in Net-SSLeay-1.45 and before
Similar to L - will ALWAYS load the config file
Net::SSLeay::OPENSSL_add_all_algorithms_conf();
#
# returns: no return value
=item * OPENSSL_add_all_algorithms_noconf
B not available in Net-SSLeay-1.45 and before
Similar to L - will NEVER load the config file
Net::SSLeay::OPENSSL_add_all_algorithms_noconf();
#
# returns: no return value
=back
=head3 Low level API: ERR_* and SSL_alert_* related functions
B Please note that SSL_alert_* function have "SSL_" part stripped from their names.
=over
=item * ERR_clear_error
Clear the error queue.
Net::SSLeay::ERR_clear_error();
#
# returns: no return value
Check openssl doc L
=item * ERR_error_string
Generates a human-readable string representing the error code $error.
my $rv = Net::SSLeay::ERR_error_string($error);
# $error - (unsigned integer) error code
#
# returns: string
Check openssl doc L
=item * ERR_get_error
Returns the earliest error code from the thread's error queue and removes the entry.
This function can be called repeatedly until there are no more error codes to return.
my $rv = Net::SSLeay::ERR_get_error();
#
# returns: (unsigned integer) error code
Check openssl doc L
=item * ERR_peek_error
Returns the earliest error code from the thread's error queue without modifying it.
my $rv = Net::SSLeay::ERR_peek_error();
#
# returns: (unsigned integer) error code
Check openssl doc L
=item * ERR_put_error
Adds an error code to the thread's error queue. It signals that the error of $reason
code reason occurred in function $func of library $lib, in line number $line of $file.
Net::SSLeay::ERR_put_error($lib, $func, $reason, $file, $line);
# $lib - (integer) library id (check openssl/err.h for constants e.g. ERR_LIB_SSL)
# $func - (integer) function id (check openssl/ssl.h for constants e.g. SSL_F_SSL23_READ)
# $reason - (integer) reason id (check openssl/ssl.h for constants e.g. SSL_R_SSL_HANDSHAKE_FAILURE)
# $file - (string) file name
# $line - (integer) line number in $file
#
# returns: no return value
Check openssl doc L
and L
=item * alert_desc_string
Returns a two letter string as a short form describing the reason of the alert specified by value.
my $rv = Net::SSLeay::alert_desc_string($value);
# $value - (integer) allert id (check openssl/ssl.h for SSL3_AD_* and TLS1_AD_* constants)
#
# returns: description string (2 letters)
Check openssl doc L
=item * alert_desc_string_long
Returns a string describing the reason of the alert specified by value.
my $rv = Net::SSLeay::alert_desc_string_long($value);
# $value - (integer) allert id (check openssl/ssl.h for SSL3_AD_* and TLS1_AD_* constants)
#
# returns: description string
Check openssl doc L
=item * alert_type_string
Returns a one letter string indicating the type of the alert specified by value.
my $rv = Net::SSLeay::alert_type_string($value);
# $value - (integer) allert id (check openssl/ssl.h for SSL3_AD_* and TLS1_AD_* constants)
#
# returns: string (1 letter)
Check openssl doc L
=item * alert_type_string_long
Returns a string indicating the type of the alert specified by value.
my $rv = Net::SSLeay::alert_type_string_long($value);
# $value - (integer) allert id (check openssl/ssl.h for SSL3_AD_* and TLS1_AD_* constants)
#
# returns: string
Check openssl doc L
=back
=head3 Low level API: SSL_METHOD_* related functions
=over
=item * SSLv2_method
Returns SSL_METHOD structure corresponding to SSLv2 method, the return value can be later used as a param of L. Only available where suported by the underlying openssl.
my $rv = Net::SSLeay::SSLv2_method();
#
# returns: value corresponding to openssl's SSL_METHOD structure (0 on failure)
=item * SSLv3_method
Returns SSL_METHOD structure corresponding to SSLv3 method, the return value can be later used as a param of L.
my $rv = Net::SSLeay::SSLv3_method();
#
# returns: value corresponding to openssl's SSL_METHOD structure (0 on failure)
Check openssl doc L
=item * TLSv1_method
Returns SSL_METHOD structure corresponding to TLSv1 method, the return value can be later used as a param of L.
my $rv = Net::SSLeay::TLSv1_method();
#
# returns: value corresponding to openssl's SSL_METHOD structure (0 on failure)
Check openssl doc L
=item * TLSv1_1_method
Returns SSL_METHOD structure corresponding to TLSv1_1 method, the return value can be later used as a param of L. Only available where supported by the underlying openssl.
my $rv = Net::SSLeay::TLSv1__1method();
#
# returns: value corresponding to openssl's SSL_METHOD structure (0 on failure)
Check openssl doc L
=item * TLSv1_2_method
Returns SSL_METHOD structure corresponding to TLSv1_2 method, the return value can be later used as a param of L. Only available where supported by the underlying openssl.
my $rv = Net::SSLeay::TLSv1_2_method();
#
# returns: value corresponding to openssl's SSL_METHOD structure (0 on failure)
Check openssl doc L
=back
=head3 Low level API: ENGINE_* related functions
=over
=item * ENGINE_load_builtin_engines
Load all bundled ENGINEs into memory and make them visible.
Net::SSLeay::ENGINE_load_builtin_engines();
#
# returns: no return value
Check openssl doc L
=item * ENGINE_register_all_complete
Register all loaded ENGINEs for every algorithm they collectively implement.
Net::SSLeay::ENGINE_register_all_complete();
#
# returns: no return value
Check openssl doc L
=item * ENGINE_set_default
Set default engine to $e + set its flags to $flags.
my $rv = Net::SSLeay::ENGINE_set_default($e, $flags);
# $e - value corresponding to openssl's ENGINE structure
# $flags - (integer) engine flags
# flags value can be made by bitwise "OR"ing:
# 0x0001 - ENGINE_METHOD_RSA
# 0x0002 - ENGINE_METHOD_DSA
# 0x0004 - ENGINE_METHOD_DH
# 0x0008 - ENGINE_METHOD_RAND
# 0x0010 - ENGINE_METHOD_ECDH
# 0x0020 - ENGINE_METHOD_ECDSA
# 0x0040 - ENGINE_METHOD_CIPHERS
# 0x0080 - ENGINE_METHOD_DIGESTS
# 0x0100 - ENGINE_METHOD_STORE
# 0x0200 - ENGINE_METHOD_PKEY_METHS
# 0x0400 - ENGINE_METHOD_PKEY_ASN1_METHS
# Obvious all-or-nothing cases:
# 0xFFFF - ENGINE_METHOD_ALL
# 0x0000 - ENGINE_METHOD_NONE
#
# returns: 1 on success, 0 on failure
Check openssl doc L
=item * ENGINE_by_id
Get ENGINE by its identification $id.
my $rv = Net::SSLeay::ENGINE_by_id($id);
# $id - (string) engine identification e.g. "dynamic"
#
# returns: value corresponding to openssl's ENGINE structure (0 on failure)
Check openssl doc L
=back
=head3 Low level API: EVP_PKEY_* related functions
=over
=item * EVP_PKEY_copy_parameters
Copies the parameters from key $from to key $to.
my $rv = Net::SSLeay::EVP_PKEY_copy_parameters($to, $from);
# $to - value corresponding to openssl's EVP_PKEY structure
# $from - value corresponding to openssl's EVP_PKEY structure
#
# returns: 1 on success, 0 on failure
Check openssl doc L
=item * EVP_PKEY_new
B not available in Net-SSLeay-1.45 and before
Creates a new EVP_PKEY structure.
my $rv = Net::SSLeay::EVP_PKEY_new();
#
# returns: value corresponding to openssl's EVP_PKEY structure (0 on failure)
Check openssl doc L
=item * EVP_PKEY_free
B not available in Net-SSLeay-1.45 and before
Free an allocated EVP_PKEY structure.
Net::SSLeay::EVP_PKEY_free($pkey);
# $pkey - value corresponding to openssl's EVP_PKEY structure
#
# returns: no return value
Check openssl doc L
=item * EVP_PKEY_assign_RSA
B not available in Net-SSLeay-1.45 and before
Set the key referenced by $pkey to $key
B In accordance with the OpenSSL naming convention the $key assigned
to the $pkey using the "1" functions must be freed as well as $pkey.
my $rv = Net::SSLeay::EVP_PKEY_assign_RSA($pkey, $key);
# $pkey - value corresponding to openssl's EVP_PKEY structure
# $key - value corresponding to openssl's RSA structure
#
# returns: 1 on success, 0 on failure
Check openssl doc L
=item * EVP_PKEY_bits
B not available in Net-SSLeay-1.45 and before
Returns the size of the key $pkey in bits.
my $rv = Net::SSLeay::EVP_PKEY_bits($pkey);
# $pkey - value corresponding to openssl's EVP_PKEY structure
#
# returns: size in bits
=item * EVP_PKEY_size
B not available in Net-SSLeay-1.45 and before
Returns the maximum size of a signature in bytes. The actual signature may be smaller.
my $rv = Net::SSLeay::EVP_PKEY_size($pkey);
# $pkey - value corresponding to openssl's EVP_PKEY structure
#
# returns: the maximum size in bytes
Check openssl doc L
=item * EVP_PKEY_id
B not available in Net-SSLeay-1.45 and before; requires at least openssl-1.0.0
Returns $pkey type (integer value of corresponding NID).
my $rv = Net::SSLeay::EVP_PKEY_id($pkey);
# $pkey - value corresponding to openssl's EVP_PKEY structure
#
# returns: (integer) key type
Example:
my $pubkey = Net::SSLeay::X509_get_pubkey($x509);
my $type = Net::SSLeay::EVP_PKEY_id($pubkey);
print Net::SSLeay::OBJ_nid2sn($type); #prints e.g. 'rsaEncryption'
=back
=head3 Low level API: PEM_* related functions
Check openssl doc L
=over
=item * PEM_read_bio_X509
B not available in Net-SSLeay-1.45 and before
Loads PEM formated X509 certificate via given BIO structure.
my $rv = Net::SSLeay::PEM_read_bio_X509($bio);
# $bio - value corresponding to openssl's BIO structure
#
# returns: value corresponding to openssl's X509 structure (0 on failure)
Example:
my $bio = Net::SSLeay::BIO_new_file($filename, 'r');
my $x509 = Net::SSLeay::PEM_read_bio_X509($bio);
Net::SSLeay::BIO_free($bio);
=item * PEM_read_bio_X509_REQ
B not available in Net-SSLeay-1.45 and before
Loads PEM formated X509_REQ object via given BIO structure.
my $rv = Net::SSLeay::PEM_read_bio_X509_REQ($bio, $x=NULL, $cb=NULL, $u=NULL);
# $bio - value corresponding to openssl's BIO structure
#
# returns: value corresponding to openssl's X509_REQ structure (0 on failure)
Example:
my $bio = Net::SSLeay::BIO_new_file($filename, 'r');
my $x509_req = Net::SSLeay::PEM_read_bio_X509_REQ($bio);
Net::SSLeay::BIO_free($bio);
=item * PEM_read_bio_DHparams
Reads DH structure from BIO.
my $rv = Net::SSLeay::PEM_read_bio_DHparams($bio);
# $bio - value corresponding to openssl's BIO structure
#
# returns: value corresponding to openssl's DH structure (0 on failure)
=item * PEM_read_bio_X509_CRL
Reads X509_CRL structure from BIO.
my $rv = Net::SSLeay::PEM_read_bio_X509_CRL($bio);
# $bio - value corresponding to openssl's BIO structure
#
# returns: value corresponding to openssl's X509_CRL structure (0 on failure)
=item * PEM_read_bio_PrivateKey
B not available in Net-SSLeay-1.45 and before
Loads PEM formated private key via given BIO structure.
my $rv = Net::SSLeay::PEM_read_bio_PrivateKey($bio, $cb, $data);
# $bio - value corresponding to openssl's BIO structure
# $cb - reference to perl callback function
# $data - data that will be passed to callback function (see examples below)
#
# returns: value corresponding to openssl's EVP_PKEY structure (0 on failure)
Example:
my $bio = Net::SSLeay::BIO_new_file($filename, 'r');
my $privkey = Net::SSLeay::PEM_read_bio_PrivateKey($bio); #ask for password if needed
Net::SSLeay::BIO_free($bio);
To use password you have the following options:
$privkey = Net::SSLeay::PEM_read_bio_PrivateKey($bio, \&callback_func); # use callback func for getting password
$privkey = Net::SSLeay::PEM_read_bio_PrivateKey($bio, \&callback_func, $data); # use callback_func + pass $data to callback_func
$privkey = Net::SSLeay::PEM_read_bio_PrivateKey($bio, undef, "secret"); # use password "secret"
$privkey = Net::SSLeay::PEM_read_bio_PrivateKey($bio, undef, ""); # use empty password
Callback function signature:
sub callback_func {
my ($max_passwd_size, $rwflag, $data) = @_;
# $max_passwd_size - maximum size of returned password (longer values will be discarded)
# $rwflag - indicates whether we are loading (0) or storing (1) - for PEM_read_bio_PrivateKey always 0
# $data - the data passed to PEM_read_bio_PrivateKey as 3rd parameter
return "secret";
}
=item * PEM_get_string_X509
B Does not exactly correspond to any low level API function
Converts/exports X509 certificate to string (PEM format).
Net::SSLeay::PEM_get_string_X509($x509);
# $x509 - value corresponding to openssl's X509 structure
#
# returns: string with $x509 in PEM format
=item * PEM_get_string_PrivateKey
B not available in Net-SSLeay-1.45 and before
Converts public key $pk into PEM formated string (optionally protected with password).
my $rv = Net::SSLeay::PEM_get_string_PrivateKey($pk, $passwd, $enc_alg);
# $pk - value corresponding to openssl's EVP_PKEY structure
# $passwd - [optional] (string) password to use for key encryption
# $enc_alg - [optional] algorithm to use for key encryption (default: DES_CBC) - value corresponding to openssl's EVP_CIPHER structure
#
# returns: PEM formated string
Examples:
$pem_privkey = Net::SSLeay::PEM_get_string_PrivateKey($pk);
$pem_privkey = Net::SSLeay::PEM_get_string_PrivateKey($pk, "secret");
$pem_privkey = Net::SSLeay::PEM_get_string_PrivateKey($pk, "secret", Net::SSLeay::EVP_get_cipherbyname("DES-EDE3-CBC"));
=item * PEM_get_string_X509_CRL
B not available in Net-SSLeay-1.45 and before
Converts X509_CRL object $x509_crl into PEM formated string.
Net::SSLeay::PEM_get_string_X509_CRL($x509_crl);
# $x509_crl - value corresponding to openssl's X509_CRL structure
#
# returns: no return value
=item * PEM_get_string_X509_REQ
B not available in Net-SSLeay-1.45 and before
Converts X509_REQ object $x509_crl into PEM formated string.
Net::SSLeay::PEM_get_string_X509_REQ($x509_req);
# $x509_req - value corresponding to openssl's X509_REQ structure
#
# returns: no return value
=back
=head3 Low level API: d2i_* (DER format) related functions
=over
=item * d2i_X509_bio
B not available in Net-SSLeay-1.45 and before
Loads DER formated X509 certificate via given BIO structure.
my $rv = Net::SSLeay::d2i_X509_bio($bp);
# $bp - value corresponding to openssl's BIO structure
#
# returns: value corresponding to openssl's X509 structure (0 on failure)
Example:
my $bio = Net::SSLeay::BIO_new_file($filename, 'rb');
my $x509 = Net::SSLeay::d2i_X509_bio($bio);
Net::SSLeay::BIO_free($bio);
Check openssl doc L
=item * d2i_X509_CRL_bio
B not available in Net-SSLeay-1.45 and before
Loads DER formated X509_CRL object via given BIO structure.
my $rv = Net::SSLeay::d2i_X509_CRL_bio($bp);
# $bp - value corresponding to openssl's BIO structure
#
# returns: value corresponding to openssl's X509_CRL structure (0 on failure)
Example:
my $bio = Net::SSLeay::BIO_new_file($filename, 'rb');
my $x509_crl = Net::SSLeay::d2i_X509_CRL_bio($bio);
Net::SSLeay::BIO_free($bio);
=item * d2i_X509_REQ_bio
B not available in Net-SSLeay-1.45 and before
Loads DER formated X509_REQ object via given BIO structure.
my $rv = Net::SSLeay::d2i_X509_REQ_bio($bp);
# $bp - value corresponding to openssl's BIO structure
#
# returns: value corresponding to openssl's X509_REQ structure (0 on failure)
Example:
my $bio = Net::SSLeay::BIO_new_file($filename, 'rb');
my $x509_req = Net::SSLeay::d2i_X509_REQ_bio($bio);
Net::SSLeay::BIO_free($bio);
=back
=head3 Low level API: PKCS12 related functions
=over
=item * P_PKCS12_load_file
B not available in Net-SSLeay-1.45 and before
Loads X509 certificate + private key + certificates of CA chain (if present in PKCS12 file).
my ($privkey, $cert, @cachain) = Net::SSLeay::P_PKCS12_load_file($filename, $load_chain, $password);
# $filename - name of PKCS12 file
# $load_chain - [optional] whether load (1) or not(0) CA chain (default: 0)
# $password - [optional] password for private key
#
# returns: triplet ($privkey, $cert, @cachain)
# $privkey - value corresponding to openssl's EVP_PKEY structure
# $cert - value corresponding to openssl's X509 structure
# @cachain - array of values corresponding to openssl's X509 structure (empty if no CA chain in PKCS12)
B after you do the job you need to call X509_free() on $privkey + all members
of @cachain and EVP_PKEY_free() on $privkey.
Examples:
my ($privkey, $cert) = Net::SSLeay::P_PKCS12_load_file($filename);
#or
my ($privkey, $cert) = Net::SSLeay::P_PKCS12_load_file($filename, 0, $password);
#or
my ($privkey, $cert, @cachain) = Net::SSLeay::P_PKCS12_load_file($filename, 1);
#or
my ($privkey, $cert, @cachain) = Net::SSLeay::P_PKCS12_load_file($filename, 1, $password);
#BEWARE: THIS IS WRONG - MEMORY LEAKS! (you cannot free @cachain items)
my ($privkey, $cert) = Net::SSLeay::P_PKCS12_load_file($filename, 1, $password);
=back
=head3 Low level API: SESSION_* related functions
=over
=item * d2i_SSL_SESSION
Transforms the external ASN1 representation of an SSL/TLS session, stored as binary data
at location pp with length length, into an SSL_SESSION object.
??? (does this function really work?)
my $rv = Net::SSLeay::d2i_SSL_SESSION($a, $pp, $length);
# $a - value corresponding to openssl's SSL_SESSION structure
# $pp - pointer/buffer ???
# $length - ???
#
# returns: ???
Check openssl doc L
=item * i2d_SSL_SESSION
Transforms the SSL_SESSION object in into the ASN1 representation and stores it
into the memory location pointed to by pp. The length of the resulting ASN1
representation is returned.
??? (does this function really work?)
my $rv = Net::SSLeay::i2d_SSL_SESSION($in, $pp);
# $in - value corresponding to openssl's SSL_SESSION structure
# $pp - pointer/data ???
#
# returns: 1 on success, 0
Check openssl doc L
=item * SESSION_new
Creates a new SSL_SESSION structure.
my $rv = Net::SSLeay::SESSION_new();
#
# returns: value corresponding to openssl's SSL_SESSION structure (0 on failure)
=item * SESSION_free
Free an allocated SSL_SESSION structure.
Net::SSLeay::SESSION_free($ses);
# $ses - value corresponding to openssl's SSL_SESSION structure
#
# returns: no return value
Check openssl doc L
=item * SESSION_cmp
Compare two SSL_SESSION structures.
my $rv = Net::SSLeay::SESSION_cmp($sesa, $sesb);
# $sesa - value corresponding to openssl's SSL_SESSION structure
# $sesb - value corresponding to openssl's SSL_SESSION structure
#
# returns: 0 if the two structures are the same
B Not available in openssl 1.0 or later
=item * SESSION_get_app_data
Can be used to get application defined value/data.
my $rv = Net::SSLeay::SESSION_get_app_data($ses);
# $ses - value corresponding to openssl's SSL_SESSION structure
#
# returns: string/buffer/pointer ???
=item * SESSION_set_app_data
Can be used to set some application defined value/data.
my $rv = Net::SSLeay::SESSION_set_app_data($s, $a);
# $s - value corresponding to openssl's SSL_SESSION structure
# $a - (string/buffer/pointer ???) data
#
# returns: ???
=item * SESSION_get_ex_data
Is used to retrieve the information for $idx from session $ses.
my $rv = Net::SSLeay::SESSION_get_ex_data($ses, $idx);
# $ses - value corresponding to openssl's SSL_SESSION structure
# $idx - (integer) index for application specific data
#
# returns: pointer to ???
Check openssl doc L
=item * SESSION_set_ex_data
Is used to store application data at arg for idx into the session object.
my $rv = Net::SSLeay::SESSION_set_ex_data($ss, $idx, $data);
# $ss - value corresponding to openssl's SSL_SESSION structure
# $idx - (integer) ???
# $data - (pointer) ???
#
# returns: 1 on success, 0 on failure
Check openssl doc L
=item * SESSION_get_ex_new_index
Is used to register a new index for application specific data.
my $rv = Net::SSLeay::SESSION_get_ex_new_index($argl, $argp, $new_func, $dup_func, $free_func);
# $argl - (long) ???
# $argp - (pointer) ???
# $new_func - function pointer ??? (CRYPTO_EX_new *)
# $dup_func - function pointer ??? (CRYPTO_EX_dup *)
# $free_func - function pointer ??? (CRYPTO_EX_free *)
#
# returns: (integer) ???
Check openssl doc L
=item * SESSION_get_master_key
B Does not exactly correspond to any low level API function
Returns 'master_key' value from SSL_SESSION structure $s
Net::SSLeay::SESSION_get_master_key($s);
# $s - value corresponding to openssl's SSL_SESSION structure
#
# returns: master key (binary data)
=item * SESSION_set_master_key
Sets 'master_key' value for SSL_SESSION structure $s
Net::SSLeay::SESSION_set_master_key($s, $key);
# $s - value corresponding to openssl's SSL_SESSION structure
# $key - master key (binary data)
#
# returns: no return value
=item * SESSION_get_time
Returns the time at which the session s was established.
The time is given in seconds since 1.1.1970.
my $rv = Net::SSLeay::SESSION_get_time($s);
# $s - value corresponding to openssl's SSL_SESSION structure
#
# returns: timestamp (seconds since 1.1.1970)
Check openssl doc L
=item * get_time
Technically the same functionality as L.
my $rv = Net::SSLeay::get_time($s);
=item * SESSION_get_timeout
Returns the timeout value set for session $s in seconds.
my $rv = Net::SSLeay::SESSION_get_timeout($s);
# $s - value corresponding to openssl's SSL_SESSION structure
#
# returns: timeout (in seconds)
Check openssl doc L
=item * get_timeout
Technically the same functionality as L.
my $rv = Net::SSLeay::get_timeout($s);
=item * SESSION_print
B Does not exactly correspond to any low level API function
Prints session details (e.g. protocol version, ciprher, session-id ...) to BIO.
my $rv = Net::SSLeay::SESSION_print($fp, $ses);
# $fp - value corresponding to openssl's BIO structure
# $ses - value corresponding to openssl's SSL_SESSION structure
#
# returns: 1 on success, 0 on failure
You have to use necessary BIO functions like this:
# let us have $ssl corresponding to openssl's SSL structure
my $ses = Net::SSLeay::get_session($ssl);
my $bio = Net::SSLeay::BIO_new(&Net::SSLeay::BIO_s_mem);
Net::SSLeay::SESSION_print($bio, $ses);
print Net::SSLeay::BIO_read($bio);
=item * SESSION_print_fp
Prints session details (e.g. protocol version, ciprher, session-id ...) to file handle.
my $rv = Net::SSLeay::SESSION_print_fp($fp, $ses);
# $fp - perl file handle
# $ses - value corresponding to openssl's SSL_SESSION structure
#
# returns: 1 on success, 0 on failure
Example:
# let us have $ssl corresponding to openssl's SSL structure
my $ses = Net::SSLeay::get_session($ssl);
open my $fh, ">", "output.txt";
Net::SSLeay::SESSION_print_fp($fh,$ses);
=item * SESSION_set_time
Replaces the creation time of the session s with the chosen value $t (seconds since 1.1.1970).
my $rv = Net::SSLeay::SESSION_set_time($ses, $t);
# $ses - value corresponding to openssl's SSL_SESSION structure
# $t - time value
#
# returns: 1 on success
Check openssl doc L
=item * set_time
Technically the same functionality as L.
my $rv = Net::SSLeay::set_time($ses, $t);
=item * SESSION_set_timeout
Sets the timeout value for session s in seconds to $t.
my $rv = Net::SSLeay::SESSION_set_timeout($s, $t);
# $s - value corresponding to openssl's SSL_SESSION structure
# $t - timeout (in seconds)
#
# returns: 1 on success
Check openssl doc L
=item * set_timeout
Technically the same functionality as L.
my $rv = Net::SSLeay::set_timeout($ses, $t);
=back
=head3 Low level API: SSL_CTX_* related functions
B Please note that the function described in this chapter have "SSL_" part stripped from their original openssl names.
=over
=item * CTX_add_client_CA
Adds the CA name extracted from $cacert to the list of CAs sent to the client when requesting a client certificate for $ctx.
my $rv = Net::SSLeay::CTX_add_client_CA($ctx, $cacert);
# $ctx - value corresponding to openssl's SSL_CTX structure
# $cacert - value corresponding to openssl's X509 structure
#
# returns: 1 on success, 0 on failure
Check openssl doc L
=item * CTX_add_extra_chain_cert
Adds the certificate $x509 to the certificate chain presented together with the certificate. Several certificates can be added one after the other.
my $rv = Net::SSLeay::CTX_add_extra_chain_cert($ctx, $x509);
# $ctx - value corresponding to openssl's SSL_CTX structure
# $x509 - value corresponding to openssl's X509 structure
#
# returns: 1 on success, check out the error stack to find out the reason for failure otherwise
Check openssl doc L
=item * CTX_add_session
Adds the session $ses to the context $ctx.
my $rv = Net::SSLeay::CTX_add_session($ctx, $ses);
# $ctx - value corresponding to openssl's SSL_CTX structure
# $ses - value corresponding to openssl's SSL_SESSION structure
#
# returns: 1 on success, 0 on failure
Check openssl doc L
=item * CTX_callback_ctrl
??? (more info needed)
my $rv = Net::SSLeay::CTX_callback_ctrl($ctx, $cmd, $fp);
# $ctx - value corresponding to openssl's SSL_CTX structure
# $cmd - (integer) command id
# $fp - (function pointer) ???
#
# returns: ???
Check openssl doc L
=item * CTX_check_private_key
Checks the consistency of a private key with the corresponding certificate loaded into $ctx.
my $rv = Net::SSLeay::CTX_check_private_key($ctx);
# $ctx - value corresponding to openssl's SSL_CTX structure
#
# returns: 1 on success, otherwise check out the error stack to find out the reason
Check openssl doc L
=item * CTX_ctrl
Internal handling function for SSL_CTX objects.
B openssl doc says: This function should never be called directly!
my $rv = Net::SSLeay::CTX_ctrl($ctx, $cmd, $larg, $parg);
# $ctx - value corresponding to openssl's SSL_CTX structure
# $cmd - (integer) command id
# $larg - (integer) long ???
# $parg - (string/pointer) ???
#
# returns: (long) result of given command ???
#valid $cmd values
1 - SSL_CTRL_NEED_TMP_RSA
2 - SSL_CTRL_SET_TMP_RSA
3 - SSL_CTRL_SET_TMP_DH
4 - SSL_CTRL_SET_TMP_ECDH
5 - SSL_CTRL_SET_TMP_RSA_CB
6 - SSL_CTRL_SET_TMP_DH_CB
7 - SSL_CTRL_SET_TMP_ECDH_CB
8 - SSL_CTRL_GET_SESSION_REUSED
9 - SSL_CTRL_GET_CLIENT_CERT_REQUEST
10 - SSL_CTRL_GET_NUM_RENEGOTIATIONS
11 - SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS
12 - SSL_CTRL_GET_TOTAL_RENEGOTIATIONS
13 - SSL_CTRL_GET_FLAGS
14 - SSL_CTRL_EXTRA_CHAIN_CERT
15 - SSL_CTRL_SET_MSG_CALLBACK
16 - SSL_CTRL_SET_MSG_CALLBACK_ARG
17 - SSL_CTRL_SET_MTU
20 - SSL_CTRL_SESS_NUMBER
21 - SSL_CTRL_SESS_CONNECT
22 - SSL_CTRL_SESS_CONNECT_GOOD
23 - SSL_CTRL_SESS_CONNECT_RENEGOTIATE
24 - SSL_CTRL_SESS_ACCEPT
25 - SSL_CTRL_SESS_ACCEPT_GOOD
26 - SSL_CTRL_SESS_ACCEPT_RENEGOTIATE
27 - SSL_CTRL_SESS_HIT
28 - SSL_CTRL_SESS_CB_HIT
29 - SSL_CTRL_SESS_MISSES
30 - SSL_CTRL_SESS_TIMEOUTS
31 - SSL_CTRL_SESS_CACHE_FULL
32 - SSL_CTRL_OPTIONS
33 - SSL_CTRL_MODE
40 - SSL_CTRL_GET_READ_AHEAD
41 - SSL_CTRL_SET_READ_AHEAD
42 - SSL_CTRL_SET_SESS_CACHE_SIZE
43 - SSL_CTRL_GET_SESS_CACHE_SIZE
44 - SSL_CTRL_SET_SESS_CACHE_MODE
45 - SSL_CTRL_GET_SESS_CACHE_MODE
50 - SSL_CTRL_GET_MAX_CERT_LIST
51 - SSL_CTRL_SET_MAX_CERT_LIST
52 - SSL_CTRL_SET_MAX_SEND_FRAGMENT
53 - SSL_CTRL_SET_TLSEXT_SERVERNAME_CB
54 - SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG
55 - SSL_CTRL_SET_TLSEXT_HOSTNAME
56 - SSL_CTRL_SET_TLSEXT_DEBUG_CB
57 - SSL_CTRL_SET_TLSEXT_DEBUG_ARG
58 - SSL_CTRL_GET_TLSEXT_TICKET_KEYS
59 - SSL_CTRL_SET_TLSEXT_TICKET_KEYS
60 - SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT
61 - SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB
62 - SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB_ARG
63 - SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB
64 - SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG
65 - SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE
66 - SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS
67 - SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS
68 - SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS
69 - SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS
70 - SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP
71 - SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP
72 - SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB
73 - DTLS_CTRL_GET_TIMEOUT
74 - DTLS_CTRL_HANDLE_TIMEOUT
75 - DTLS_CTRL_LISTEN
76 - SSL_CTRL_GET_RI_SUPPORT
77 - SSL_CTRL_CLEAR_OPTIONS
78 - SSL_CTRL_CLEAR_MODE
82 - SSL_CTRL_GET_EXTRA_CHAIN_CERTS
83 - SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS
88 - SSL_CTRL_CHAIN
89 - SSL_CTRL_CHAIN_CERT
90 - SSL_CTRL_GET_CURVES
91 - SSL_CTRL_SET_CURVES
92 - SSL_CTRL_SET_CURVES_LIST
93 - SSL_CTRL_GET_SHARED_CURVE
94 - SSL_CTRL_SET_ECDH_AUTO
97 - SSL_CTRL_SET_SIGALGS
98 - SSL_CTRL_SET_SIGALGS_LIST
99 - SSL_CTRL_CERT_FLAGS
100 - SSL_CTRL_CLEAR_CERT_FLAGS
101 - SSL_CTRL_SET_CLIENT_SIGALGS
102 - SSL_CTRL_SET_CLIENT_SIGALGS_LIST
103 - SSL_CTRL_GET_CLIENT_CERT_TYPES
104 - SSL_CTRL_SET_CLIENT_CERT_TYPES
105 - SSL_CTRL_BUILD_CERT_CHAIN
106 - SSL_CTRL_SET_VERIFY_CERT_STORE
107 - SSL_CTRL_SET_CHAIN_CERT_STORE
108 - SSL_CTRL_GET_PEER_SIGNATURE_NID
109 - SSL_CTRL_GET_SERVER_TMP_KEY
110 - SSL_CTRL_GET_RAW_CIPHERLIST
111 - SSL_CTRL_GET_EC_POINT_FORMATS
112 - SSL_CTRL_GET_TLSA_RECORD
113 - SSL_CTRL_SET_TLSA_RECORD
114 - SSL_CTRL_PULL_TLSA_RECORD
Check openssl doc L
=item * CTX_flush_sessions
Causes a run through the session cache of $ctx to remove sessions expired at time $tm.
Net::SSLeay::CTX_flush_sessions($ctx, $tm);
# $ctx - value corresponding to openssl's SSL_CTX structure
# $tm - specifies the time which should be used for the expiration test (seconds since 1.1.1970)
#
# returns: no return value
Check openssl doc L
=item * CTX_free
Free an allocated SSL_CTX object.
Net::SSLeay::CTX_free($ctx);
# $ctx - value corresponding to openssl's SSL_CTX structure
#
# returns: no return value
Check openssl doc L
=item * CTX_get_app_data
Can be used to get application defined value/data.
my $rv = Net::SSLeay::CTX_get_app_data($ctx);
# $ctx - value corresponding to openssl's SSL_CTX structure
#
# returns: string/buffer/pointer ???
=item * CTX_set_app_data
Can be used to set some application defined value/data.
my $rv = Net::SSLeay::CTX_set_app_data($ctx, $arg);
# $ctx - value corresponding to openssl's SSL_CTX structure
# $arg - (string/buffer/pointer ???) data
#
# returns: ???
=item * CTX_get_cert_store
Returns the current certificate verification storage.
my $rv = Net::SSLeay::CTX_get_cert_store($ctx);
# $ctx - value corresponding to openssl's SSL_CTX structure
#
# returns: value corresponding to openssl's X509_STORE structure (0 on failure)
Check openssl doc L
=item * CTX_get_client_CA_list
Returns the list of client CAs explicitly set for $ctx using L.
my $rv = Net::SSLeay::CTX_get_client_CA_list($ctx);
# $ctx - value corresponding to openssl's SSL_CTX structure
#
# returns: value corresponding to openssl's X509_NAME_STACK structure (0 on failure)
Check openssl doc L
=item * CTX_get_ex_data
Is used to retrieve the information for index $idx from $ctx.
my $rv = Net::SSLeay::CTX_get_ex_data($ssl, $idx);
# $ssl - value corresponding to openssl's SSL_CTX structure
# $idx - (integer) index for application specific data
#
# returns: pointer to ???
Check openssl doc L
=item * CTX_get_ex_new_index
Is used to register a new index for application specific data.
my $rv = Net::SSLeay::CTX_get_ex_new_index($argl, $argp, $new_func, $dup_func, $free_func);
# $argl - (long) ???
# $argp - (pointer) ???
# $new_func - function pointer ??? (CRYPTO_EX_new *)
# $dup_func - function pointer ??? (CRYPTO_EX_dup *)
# $free_func - function pointer ??? (CRYPTO_EX_free *)
#
# returns: (integer) ???
Check openssl doc L
=item * CTX_get_mode
Returns the mode set for ctx.
my $rv = Net::SSLeay::CTX_get_mode($ctx);
# $ctx - value corresponding to openssl's SSL_CTX structure
#
# returns: mode (bitmask)
#to decode the return value (bitmask) use:
0x00000001 corresponds to SSL_MODE_ENABLE_PARTIAL_WRITE
0x00000002 corresponds to SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER
0x00000004 corresponds to SSL_MODE_AUTO_RETRY
0x00000008 corresponds to SSL_MODE_NO_AUTO_CHAIN
0x00000010 corresponds to SSL_MODE_RELEASE_BUFFERS
(note: some of the bits might not be supported by older openssl versions)
Check openssl doc L
=item * CTX_set_mode
Adds the mode set via bitmask in $mode to $ctx. Options already set before are not cleared.
my $rv = Net::SSLeay::CTX_set_mode($ctx, $mode);
# $ctx - value corresponding to openssl's SSL_CTX structure
# $mode - mode bitmask
#
# returns: the new mode bitmask after adding $mode
For bitmask details see L (above).
Check openssl doc L
=item * CTX_get_options
Returns the options (bitmask) set for $ctx.
my $rv = Net::SSLeay::CTX_get_options($ctx);
# $ctx - value corresponding to openssl's SSL_CTX structure
#
# returns: options (bitmask)
#to decode the return value (bitmask) use:
0x00000001 corresponds to SSL_OP_MICROSOFT_SESS_ID_BUG
0x00000002 corresponds to SSL_OP_NETSCAPE_CHALLENGE_BUG
0x00000004 corresponds to SSL_OP_LEGACY_SERVER_CONNECT
0x00000008 corresponds to SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG
0x00000010 corresponds to SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG
0x00000020 corresponds to SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER
0x00000040 corresponds to SSL_OP_MSIE_SSLV2_RSA_PADDING
0x00000080 corresponds to SSL_OP_SSLEAY_080_CLIENT_DH_BUG
0x00000100 corresponds to SSL_OP_TLS_D5_BUG
0x00000200 corresponds to SSL_OP_TLS_BLOCK_PADDING_BUG
0x00000800 corresponds to SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS
0x80000FFF corresponds to SSL_OP_ALL
0x00001000 corresponds to SSL_OP_NO_QUERY_MTU
0x00002000 corresponds to SSL_OP_COOKIE_EXCHANGE
0x00004000 corresponds to SSL_OP_NO_TICKET
0x00008000 corresponds to SSL_OP_CISCO_ANYCONNECT
0x00010000 corresponds to SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION
0x00020000 corresponds to SSL_OP_NO_COMPRESSION
0x00040000 corresponds to SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION
0x00080000 corresponds to SSL_OP_SINGLE_ECDH_USE
0x00100000 corresponds to SSL_OP_SINGLE_DH_USE
0x00200000 corresponds to SSL_OP_EPHEMERAL_RSA
0x00400000 corresponds to SSL_OP_CIPHER_SERVER_PREFERENCE
0x00800000 corresponds to SSL_OP_TLS_ROLLBACK_BUG
0x01000000 corresponds to SSL_OP_NO_SSLv2
0x02000000 corresponds to SSL_OP_NO_SSLv3
0x04000000 corresponds to SSL_OP_NO_TLSv1
0x08000000 corresponds to SSL_OP_PKCS1_CHECK_1
0x10000000 corresponds to SSL_OP_PKCS1_CHECK_2
0x20000000 corresponds to SSL_OP_NETSCAPE_CA_DN_BUG
0x40000000 corresponds to SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG
0x80000000 corresponds to SSL_OP_CRYPTOPRO_TLSEXT_BUG
(note: some of the bits might not be supported by older openssl versions)
Check openssl doc L
=item * CTX_set_options
Adds the options set via bitmask in $options to ctx. Options already set before are not cleared.
Net::SSLeay::CTX_set_options($ctx, $options);
# $ctx - value corresponding to openssl's SSL_CTX structure
# $options - options bitmask
#
# returns: the new options bitmask after adding $options
For bitmask details see L (above).
Check openssl doc L
=item * CTX_get_quiet_shutdown
Returns the 'quiet shutdown' setting of $ctx.
my $rv = Net::SSLeay::CTX_get_quiet_shutdown($ctx);
# $ctx - value corresponding to openssl's SSL_CTX structure
#
# returns: (integer) the current setting
Check openssl doc L
=item * CTX_get_read_ahead
my $rv = Net::SSLeay::CTX_get_read_ahead($ctx);
# $ctx - value corresponding to openssl's SSL_CTX structure
#
# returns: (integer) read_ahead value
=item * CTX_get_session_cache_mode
Returns the currently used cache mode (bitmask).
my $rv = Net::SSLeay::CTX_get_session_cache_mode($ctx);
# $ctx - value corresponding to openssl's SSL_CTX structure
#
# returns: mode (bitmask)
#to decode the return value (bitmask) use:
0x0000 corresponds to SSL_SESS_CACHE_OFF
0x0001 corresponds to SSL_SESS_CACHE_CLIENT
0x0002 corresponds to SSL_SESS_CACHE_SERVER
0x0080 corresponds to SSL_SESS_CACHE_NO_AUTO_CLEAR
0x0100 corresponds to SSL_SESS_CACHE_NO_INTERNAL_LOOKUP
0x0200 corresponds to SSL_SESS_CACHE_NO_INTERNAL_STORE
(note: some of the bits might not be supported by older openssl versions)
Check openssl doc L
=item * CTX_set_session_cache_mode
Enables/disables session caching by setting the operational mode for $ctx to $mode.
my $rv = Net::SSLeay::CTX_set_session_cache_mode($ctx, $mode);
# $ctx - value corresponding to openssl's SSL_CTX structure
# $mode - mode (bitmask)
#
# returns: previously set cache mode
For bitmask details see L (above).
Check openssl doc L
=item * CTX_get_timeout
Returns the currently set timeout value for $ctx.
my $rv = Net::SSLeay::CTX_get_timeout($ctx);
# $ctx - value corresponding to openssl's SSL_CTX structure
#
# returns: timeout in seconds
Check openssl doc L
=item * CTX_get_verify_depth
Returns the verification depth limit currently set in $ctx. If no limit has been explicitly set, -1 is returned and the default value will be used.",
my $rv = Net::SSLeay::CTX_get_verify_depth($ctx);
# $ctx - value corresponding to openssl's SSL_CTX structure
#
# returns: depth limit currently set in $ctx, -1 if no limit has been explicitly set
Check openssl doc L
=item * CTX_get_verify_mode
Returns the verification mode (bitmask) currently set in $ctx.
my $rv = Net::SSLeay::CTX_get_verify_mode($ctx);
# $ctx - value corresponding to openssl's SSL_CTX structure
#
# returns: mode (bitmask)
#to decode the return value (bitmask) use:
0x00 corresponds to SSL_VERIFY_NONE
0x01 corresponds to SSL_VERIFY_PEER
0x02 corresponds to SSL_VERIFY_FAIL_IF_NO_PEER_CERT
0x04 corresponds to SSL_VERIFY_CLIENT_ONCE
(note: some of the bits might not be supported by older openssl versions)
Check openssl doc L
=item * CTX_set_verify
Sets the verification flags for $ctx to be $mode and specifies the verify_callback function to be used.
Net::SSLeay::CTX_set_verify($ctx, $mode, $callback);
# $ctx - value corresponding to openssl's SSL_CTX structure
# $mode - mode (bitmask)
# $callback - [optional] reference to perl callback function
#
# returns: no return value
For bitmask details see L (above).
Check openssl doc L
=item * CTX_load_verify_locations
Specifies the locations for $ctx, at which CA certificates for verification purposes are located. The certificates available via $CAfile and $CApath are trusted.
my $rv = Net::SSLeay::CTX_load_verify_locations($ctx, $CAfile, $CApath);
# $ctx - value corresponding to openssl's SSL_CTX structure
# $CAfile - (string) file of CA certificates in PEM format, the file can contain several CA certificates (or '')
# $CApath - (string) directory containing CA certificates in PEM format (or '')
#
# returns: 1 on success, 0 on failure (check the error stack to find out the reason)
Check openssl doc L
=item * CTX_need_tmp_RSA
Return the result of C
my $rv = Net::SSLeay::CTX_need_tmp_RSA($ctx);
# $ctx - value corresponding to openssl's SSL_CTX structure
#
# returns: result of SSL_CTRL_NEED_TMP_RSA command
=item * CTX_new
The same as L
my $rv = Net::SSLeay::CTX_new();
#
# returns: value corresponding to openssl's SSL_CTX structure (0 on failure)
Check openssl doc L
=item * CTX_v2_new
Creates a new SSL_CTX object - based on SSLv2_method() - as framework to establish TLS/SSL enabled connections.
my $rv = Net::SSLeay::CTX_v2_new();
#
# returns: value corresponding to openssl's SSL_CTX structure (0 on failure)
=item * CTX_v23_new
Creates a new SSL_CTX object - based on SSLv23_method() - as framework to establish TLS/SSL enabled connections.
my $rv = Net::SSLeay::CTX_v23_new();
#
# returns: value corresponding to openssl's SSL_CTX structure (0 on failure)
=item * CTX_v3_new
Creates a new SSL_CTX object - based on SSLv3_method() - as framework to establish TLS/SSL enabled connections.
my $rv = Net::SSLeay::CTX_v3_new();
#
# returns: value corresponding to openssl's SSL_CTX structure (0 on failure)
=item * CTX_tlsv1_new
Creates a new SSL_CTX object - based on TLSv1_method() - as framework to establish TLS/SSL enabled connections.
my $rv = Net::SSLeay::CTX_tlsv1_new();
#
# returns: value corresponding to openssl's SSL_CTX structure (0 on failure)
=item * CTX_tlsv1_1_new
Creates a new SSL_CTX object - based on TLSv1_1_method() - as framework to establish TLS/SSL
enabled connections. Only available where supported by the underlying openssl.
my $rv = Net::SSLeay::CTX_tlsv1_1_new();
#
# returns: value corresponding to openssl's SSL_CTX structure (0 on failure)
=item * CTX_tlsv1_2_new
Creates a new SSL_CTX object - based on TLSv1_2_method() - as framework to establish TLS/SSL
enabled connections. Only available where supported by the underlying openssl.
my $rv = Net::SSLeay::CTX_tlsv1_2_new();
#
# returns: value corresponding to openssl's SSL_CTX structure (0 on failure)
=item * CTX_new_with_method
Creates a new SSL_CTX object based on $meth method
my $rv = Net::SSLeay::CTX_new_with_method($meth);
# $meth - value corresponding to openssl's SSL_METHOD structure
#
# returns: value corresponding to openssl's SSL_CTX structure (0 on failure)
#example
my $ctx = Net::SSLeay::CTX_new_with_method(&Net::SSLeay::TLSv1_method);
Check openssl doc L
=item * CTX_remove_session
Removes the session $ses from the context $ctx.
my $rv = Net::SSLeay::CTX_remove_session($ctx, $ses);
# $ctx - value corresponding to openssl's SSL_CTX structure
# $ses - value corresponding to openssl's SSL_SESSION structure
#
# returns: 1 on success, 0 on failure
Check openssl doc L
=item * CTX_sess_accept
my $rv = Net::SSLeay::CTX_sess_accept($ctx);
# $ctx - value corresponding to openssl's SSL_CTX structure
#
# returns: number of started SSL/TLS handshakes in server mode
Check openssl doc L
=item * CTX_sess_accept_good
my $rv = Net::SSLeay::CTX_sess_accept_good($ctx);
# $ctx - value corresponding to openssl's SSL_CTX structure
#
# returns: number of successfully established SSL/TLS sessions in server mode
Check openssl doc L
=item * CTX_sess_accept_renegotiate
my $rv = Net::SSLeay::CTX_sess_accept_renegotiate($ctx);
# $ctx - value corresponding to openssl's SSL_CTX structure
#
# returns: number of start renegotiations in server mode
Check openssl doc L
=item * CTX_sess_cache_full
my $rv = Net::SSLeay::CTX_sess_cache_full($ctx);
# $ctx - value corresponding to openssl's SSL_CTX structure
#
# returns: number of sessions that were removed because the maximum session cache size was exceeded
Check openssl doc L
=item * CTX_sess_cb_hits
my $rv = Net::SSLeay::CTX_sess_cb_hits($ctx);
# $ctx - value corresponding to openssl's SSL_CTX structure
#
# returns: number of successfully retrieved sessions from the external session cache in server mode
Check openssl doc L
=item * CTX_sess_connect
my $rv = Net::SSLeay::CTX_sess_connect($ctx);
# $ctx - value corresponding to openssl's SSL_CTX structure
#
# returns: number of started SSL/TLS handshakes in client mode
Check openssl doc L
=item * CTX_sess_connect_good
my $rv = Net::SSLeay::CTX_sess_connect_good($ctx);
# $ctx - value corresponding to openssl's SSL_CTX structure
#
# returns: number of successfully established SSL/TLS sessions in client mode
Check openssl doc L
=item * CTX_sess_connect_renegotiate
my $rv = Net::SSLeay::CTX_sess_connect_renegotiate($ctx);
# $ctx - value corresponding to openssl's SSL_CTX structure
#
# returns: number of start renegotiations in client mode
Check openssl doc L
=item * CTX_sess_get_cache_size
Returns the currently valid session cache size.
my $rv = Net::SSLeay::CTX_sess_get_cache_size($ctx);
# $ctx - value corresponding to openssl's SSL_CTX structure
#
# returns: current size
Check openssl doc L
=item * CTX_sess_hits
my $rv = Net::SSLeay::CTX_sess_hits($ctx);
# $ctx - value corresponding to openssl's SSL_CTX structure
#
# returns: number of successfully reused sessions
Check openssl doc L
=item * CTX_sess_misses
my $rv = Net::SSLeay::CTX_sess_misses($ctx);
# $ctx - value corresponding to openssl's SSL_CTX structure
#
# returns: number of sessions proposed by clients that were not found in the internal session cache in server mode
Check openssl doc L
=item * CTX_sess_number
my $rv = Net::SSLeay::CTX_sess_number($ctx);
# $ctx - value corresponding to openssl's SSL_CTX structure
#
# returns: current number of sessions in the internal session cache
Check openssl doc L
=item * CTX_sess_set_cache_size
Sets the size of the internal session cache of context $ctx to $size.
Net::SSLeay::CTX_sess_set_cache_size($ctx, $size);
# $ctx - value corresponding to openssl's SSL_CTX structure
# $size - cache size (0 = unlimited)
#
# returns: previously valid size
Check openssl doc L
=item * CTX_sess_timeouts
Returns the number of sessions proposed by clients and either found in the internal or external session cache in
server mode, but that were invalid due to timeout. These sessions are not included in the SSL_CTX_sess_hits count.
my $rv = Net::SSLeay::CTX_sess_timeouts($ctx);
# $ctx - value corresponding to openssl's SSL_CTX structure
#
# returns: number of sessions
Check openssl doc L
=item * CTX_sessions
Returns a pointer to the lhash databases containing the internal session cache for ctx.
my $rv = Net::SSLeay::CTX_sessions($ctx);
# $ctx - value corresponding to openssl's SSL_CTX structure
#
# returns: value corresponding to openssl's LHASH structure (0 on failure)
Check openssl doc L
=item * CTX_set1_param
Applies X509 verification parameters $vpm on $ctx
my $rv = Net::SSLeay::CTX_set1_param($ctx, $vpm);
# $ctx - value corresponding to openssl's SSL_CTX structure
# $vpm - value corresponding to openssl's X509_VERIFY_PARAM structure
#
# returns: 1 on success, 0 on failure
=item * CTX_set_cert_store
Sets/replaces the certificate verification storage of $ctx to/with $store.
Net::SSLeay::CTX_set_cert_store($ctx, $store);
# $ctx - value corresponding to openssl's SSL_CTX structure
# $store - value corresponding to openssl's X509_STORE structure
#
# returns: no return value
Check openssl doc L
=item * CTX_set_cert_verify_callback
Sets the verification callback function for $ctx. SSL objects that are created from $ctx
inherit the setting valid at the time when C is called.
Net::SSLeay::CTX_set_cert_verify_callback($ctx, $func, $data);
# $ctx - value corresponding to openssl's SSL_CTX structure
# $func - perl reference to callback function
# $data - [optional] data that will be passed to callback function when invoked
#
# returns: no return value
Check openssl doc L
=item * CTX_set_cipher_list
Sets the list of available ciphers for $ctx using the control string $str.
The list of ciphers is inherited by all ssl objects created from $ctx.
my $rv = Net::SSLeay::CTX_set_cipher_list($s, $str);
# $s - value corresponding to openssl's SSL_CTX structure
# $str - (string) cipher list e.g. '3DES:+RSA'
#
# returns: 1 if any cipher could be selected and 0 on complete failure
The format of $str is described in L
Check openssl doc L
=item * CTX_set_client_CA_list
Sets the list of CAs sent to the client when requesting a client certificate for $ctx.
Net::SSLeay::CTX_set_client_CA_list($ctx, $list);
# $ctx - value corresponding to openssl's SSL_CTX structure
# $list - value corresponding to openssl's X509_NAME_STACK structure
#
# returns: no return value
Check openssl doc L
=item * CTX_set_default_passwd_cb
Sets the default password callback called when loading/storing a PEM certificate with encryption.
Net::SSLeay::CTX_set_default_passwd_cb($ctx, $func);
# $ctx - value corresponding to openssl's SSL_CTX structure
# $func - perl reference to callback function
#
# returns: no return value
Check openssl doc L
=item * CTX_set_default_passwd_cb_userdata
Sets a pointer to userdata which will be provided to the password callback on invocation.
Net::SSLeay::CTX_set_default_passwd_cb_userdata($ctx, $userdata);
# $ctx - value corresponding to openssl's SSL_CTX structure
# $userdata - data that will be passed to callback function when invoked
#
# returns: no return value
Check openssl doc L
=item * CTX_set_default_verify_paths
??? (more info needed)
my $rv = Net::SSLeay::CTX_set_default_verify_paths($ctx);
# $ctx - value corresponding to openssl's SSL_CTX structure
#
# returns: 1 on success, 0 on failure
=item * CTX_set_ex_data
Is used to store application data at $data for $idx into the $ctx object.
my $rv = Net::SSLeay::CTX_set_ex_data($ssl, $idx, $data);
# $ssl - value corresponding to openssl's SSL_CTX structure
# $idx - (integer) ???
# $data - (pointer) ???
#
# returns: 1 on success, 0 on failure
Check openssl doc L
=item * CTX_set_purpose
my $rv = Net::SSLeay::CTX_set_purpose($s, $purpose);
# $s - value corresponding to openssl's SSL_CTX structure
# $purpose - (integer) purpose identifier
#
# returns: 1 on success, 0 on failure
#avainable purpose identifier
1 - X509_PURPOSE_SSL_CLIENT
2 - X509_PURPOSE_SSL_SERVER
3 - X509_PURPOSE_NS_SSL_SERVER
4 - X509_PURPOSE_SMIME_SIGN
5 - X509_PURPOSE_SMIME_ENCRYPT
6 - X509_PURPOSE_CRL_SIGN
7 - X509_PURPOSE_ANY
8 - X509_PURPOSE_OCSP_HELPER
9 - X509_PURPOSE_TIMESTAMP_SIGN
#or use corresponding constants
$purpose = &Net::SSLeay::X509_PURPOSE_SSL_CLIENT;
...
$purpose = &Net::SSLeay::X509_PURPOSE_TIMESTAMP_SIGN;
=item * CTX_set_quiet_shutdown
Sets the 'quiet shutdown' flag for $ctx to be mode. SSL objects created from $ctx inherit the mode valid at the time C is called.
Net::SSLeay::CTX_set_quiet_shutdown($ctx, $mode);
# $ctx - value corresponding to openssl's SSL_CTX structure
# $mode - 0 or 1
#
# returns: no return value
Check openssl doc L
=item * CTX_set_read_ahead
my $rv = Net::SSLeay::CTX_set_read_ahead($ctx, $val);
# $ctx - value corresponding to openssl's SSL_CTX structure
# $val - read_ahead value to be set
#
# returns: the original read_ahead value
=item * CTX_set_session_id_context
Sets the context $sid_ctx of length $sid_ctx_len within which a session can be reused for the $ctx object.
my $rv = Net::SSLeay::CTX_set_session_id_context($ctx, $sid_ctx, $sid_ctx_len);
# $ctx - value corresponding to openssl's SSL_CTX structure
# $sid_ctx - data buffer
# $sid_ctx_len - length of data in $sid_ctx
#
# returns: 1 on success, 0 on failure (the error is logged to the error stack)
Check openssl doc L
=item * CTX_set_ssl_version
Sets a new default TLS/SSL method for SSL objects newly created from this $ctx.
SSL objects already created with C are not
affected, except when C is being called.
my $rv = Net::SSLeay::CTX_set_ssl_version($ctx, $meth);
# $ctx - value corresponding to openssl's SSL_CTX structure
# $meth - value corresponding to openssl's SSL_METHOD structure
#
# returns: 1 on success, 0 on failure
Check openssl doc L
=item * CTX_set_timeout
Sets the timeout for newly created sessions for $ctx to $t. The timeout value $t must be given in seconds.
my $rv = Net::SSLeay::CTX_set_timeout($ctx, $t);
# $ctx - value corresponding to openssl's SSL_CTX structure
# $t - timeout in seconds
#
# returns: previously set timeout value
Check openssl doc L
=item * CTX_set_tmp_dh
Sets DH parameters to be used to be $dh. The key is inherited by all ssl objects created from $ctx.
my $rv = Net::SSLeay::CTX_set_tmp_dh($ctx, $dh);
# $ctx - value corresponding to openssl's SSL_CTX structure
# $dh - value corresponding to openssl's DH structure
#
# returns: 1 on success, 0 on failure
Check openssl doc L
=item * CTX_set_tmp_dh_callback
Sets the callback function for $ctx to be used when a DH parameters are required to $tmp_dh_callback.
Net::SSLeay::CTX_set_tmp_dh_callback($ctx, $tmp_dh_callback);
# $ctx - value corresponding to openssl's SSL_CTX structure
# tmp_dh_callback - (function pointer) ???
#
# returns: no return value
Check openssl doc L
=item * CTX_set_tmp_rsa
Sets the temporary/ephemeral RSA key to be used to be $rsa.
my $rv = Net::SSLeay::CTX_set_tmp_rsa($ctx, $rsa);
# $ctx - value corresponding to openssl's SSL_CTX structure
# $rsa - value corresponding to openssl's RSA structure
#
# returns: 1 on success, 0 on failure
Check openssl doc L
=item * CTX_set_tmp_rsa_callback
Sets the callback function for ctx to be used when a temporary/ephemeral RSA key is required to $tmp_rsa_callback.
??? (does this function really work?)
Net::SSLeay::CTX_set_tmp_rsa_callback($ctx, $tmp_rsa_callback);
# $ctx - value corresponding to openssl's SSL_CTX structure
# $tmp_rsa_callback - (function pointer) ???
#
# returns: no return value
Check openssl doc L
=item * CTX_set_trust
my $rv = Net::SSLeay::CTX_set_trust($s, $trust);
# $s - value corresponding to openssl's SSL_CTX structure
# $trust - (integer) trust identifier
#
# returns: the original value
#available trust identifiers
1 - X509_TRUST_COMPAT
2 - X509_TRUST_SSL_CLIENT
3 - X509_TRUST_SSL_SERVER
4 - X509_TRUST_EMAIL
5 - X509_TRUST_OBJECT_SIGN
6 - X509_TRUST_OCSP_SIGN
7 - X509_TRUST_OCSP_REQUEST
8 - X509_TRUST_TSA
#or use corresponding constants
$trust = &Net::SSLeay::X509_TRUST_COMPAT;
...
$trust = &Net::SSLeay::X509_TRUST_TSA;
=item * CTX_set_verify_depth
Sets the maximum depth for the certificate chain verification that shall be allowed for ctx.
Net::SSLeay::CTX_set_verify_depth($ctx, $depth);
# $ctx - value corresponding to openssl's SSL_CTX structure
# $depth - max. depth
#
# returns: no return value
Check openssl doc L
=item * CTX_use_PKCS12_file
Adds the certificate and private key from PKCS12 file $p12filename to $ctx.
my $rv = Net::SSLeay::CTX_use_PKCS12_file($ctx, $p12filename, $password);
# $ctx - value corresponding to openssl's SSL_CTX structure
# $p12filename - (string) filename
# $password - (string) password to decrypt private key
#
# returns: 1 on success, 0 on failure
=item * CTX_use_PrivateKey
Adds the private key $pkey to $ctx.
my $rv = Net::SSLeay::CTX_use_PrivateKey($ctx, $pkey);
# $ctx - value corresponding to openssl's SSL_CTX structure
# $pkey - value corresponding to openssl's EVP_PKEY structure
#
# returns: 1 on success, otherwise check out the error stack to find out the reason
Check openssl doc L
=item * CTX_use_PrivateKey_file
Adds the first private key found in $file to $ctx.
my $rv = Net::SSLeay::CTX_use_PrivateKey_file($ctx, $file, $type);
# $ctx - value corresponding to openssl's SSL_CTX structure
# $file - (string) file name
# $type - (integer) type - use constants &Net::SSLeay::FILETYPE_PEM or &Net::SSLeay::FILETYPE_ASN1
#
# returns: 1 on success, otherwise check out the error stack to find out the reason
Check openssl doc L
=item * CTX_use_RSAPrivateKey
Adds the RSA private key $rsa to $ctx.
my $rv = Net::SSLeay::CTX_use_RSAPrivateKey($ctx, $rsa);
# $ctx - value corresponding to openssl's SSL_CTX structure
# $rsa - value corresponding to openssl's RSA structure
#
# returns: 1 on success, otherwise check out the error stack to find out the reason
Check openssl doc L
=item * CTX_use_RSAPrivateKey_file
Adds the first RSA private key found in $file to $ctx.
my $rv = Net::SSLeay::CTX_use_RSAPrivateKey_file($ctx, $file, $type);
# $ctx - value corresponding to openssl's SSL_CTX structure
# $file - (string) file name
# $type - (integer) type - use constants &Net::SSLeay::FILETYPE_PEM or &Net::SSLeay::FILETYPE_ASN1
#
# returns: 1 on success, otherwise check out the error stack to find out the reason
=item * CTX_use_certificate
Loads the certificate $x into $ctx
my $rv = Net::SSLeay::CTX_use_certificate($ctx, $x);
# $ctx - value corresponding to openssl's SSL_CTX structure
# $x - value corresponding to openssl's X509 structure
#
# returns: 1 on success, otherwise check out the error stack to find out the reason
Check openssl doc L
=item * CTX_use_certificate_chain_file
Loads a certificate chain from $file into $ctx. The certificates must be in PEM format and must be sorted
starting with the subject's certificate (actual client or server certificate), followed by intermediate
CA certificates if applicable, and ending at the highest level (root) CA.
my $rv = Net::SSLeay::CTX_use_certificate_chain_file($ctx, $file);
# $ctx - value corresponding to openssl's SSL_CTX structure
# $file - (string) file name
#
# returns: 1 on success, otherwise check out the error stack to find out the reason
Check openssl doc L
=item * CTX_use_certificate_file
Loads the first certificate stored in $file into $ctx.
my $rv = Net::SSLeay::CTX_use_certificate_file($ctx, $file, $type);
# $ctx - value corresponding to openssl's SSL_CTX structure
# $file - (string) file name
# $type - (integer) type - use constants &Net::SSLeay::FILETYPE_PEM or &Net::SSLeay::FILETYPE_ASN1
#
# returns: 1 on success, otherwise check out the error stack to find out the reason
Check openssl doc L
=back
=head3 Low level API: SSL_* related functions
B Please note that the function described in this chapter have "SSL_" part stripped from their original openssl names.
=over
=item * new
Creates a new SSL structure which is needed to hold the data for a TLS/SSL connection.
The new structure inherits the settings of the underlying context $ctx: connection
method (SSLv2/v3/TLSv1), options, verification settings, timeout settings.
my $rv = Net::SSLeay::new($ctx);
# $ctx - value corresponding to openssl's SSL_CTX structure
#
# returns: value corresponding to openssl's SSL structure (0 on failure)
Check openssl doc L
=item * accept
Waits for a TLS/SSL client to initiate the TLS/SSL handshake. The communication
channel must already have been set and assigned to the ssl by setting an underlying BIO.
my $rv = Net::SSLeay::accept($ssl);
# $ssl - value corresponding to openssl's SSL structure
#
# returns: 1 = success, 0 = handshake not successfull, <0 = fatal error during handshake
Check openssl doc L
=item * add_client_CA
Adds the CA name extracted from cacert to the list of CAs sent to the client
when requesting a client certificate for the chosen ssl, overriding the setting
valid for ssl's SSL_CTX object.
my $rv = Net::SSLeay::add_client_CA($ssl, $x);
# $ssl - value corresponding to openssl's SSL structure
# $x - value corresponding to openssl's X509 structure
#
# returns: 1 on success, 0 on failure
Check openssl doc L
=item * callback_ctrl
??? (more info needed)
my $rv = Net::SSLeay::callback_ctrl($ssl, $cmd, $fp);
# $ssl - value corresponding to openssl's SSL structure
# $cmd - (integer) command id
# $fp - (function pointer) ???
#
# returns: ???
Check openssl doc L
=item * check_private_key
Checks the consistency of a private key with the corresponding certificate loaded into $ssl
my $rv = Net::SSLeay::check_private_key($ssl);
# $ssl - value corresponding to openssl's SSL structure
#
# returns: 1 on success, otherwise check out the error stack to find out the reason
Check openssl doc L
=item * clear
Reset SSL object to allow another connection.
Net::SSLeay::clear($ssl);
# $ssl - value corresponding to openssl's SSL structure
#
# returns: no return value
Check openssl doc L
=item * connect
Initiate the TLS/SSL handshake with an TLS/SSL server.
my $rv = Net::SSLeay::connect($ssl);
# $ssl - value corresponding to openssl's SSL structure
#
# returns: 1 = success, 0 = handshake not successfull, <0 = fatal error during handshake
Check openssl doc L
=item * copy_session_id
Copies the session structure fro $from to $to (+ also the private key and certificate associated with $from).
Net::SSLeay::copy_session_id($to, $from);
# $to - value corresponding to openssl's SSL structure
# $from - value corresponding to openssl's SSL structure
#
# returns: no return value
=item * ctrl
Internal handling function for SSL objects.
B openssl doc says: This function should never be called directly!
my $rv = Net::SSLeay::ctrl($ssl, $cmd, $larg, $parg);
# $ssl - value corresponding to openssl's SSL structure
# $cmd - (integer) command id
# $larg - (integer) long ???
# $parg - (string/pointer) ???
#
# returns: (long) result of given command ???
For more details about valid $cmd values check L.
Check openssl doc L
=item * do_handshake
Will wait for a SSL/TLS handshake to take place. If the connection is in client
mode, the handshake will be started. The handshake routines may have to be
explicitly set in advance using either SSL_set_connect_state or SSL_set_accept_state(3).
my $rv = Net::SSLeay::do_handshake($ssl);
# $ssl - value corresponding to openssl's SSL structure
#
# returns: 1 = success, 0 = handshake not successfull, <0 = fatal error during handshake
Check openssl doc L
=item * dup
Returns a duplicate of $ssl.
my $rv = Net::SSLeay::dup($ssl);
# $ssl - value corresponding to openssl's SSL structure
#
# returns: value corresponding to openssl's SSL structure (0 on failure)
=item * free
Free an allocated SSL structure.
Net::SSLeay::free($ssl);
# $ssl - value corresponding to openssl's SSL structure
#
# returns: no return value
Check openssl doc L
=item * get_SSL_CTX
Returns a pointer to the SSL_CTX object, from which $ssl was created with Net::SSLeay::new.
my $rv = Net::SSLeay::get_SSL_CTX($ssl);
# $ssl - value corresponding to openssl's SSL structure
#
# returns: value corresponding to openssl's SSL_CTX structure (0 on failure)
Check openssl doc L
=item * set_SSL_CTX
Sets the SSL_CTX the corresponds to an SSL session.
my $the_ssl_ctx = Net::SSLeay::set_SSL_CTX($ssl, $ssl_ctx);
# $ssl - value corresponding to openssl's SSL structure
# $ssl_ctx - Change the ssl object to the given ssl_ctx
#
# returns - the ssl_ctx
=item * get_app_data
Can be used to get application defined value/data.
my $rv = Net::SSLeay::get_app_data($ssl);
# $ssl - value corresponding to openssl's SSL structure
#
# returns: string/buffer/pointer ???
=item * set_app_data
Can be used to set some application defined value/data.
my $rv = Net::SSLeay::set_app_data($ssl, $arg);
# $ssl - value corresponding to openssl's SSL structure
# $arg - (string/buffer/pointer ???) data
#
# returns: ???
=item * get_certificate
Gets X509 certificate from an established SSL connection.
my $rv = Net::SSLeay::get_certificate($ssl);
# $ssl - value corresponding to openssl's SSL structure
#
# returns: value corresponding to openssl's X509 structure (0 on failure)
=item * get_cipher
Obtains the name of the currently used cipher.
my $rv = Net::SSLeay::get_cipher($ssl);
# $ssl - value corresponding to openssl's SSL structure
#
# returns: (string) cipher name e.g. 'DHE-RSA-AES256-SHA' or '', when no session has been established.
Check openssl doc L
=item * get_cipher_bits
Obtain the number of secret/algorithm bits used.
my $rv = Net::SSLeay::get_cipher_bits($ssl);
# $ssl - value corresponding to openssl's SSL structure
#
# returns: number of secret bits used by current cipher
Check openssl doc L
and L
=item * get_cipher_list
Returns the name (string) of the SSL_CIPHER listed for $ssl with priority $n.
my $rv = Net::SSLeay::get_cipher_list($ssl, $n);
# $ssl - value corresponding to openssl's SSL structure
# $n - (integer) priority
#
# returns: (string) cipher name e.g. 'EDH-DSS-DES-CBC3-SHA' or '' in case of error
Call Net::SSLeay::get_cipher_list with priority starting from 0 to obtain
the sorted list of available ciphers, until '' is returned:
my $priority = 0;
while (my $c = Net::SSLeay::get_cipher_list($ssl, $priority)) {
print "cipher[$priority] = $c\n";
$priority++;
}
Check openssl doc L
=item * get_client_CA_list
Returns the list of client CAs explicitly set for $ssl using C
or $ssl's SSL_CTX object with C, when in server mode.
In client mode, returns the list of client CAs sent from the server, if any.
my $rv = Net::SSLeay::get_client_CA_list($ssl);
# $ssl - value corresponding to openssl's SSL structure
#
# returns: value corresponding to openssl's STACK_OF(X509_NAME) structure (0 on failure)
Check openssl doc L
=item * get_current_cipher
Returns the cipher actually used.
my $rv = Net::SSLeay::get_current_cipher($ssl);
# $ssl - value corresponding to openssl's SSL structure
#
# returns: value corresponding to openssl's SSL_CIPHER structure (0 on failure)
Check openssl doc L
=item * get_default_timeout
Returns the default timeout value assigned to SSL_SESSION objects negotiated for the protocol valid for $ssl.
my $rv = Net::SSLeay::get_default_timeout($ssl);
# $ssl - value corresponding to openssl's SSL structure
#
# returns: (long) timeout in seconds
Check openssl doc L
=item * get_error
Returns a result code for a preceding call to C, C, C, C, C or C on $ssl.
my $rv = Net::SSLeay::get_error($ssl, $ret);
# $ssl - value corresponding to openssl's SSL structure
# $ret - return value of preceding TLS/SSL I/O operation
#
# returns: result code, which is one of the following values:
# 0 - SSL_ERROR_NONE
# 1 - SSL_ERROR_SSL
# 2 - SSL_ERROR_WANT_READ
# 3 - SSL_ERROR_WANT_WRITE
# 4 - SSL_ERROR_WANT_X509_LOOKUP
# 5 - SSL_ERROR_SYSCALL
# 6 - SSL_ERROR_ZERO_RETURN
# 7 - SSL_ERROR_WANT_CONNECT
# 8 - SSL_ERROR_WANT_ACCEPT
Check openssl doc L
=item * get_ex_data
Is used to retrieve the information for $idx from $ssl.
my $rv = Net::SSLeay::get_ex_data($ssl, $idx);
# $ssl - value corresponding to openssl's SSL structure
# $idx - (integer) index for application specific data
#
# returns: pointer to ???
Check openssl doc L
=item * set_ex_data
Is used to store application data at $data for $idx into the $ssl object.
my $rv = Net::SSLeay::set_ex_data($ssl, $idx, $data);
# $ssl - value corresponding to openssl's SSL structure
# $idx - (integer) ???
# $data - (pointer) ???
#
# returns: 1 on success, 0 on failure
Check openssl doc L
=item * get_ex_new_index
Is used to register a new index for application specific data.
my $rv = Net::SSLeay::get_ex_new_index($argl, $argp, $new_func, $dup_func, $free_func);
# $argl - (long) ???
# $argp - (pointer) ???
# $new_func - function pointer ??? (CRYPTO_EX_new *)
# $dup_func - function pointer ??? (CRYPTO_EX_dup *)
# $free_func - function pointer ??? (CRYPTO_EX_free *)
#
# returns: (integer) ???
Check openssl doc L
=item * get_fd
Returns the file descriptor which is linked to $ssl.
my $rv = Net::SSLeay::get_fd($ssl);
# $ssl - value corresponding to openssl's SSL structure
#
# returns: file descriptor (>=0) or -1 on failure
Check openssl doc L
=item * get_finished
Obtains the latest 'Finished' message sent to the peer.
??? (does this function really work?)
my $rv = Net::SSLeay::get_finished($ssl, $buf, $count);
# $ssl - value corresponding to openssl's SSL structure
# $buf - buffer where the returned data will be stored (pointer ???, pre-allocated ???)
# $count - max. size of return data
#
# returns: actual size of the returned data in $buf
=item * get_peer_finished
Obtains the latest 'Finished' message expected from the peer.
??? (does this function really work?)
my $rv = Net::SSLeay::get_peer_finished($ssl, $buf, $count);
# $ssl - value corresponding to openssl's SSL structure
# $buf - buffer where the returned data will be stored (pointer ???, pre-allocated ???)
# $count - max. size of the return data
#
# returns: actual size of the returned data in $buf
=item * get_keyblock_size
B Does not exactly correspond to any low level API function.
??? (more info needed)
my $rv = Net::SSLeay::get_keyblock_size($ssl);
# $ssl - value corresponding to openssl's SSL structure
#
# returns: keyblock size, -1 on error
=item * get_mode
Returns the mode (bitmask) set for $ssl.
my $rv = Net::SSLeay::get_mode($ssl);
# $ssl - value corresponding to openssl's SSL structure
#
# returns: mode (bitmask)
To decode the return value (bitmask) see documentation for L.
Check openssl doc L
=item * set_mode
Adds the mode set via bitmask in $mode to $ssl. Options already set before are not cleared.
my $rv = Net::SSLeay::set_mode($ssl, $mode);
# $ssl - value corresponding to openssl's SSL structure
# $mode - mode (bitmask)
#
# returns: the new mode bitmask after adding $mode
For $mode bitmask details see L.
Check openssl doc L
=item * get_options
Returns the options (bitmask) set for $ssl.
my $rv = Net::SSLeay::get_options($ssl);
# $ssl - value corresponding to openssl's SSL structure
#
# returns: options (bitmask)
To decode the return value (bitmask) see documentation for L.
Check openssl doc L
=item * set_options
Adds the options set via bitmask in $options to $ssl. Options already set before are not cleared!
Net::SSLeay::set_options($ssl, $options);
# $ssl - value corresponding to openssl's SSL structure
# $options - options (bitmask)
#
# returns: the new options bitmask after adding $options
For $options bitmask details see L.
Check openssl doc L
=item * get_peer_certificate
Get the X509 certificate of the peer.
my $rv = Net::SSLeay::get_peer_certificate($ssl);
# $ssl - value corresponding to openssl's SSL structure
#
# returns: value corresponding to openssl's X509 structure (0 on failure)
Check openssl doc L
=item * get_quiet_shutdown
Returns the 'quiet shutdown' setting of ssl.
my $rv = Net::SSLeay::get_quiet_shutdown($ssl);
# $ssl - value corresponding to openssl's SSL structure
#
# returns: (integer) current 'quiet shutdown' value
Check openssl doc L
=item * get_rbio
Get 'read' BIO linked to an SSL object $ssl.
my $rv = Net::SSLeay::get_rbio($ssl);
# $ssl - value corresponding to openssl's SSL structure
#
# returns: value corresponding to openssl's BIO structure (0 on failure)
Check openssl doc L