22271 lines
433 KiB
HTML
22271 lines
433 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of Net::SSLeay</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>Net::SSLeay</H1>
|
|
Section: User Contributed Perl Documentation (3pm)<BR>Updated: 2020-01-15<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
Net::SSLeay - Perl extension for using OpenSSL
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
use Net::SSLeay qw(get_https post_https sslcat make_headers make_form);
|
|
|
|
($page) = get_https('<A HREF="http://www.bacus.pt">www.bacus.pt</A>', 443, '/'); # Case 1
|
|
|
|
($page, $response, %reply_headers)
|
|
= get_https('<A HREF="http://www.bacus.pt">www.bacus.pt</A>', 443, '/', # Case 2
|
|
make_headers(User-Agent => 'Cryptozilla/5.0b1',
|
|
Referer => '<A HREF="https://www.bacus.pt'">https://www.bacus.pt'</A>
|
|
));
|
|
|
|
($page, $result, %headers) = # Case 2b
|
|
= get_https('<A HREF="http://www.bacus.pt">www.bacus.pt</A>', 443, '/protected.html',
|
|
make_headers(Authorization =>
|
|
'Basic ' . MIME::Base64::encode("$user:$pass",''))
|
|
);
|
|
|
|
($page, $response, %reply_headers)
|
|
= post_https('<A HREF="http://www.bacus.pt">www.bacus.pt</A>', 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
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
|
|
|
|
Net::SSLeay module contains perl bindings to openssl (<<A HREF="http://www.openssl.org">http://www.openssl.org</A>>) library.
|
|
<P>
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY NOTE:</B></FONT><B></B> Net::SSLeay 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 <FONT SIZE="-1">API</FONT> functions
|
|
may be available with certain openssl versions.
|
|
<P>
|
|
|
|
It is compatible with OpenSSL 1.0 and 1.1. Some functions are not available under OpenSSL 1.1.
|
|
<P>
|
|
|
|
Net::SSLeay module basically comprise of:
|
|
<DL COMPACT>
|
|
<DT id="1">•<DD>
|
|
High level functions for accessing web servers (by using <FONT SIZE="-1">HTTP/HTTPS</FONT>)
|
|
<DT id="2">•<DD>
|
|
Low level <FONT SIZE="-1">API</FONT> (mostly mapped 1:1 to openssl's C functions)
|
|
<DT id="3">•<DD>
|
|
Convenience functions (related to low level <FONT SIZE="-1">API</FONT> but with more perl friendly interface)
|
|
</DL>
|
|
<P>
|
|
|
|
There is also a related module called Net::SSLeay::Handle included in this
|
|
distribution that you might want to use instead. It has its own pod
|
|
documentation.
|
|
<A NAME="lbAE"> </A>
|
|
<H3>High level functions for accessing web servers</H3>
|
|
|
|
|
|
|
|
This module offers some high level convenience functions for accessing
|
|
web pages on <FONT SIZE="-1">SSL</FONT> servers (for symmetry, the same <FONT SIZE="-1">API</FONT> is offered for
|
|
accessing http servers, too), an <TT>"sslcat()"</TT> function for writing your own
|
|
clients, and finally access to the <FONT SIZE="-1">SSL</FONT> api of the SSLeay/OpenSSL package
|
|
so you can write servers or clients for more complicated applications.
|
|
<P>
|
|
|
|
For high level functions it is most convenient to import them into your
|
|
main namespace as indicated in the synopsis.
|
|
<P>
|
|
|
|
<I>Basic set of functions</I>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="4">•<DD>
|
|
get_https
|
|
<DT id="5">•<DD>
|
|
post_https
|
|
<DT id="6">•<DD>
|
|
put_https
|
|
<DT id="7">•<DD>
|
|
head_https
|
|
<DT id="8">•<DD>
|
|
do_https
|
|
<DT id="9">•<DD>
|
|
sslcat
|
|
<DT id="10">•<DD>
|
|
https_cat
|
|
<DT id="11">•<DD>
|
|
make_form
|
|
<DT id="12">•<DD>
|
|
make_headers
|
|
</DL>
|
|
<P>
|
|
|
|
<B>Case 1 (in </B><FONT SIZE="-1"><B>SYNOPSIS</B></FONT><B>)</B> demonstrates the typical invocation of <B>get_https()</B> to fetch an <FONT SIZE="-1">HTML</FONT>
|
|
page from secure server. The first argument provides the hostname or <FONT SIZE="-1">IP</FONT>
|
|
in dotted decimal notation of the remote server to contact. The second
|
|
argument is the <FONT SIZE="-1">TCP</FONT> port at the remote end (your own port is picked
|
|
arbitrarily from high numbered ports as usual for <FONT SIZE="-1">TCP</FONT>). The third
|
|
argument is the <FONT SIZE="-1">URL</FONT> of the page without the host name part. If in
|
|
doubt consult the <FONT SIZE="-1">HTTP</FONT> specifications at <<A HREF="http://www.w3c.org">http://www.w3c.org</A>>.
|
|
<P>
|
|
|
|
<B>Case 2 (in </B><FONT SIZE="-1"><B>SYNOPSIS</B></FONT><B>)</B> demonstrates full fledged use of <TT>"get_https()"</TT>. As can be seen,
|
|
<TT>"get_https()"</TT> 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 <TT>"get_https()"</TT> is used to insert some additional headers
|
|
in the request. <TT>"make_headers()"</TT> is a function that will convert a list or
|
|
hash to such headers. By default <TT>"get_https()"</TT> supplies <TT>"Host"</TT> (to make
|
|
virtual hosting easy) and <TT>"Accept"</TT> (reportedly needed by <FONT SIZE="-1">IIS</FONT>) headers.
|
|
<P>
|
|
|
|
<B>Case 2b (in </B><FONT SIZE="-1"><B>SYNOPSIS</B></FONT><B>)</B> demonstrates how to get a password protected page. Refer to
|
|
the <FONT SIZE="-1">HTTP</FONT> protocol specifications for further details (e.g. <FONT SIZE="-1">RFC-2617</FONT>).
|
|
<P>
|
|
|
|
<B>Case 3 (in </B><FONT SIZE="-1"><B>SYNOPSIS</B></FONT><B>)</B> invokes <TT>"post_https()"</TT> to submit a <FONT SIZE="-1">HTML/CGI</FONT> form to a secure
|
|
server. The first four arguments are equal to <TT>"get_https()"</TT> (note that
|
|
the empty string (<TT>''</TT>) is passed as header argument).
|
|
The fifth argument is the
|
|
contents of the form formatted according to <FONT SIZE="-1">CGI</FONT> specification.
|
|
Do not post <FONT SIZE="-1">UTF-8</FONT> data as content: use utf8::downgrade first. In this
|
|
case the helper function <TT>"make_https()"</TT> is used to do the formatting,
|
|
but you could pass any string. <TT>"post_https()"</TT> automatically adds
|
|
<TT>"Content-Type"</TT> and <TT>"Content-Length"</TT> headers to the request.
|
|
<P>
|
|
|
|
<B>Case 4 (in </B><FONT SIZE="-1"><B>SYNOPSIS</B></FONT><B>)</B> shows the fundamental <TT>"sslcat()"</TT> function (inspired in spirit by
|
|
the <TT>"netcat"</TT> 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 -
|
|
<TT>"sslcat()"</TT> is just a transport.
|
|
<P>
|
|
|
|
<B>Case 5 (in </B><FONT SIZE="-1"><B>SYNOPSIS</B></FONT><B>)</B> is a full invocation of <TT>"sslcat()"</TT> which allows the return of errors
|
|
as well as the server (peer) certificate.
|
|
<P>
|
|
|
|
The <TT>$trace</TT> 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.
|
|
<P>
|
|
|
|
<I>Alternate versions of high-level </I><FONT SIZE="-1"><I>API</I></FONT><I></I>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="13">•<DD>
|
|
get_https3
|
|
<DT id="14">•<DD>
|
|
post_https3
|
|
<DT id="15">•<DD>
|
|
put_https3
|
|
<DT id="16">•<DD>
|
|
get_https4
|
|
<DT id="17">•<DD>
|
|
post_https4
|
|
<DT id="18">•<DD>
|
|
put_https4
|
|
</DL>
|
|
<P>
|
|
|
|
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.
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
($page, $response, @headers) = get_https('<A HREF="http://www.bacus.pt">www.bacus.pt</A>', 443, '/');
|
|
for ($i = 0; $i < $#headers; $i+=2) {
|
|
print "$headers[$i] = " . $headers[$i+1] . "\n";
|
|
}
|
|
|
|
($page, $response, $headers, $server_cert)
|
|
= get_https3('<A HREF="http://www.bacus.pt">www.bacus.pt</A>', 443, '/');
|
|
print "$headers\n";
|
|
|
|
($page, $response, $headers_ref)
|
|
= get_https4('<A HREF="http://www.bacus.pt">www.bacus.pt</A>', 443, '/');
|
|
for $k (sort keys %{$headers_ref}) {
|
|
for $v (@{$$headers_ref{$k}}) {
|
|
print "$k = $v\n";
|
|
}
|
|
}
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
All of the above code fragments accomplish the same thing: display all
|
|
values of all headers. The <FONT SIZE="-1">API</FONT> 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 perlref and perllol 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
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
print $$headers_ref{COOKIE}[0];
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
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>
|
|
|
|
|
|
|
|
<PRE>
|
|
($p, $resp, $hdrs, $server_cert) = get_https3('<A HREF="http://www.bacus.pt">www.bacus.pt</A>', 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));
|
|
}
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
Beware that this method only allows after the fact verification of
|
|
the certificate: by the time <TT>"get_https3()"</TT> 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 <FONT SIZE="-1">API</FONT> to first connect and verify the certificate
|
|
and only then send the http data. See the implementation of <TT>"ds_https3()"</TT>
|
|
for guidance on how to do this.
|
|
<P>
|
|
|
|
<I>Using client certificates</I>
|
|
|
|
|
|
<P>
|
|
|
|
Secure web communications are encrypted using symmetric crypto keys
|
|
exchanged using encryption based on the certificate of the
|
|
server. Therefore in all <FONT SIZE="-1">SSL</FONT> connections the server must have a
|
|
certificate. This serves both to authenticate the server to the
|
|
clients and to perform the key exchange.
|
|
<P>
|
|
|
|
Sometimes it is necessary to authenticate the client as well. Two
|
|
options are available: <FONT SIZE="-1">HTTP</FONT> basic authentication and a client side
|
|
certificate. The basic authentication over <FONT SIZE="-1">HTTPS</FONT> is actually quite
|
|
safe because <FONT SIZE="-1">HTTPS</FONT> 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 <FONT SIZE="-1">SSL</FONT> level using a certificate. For this to work, both the
|
|
client and the server have certificates (which typically are
|
|
different) and private keys.
|
|
<P>
|
|
|
|
The <FONT SIZE="-1">API</FONT> 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.
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
($page, $result, %headers) = # 2c
|
|
= get_https('<A HREF="http://www.bacus.pt">www.bacus.pt</A>', 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('<A HREF="http://www.bacus.pt">www.bacus.pt</A>', 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);
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
<B>Case 2c (in </B><FONT SIZE="-1"><B>SYNOPSIS</B></FONT><B>)</B> demonstrates getting a password protected page that also requires
|
|
a client certificate, i.e. it is possible to use both authentication
|
|
methods simultaneously.
|
|
<P>
|
|
|
|
<B>Case 3b (in </B><FONT SIZE="-1"><B>SYNOPSIS</B></FONT><B>)</B> is a full blown <FONT SIZE="-1">POST</FONT> to a secure server that requires both password
|
|
authentication and a client certificate, just like in case 2c.
|
|
<P>
|
|
|
|
Note: The client will not send a certificate unless the server requests one.
|
|
This is typically achieved by setting the verify mode to <TT>"VERIFY_PEER"</TT> on the
|
|
server:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::set_verify(ssl, Net::SSLeay::VERIFY_PEER, 0);
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
See <TT>"perldoc ~openssl/doc/ssl/SSL_CTX_set_verify.pod"</TT> for a full description.
|
|
<P>
|
|
|
|
<I>Working through a web proxy</I>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="19">•<DD>
|
|
set_proxy
|
|
</DL>
|
|
<P>
|
|
|
|
<TT>"Net::SSLeay"</TT> can use a web proxy to make its connections. You need to
|
|
first set the proxy host and port using <TT>"set_proxy()"</TT> and then just
|
|
use the normal <FONT SIZE="-1">API</FONT> functions, e.g:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::set_proxy('gateway.myorg.com', 8080);
|
|
($page) = get_https('<A HREF="http://www.bacus.pt">www.bacus.pt</A>', 443, '/');
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
If your proxy requires authentication, you can supply a username and
|
|
password as well
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::set_proxy('gateway.myorg.com', 8080, 'joe', 'salainen');
|
|
($page, $result, %headers) =
|
|
= get_https('<A HREF="http://www.bacus.pt">www.bacus.pt</A>', 443, '/protected.html',
|
|
make_headers(Authorization =>
|
|
'Basic ' . MIME::Base64::encode("susie:pass",''))
|
|
);
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
This example demonstrates the case where we authenticate to the proxy as
|
|
<TT>"joe"</TT> and to the final web server as <TT>"susie"</TT>. Proxy authentication
|
|
requires the <TT>"MIME::Base64"</TT> module to work.
|
|
<P>
|
|
|
|
<I></I><FONT SIZE="-1"><I>HTTP</I></FONT><I> (without S) </I><FONT SIZE="-1"><I>API</I></FONT><I></I>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="20">•<DD>
|
|
get_http
|
|
<DT id="21">•<DD>
|
|
post_http
|
|
<DT id="22">•<DD>
|
|
tcpcat
|
|
<DT id="23">•<DD>
|
|
get_httpx
|
|
<DT id="24">•<DD>
|
|
post_httpx
|
|
<DT id="25">•<DD>
|
|
tcpxcat
|
|
</DL>
|
|
<P>
|
|
|
|
Over the years it has become clear that it would be convenient to use
|
|
the light-weight flavour <FONT SIZE="-1">API</FONT> of <TT>"Net::SSLeay"</TT> for normal <FONT SIZE="-1">HTTP</FONT> as well (see
|
|
<TT>"LWP"</TT> 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 <FONT SIZE="-1">HTTP</FONT>
|
|
support was evolved.
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
use Net::SSLeay qw(get_http post_http tcpcat
|
|
get_httpx post_httpx tcpxcat
|
|
make_headers make_form);
|
|
|
|
($page, $result, %headers)
|
|
= get_http('<A HREF="http://www.bacus.pt">www.bacus.pt</A>', 443, '/protected.html',
|
|
make_headers(Authorization =>
|
|
'Basic ' . MIME::Base64::encode("$user:$pass",''))
|
|
);
|
|
|
|
($page, $response, %reply_headers)
|
|
= post_http('<A HREF="http://www.bacus.pt">www.bacus.pt</A>', 443, '/foo.cgi', '',
|
|
make_form(OK => '1',
|
|
name => 'Sampo'
|
|
));
|
|
|
|
($reply, $err) = tcpcat($host, $port, $request);
|
|
|
|
($page, $result, %headers)
|
|
= get_httpx($usessl, '<A HREF="http://www.bacus.pt">www.bacus.pt</A>', 443, '/protected.html',
|
|
make_headers(Authorization =>
|
|
'Basic ' . MIME::Base64::encode("$user:$pass",''))
|
|
);
|
|
|
|
($page, $response, %reply_headers)
|
|
= post_httpx($usessl, '<A HREF="http://www.bacus.pt">www.bacus.pt</A>', 443, '/foo.cgi', '',
|
|
make_form(OK => '1', name => 'Sampo' ));
|
|
|
|
($reply, $err, $server_cert) = tcpxcat($usessl, $host, $port, $request);
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
As can be seen, the <TT>"x"</TT> family of APIs takes as the first argument a flag
|
|
which indicates whether <FONT SIZE="-1">SSL</FONT> is used or not.
|
|
<A NAME="lbAF"> </A>
|
|
<H3>Certificate verification and Certificate Revocation Lists (CRLs)</H3>
|
|
|
|
|
|
|
|
OpenSSL supports the ability to verify peer certificates. It can also
|
|
optionally check the peer certificate against a Certificate Revocation
|
|
List (<FONT SIZE="-1">CRL</FONT>) from the certificates issuer. A <FONT SIZE="-1">CRL</FONT> 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 <FONT SIZE="-1">PEM</FONT> format.
|
|
<P>
|
|
|
|
You can enable <TT>"Net::SSLeay CRL"</TT> checking like this:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
&Net::SSLeay::X509_STORE_set_flags
|
|
(&Net::SSLeay::CTX_get_cert_store($ssl),
|
|
&Net::SSLeay::X509_V_FLAG_CRL_CHECK);
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
After setting this flag, if OpenSSL checks a peer's certificate, then
|
|
it will attempt to find a <FONT SIZE="-1">CRL</FONT> for the issuer. It does this by looking
|
|
for a specially named file in the search directory specified by
|
|
CTX_load_verify_locations. <FONT SIZE="-1">CRL</FONT> files are named with the hash of the
|
|
issuer's subject name, followed by <TT>".r0"</TT>, <TT>".r1"</TT> etc. For example
|
|
<TT>"ab1331b2.r0"</TT>, <TT>"ab1331b2.r1"</TT>. 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 <FONT SIZE="-1">CRL</FONT>
|
|
file., see below). You can find out the hash of the issuer subject
|
|
name in a <FONT SIZE="-1">CRL</FONT> with
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
openssl crl -in crl.pem -hash -noout
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
If the peer certificate does not pass the revocation list, or if no
|
|
<FONT SIZE="-1">CRL</FONT> is found, then the handshaking fails with an error.
|
|
<P>
|
|
|
|
You can also force OpenSSL to look for CRLs in one or more arbitrarily
|
|
named files.
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
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....
|
|
}
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
Usually the URLs where you can download the CRLs is contained in the certificate
|
|
itself and you can extract them with
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
my @url = Net::SSLeay::P_X509_get_crl_distribution_points($cert)
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
But there is no automatic downloading of the CRLs and often these CRLs are too
|
|
huge to just download them to verify a single certificate.
|
|
Also, these CRLs are often in <FONT SIZE="-1">DER</FONT> format which you need to convert to <FONT SIZE="-1">PEM</FONT> before
|
|
you can use it:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
openssl crl -in crl.der -inform der -out crl.pem
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
So as an alternative for faster and timely revocation checks you better use
|
|
the Online Status Revocation Protocol (<FONT SIZE="-1">OCSP</FONT>).
|
|
<A NAME="lbAG"> </A>
|
|
<H3>Certificate verification and Online Status Revocation Protocol (<FONT SIZE="-1">OCSP</FONT>)</H3>
|
|
|
|
|
|
|
|
While checking for revoked certificates is possible and fast with Certificate
|
|
Revocation Lists, you need to download the complete and often huge list before
|
|
you can verify a single certificate.
|
|
<P>
|
|
|
|
A faster way is to ask the <FONT SIZE="-1">CA</FONT> to check the revocation of just a single or a few
|
|
certificates using <FONT SIZE="-1">OCSP.</FONT> Basically you generate for each certificate an
|
|
<FONT SIZE="-1">OCSP_CERTID</FONT> based on the certificate itself and its issuer, put the ids
|
|
togetether into an <FONT SIZE="-1">OCSP_REQUEST</FONT> and send the request to the <FONT SIZE="-1">URL</FONT> given in the
|
|
certificate.
|
|
<P>
|
|
|
|
As a result you get back an <FONT SIZE="-1">OCSP_RESPONSE</FONT> and need to check the status of the
|
|
response, check that it is valid (e.g. signed by the <FONT SIZE="-1">CA</FONT>) and finally extract the
|
|
information about each <FONT SIZE="-1">OCSP_CERTID</FONT> to find out if the certificate is still valid
|
|
or got revoked.
|
|
<P>
|
|
|
|
With Net::SSLeay this can be done like this:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
# get id(s) for given certs, like from get_peer_certificate
|
|
# or get_peer_cert_chain. This will croak if
|
|
# - one tries to make an OCSP_CERTID for a self-signed certificate
|
|
# - the issuer of the certificate cannot be found in the SSL objects
|
|
# store, nor in the current certificate chain
|
|
my $cert = Net::SSLeay::get_peer_certificate($ssl);
|
|
my $id = eval { Net::SSLeay::OCSP_cert2ids($ssl,$cert) };
|
|
die "failed to make OCSP_CERTID: $@" if $@;
|
|
|
|
# create OCSP_REQUEST from id(s)
|
|
# Multiple can be put into the same request, if the same OCSP responder
|
|
# is responsible for them.
|
|
my $req = Net::SSLeay::OCSP_ids2req($id);
|
|
|
|
# determine URI of OCSP responder
|
|
my $uri = Net::SSLeay::P_X509_get_ocsp_uri($cert);
|
|
|
|
# Send stringified OCSP_REQUEST with POST to $uri.
|
|
# We can ignore certificate verification for https, because the OCSP
|
|
# response itself is signed.
|
|
my $ua = HTTP::Tiny->new(verify_SSL => 0);
|
|
my $res = $ua->request( 'POST',$uri, {
|
|
headers => { 'Content-type' => 'application/ocsp-request' },
|
|
content => Net::SSLeay::i2d_OCSP_REQUEST($req)
|
|
});
|
|
my $content = $res && $res->{success} && $res->{content}
|
|
or die "query failed";
|
|
|
|
# Extract OCSP_RESPONSE.
|
|
# this will croak if the string is not an OCSP_RESPONSE
|
|
my $resp = eval { Net::SSLeay::d2i_OCSP_RESPONSE($content) };
|
|
|
|
# Check status of response.
|
|
my $status = Net::SSLeay::OCSP_response_status($resp);
|
|
if ($status != Net::SSLeay::OCSP_RESPONSE_STATUS_SUCCESSFUL())
|
|
die "OCSP response failed: ".
|
|
Net::SSLeay::OCSP_response_status_str($status);
|
|
}
|
|
|
|
# Verify signature of response and if nonce matches request.
|
|
# This will croak if there is a nonce in the response, but it does not match
|
|
# the request. It will return false if the signature could not be verified,
|
|
# in which case details can be retrieved with Net::SSLeay::ERR_get_error.
|
|
# It will not complain if the response does not contain a nonce, which is
|
|
# usually the case with pre-signed responses.
|
|
if ( ! eval { Net::SSLeay::OCSP_response_verify($ssl,$resp,$req) }) {
|
|
die "OCSP response verification failed";
|
|
}
|
|
|
|
# Extract information from OCSP_RESPONSE for each of the ids.
|
|
|
|
# If called in scalar context it will return the time (as time_t), when the
|
|
# next update is due (minimum of all successful responses inside $resp). It
|
|
# will croak on the following problems:
|
|
# - response is expired or not yet valid
|
|
# - no response for given OCSP_CERTID
|
|
# - certificate status is not good (e.g. revoked or unknown)
|
|
if ( my $nextupd = eval { Net::SSLeay::OCSP_response_results($resp,$id) }) {
|
|
warn "certificate is valid, next update in ".
|
|
($nextupd-time())." seconds\n";
|
|
} else {
|
|
die "certificate is not valid: $@";
|
|
}
|
|
|
|
# But in array context it will return detailed information about each given
|
|
# OCSP_CERTID instead croaking on errors:
|
|
# if no @ids are given it will return information about all single responses
|
|
# in the OCSP_RESPONSE
|
|
my @results = Net::SSLeay::OCSP_response_results($resp,@ids);
|
|
for my $r (@results) {
|
|
print Dumper($r);
|
|
# @results are in the same order as the @ids and contain:
|
|
# $r->[0] - OCSP_CERTID
|
|
# $r->[1] - undef if no error (certificate good) OR error message as string
|
|
# $r->[2] - hash with details:
|
|
# thisUpdate - time_t of this single response
|
|
# nextUpdate - time_t when update is expected
|
|
# statusType - integer:
|
|
# V_OCSP_CERTSTATUS_GOOD(0)
|
|
# <A HREF="/cgi-bin/man/man2html?1+V_OCSP_CERTSTATUS_REVOKED">V_OCSP_CERTSTATUS_REVOKED</A>(1)
|
|
# <A HREF="/cgi-bin/man/man2html?2+V_OCSP_CERTSTATUS_UNKNOWN">V_OCSP_CERTSTATUS_UNKNOWN</A>(2)
|
|
# revocationTime - time_t (only if revoked)
|
|
# revocationReason - integer (only if revoked)
|
|
# revocationReason_str - reason as string (only if revoked)
|
|
}
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
To further speed up certificate revocation checking one can use a <FONT SIZE="-1">TLS</FONT> extension
|
|
to instruct the server to staple the <FONT SIZE="-1">OCSP</FONT> response:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
# set TLS extension before doing SSL_connect
|
|
Net::SSLeay::set_tlsext_status_type($ssl,
|
|
Net::SSLeay::TLSEXT_STATUSTYPE_ocsp());
|
|
|
|
# setup callback to verify OCSP response
|
|
my $cert_valid = undef;
|
|
Net::SSLeay::CTX_set_tlsext_status_cb($context,sub {
|
|
my ($ssl,$resp) = @_;
|
|
if (!$resp) {
|
|
# Lots of servers don't return an OCSP response.
|
|
# In this case we must check the OCSP status outside the SSL
|
|
# handshake.
|
|
warn "server did not return stapled OCSP response\n";
|
|
return 1;
|
|
}
|
|
# verify status
|
|
my $status = Net::SSLeay::OCSP_response_status($resp);
|
|
if ($status != Net::SSLeay::OCSP_RESPONSE_STATUS_SUCCESSFUL()) {
|
|
warn "OCSP response failure: $status\n";
|
|
return 1;
|
|
}
|
|
# verify signature - we have no OCSP_REQUEST here to check nonce
|
|
if (!eval { Net::SSLeay::OCSP_response_verify($ssl,$resp) }) {
|
|
warn "OCSP response verify failed\n";
|
|
return 1;
|
|
}
|
|
# check if the certificate is valid
|
|
# we should check here against the peer_certificate
|
|
my $cert = Net::SSLeay::get_peer_certificate();
|
|
my $certid = eval { Net::SSLeay::OCSP_cert2ids($ssl,$cert) } or do {
|
|
warn "cannot get certid from cert: $@";
|
|
$cert_valid = -1;
|
|
return 1;
|
|
};
|
|
|
|
if ( $nextupd = eval {
|
|
Net::SSLeay::OCSP_response_results($resp,$certid) }) {
|
|
warn "certificate not revoked\n";
|
|
$cert_valid = 1;
|
|
} else {
|
|
warn "certificate not valid: $@";
|
|
$cert_valid = 0;
|
|
}
|
|
});
|
|
|
|
# do SSL handshake here
|
|
....
|
|
# check if certificate revocation was checked already
|
|
if ( ! defined $cert_valid) {
|
|
# check revocation outside of SSL handshake by asking OCSP responder
|
|
...
|
|
} elsif ( ! $cert_valid ) {
|
|
die "certificate not valid - closing SSL connection";
|
|
} elsif ( $cert_valid<0 ) {
|
|
die "cannot verify certificate revocation - self-signed ?";
|
|
} else {
|
|
# everything fine
|
|
...
|
|
}
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAH"> </A>
|
|
<H3>Using Net::SSLeay in multi-threaded applications</H3>
|
|
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>IMPORTANT:</B></FONT><B> versions 1.42 or earlier are not thread-safe!</B>
|
|
<P>
|
|
|
|
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 <<A HREF="http://www.openssl.org/docs/crypto/threads.html">http://www.openssl.org/docs/crypto/threads.html</A>>).
|
|
<P>
|
|
|
|
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:
|
|
<P>
|
|
|
|
<I>Initialization</I>
|
|
|
|
|
|
<P>
|
|
|
|
Load and initialize Net::SSLeay module in the main thread:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
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);
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
<FONT SIZE="-1">NOTE:</FONT> Openssl's <TT>"int SSL_library_init(void)"</TT> function (which is also aliased as
|
|
<TT>"SSLeay_add_ssl_algorithms"</TT>, <TT>"OpenSSL_add_ssl_algorithms"</TT> and <TT>"add_ssl_algorithms"</TT>)
|
|
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 <B>Net::SSLeay::SSLeay_add_ssl_algorithms()</B>
|
|
should work without trouble.
|
|
<P>
|
|
|
|
<I>Using callbacks</I>
|
|
|
|
|
|
<P>
|
|
|
|
Do not use callbacks across threads (the module blocks cross-thread callback operations
|
|
and throws a warning). Always do the callback setup, callback use and callback destruction
|
|
within the same thread.
|
|
<P>
|
|
|
|
<I>Using openssl elements</I>
|
|
|
|
|
|
<P>
|
|
|
|
All openssl elements (X509, <FONT SIZE="-1">SSL_CTX, ...</FONT>) can be directly passed between threads.
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
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);
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
Or:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
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);
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
<I>Using other perl modules based on Net::SSLeay</I>
|
|
|
|
|
|
<P>
|
|
|
|
It should be fine to use any other module based on Net::SSLeay (like IO::Socket::SSL)
|
|
in multi-threaded applications. It is generally recommended to do any global initialization
|
|
of such a module in the main thread before calling <TT>"threads->new(..)"</TT> or
|
|
<TT>"threads->create(..)"</TT> but it might differ module by module.
|
|
<P>
|
|
|
|
To be safe you can load and init Net::SSLeay explicitly in the main thread:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
use Net::SSLeay;
|
|
use Other::SSLeay::Based::Module;
|
|
|
|
Net::SSLeay::load_error_strings();
|
|
Net::SSLeay::SSLeay_add_ssl_algorithms();
|
|
Net::SSLeay::randomize();
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
Or even safer:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
use Net::SSLeay;
|
|
use Other::SSLeay::Based::Module;
|
|
|
|
BEGIN {
|
|
Net::SSLeay::load_error_strings();
|
|
Net::SSLeay::SSLeay_add_ssl_algorithms();
|
|
Net::SSLeay::randomize();
|
|
}
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
<I>Combining Net::SSLeay with other modules linked with openssl</I>
|
|
|
|
|
|
<P>
|
|
|
|
<B></B><FONT SIZE="-1"><B>BEWARE:</B></FONT><B> This might be a big trouble! This is not guaranteed be thread-safe!</B>
|
|
<P>
|
|
|
|
There are many other (<FONT SIZE="-1">XS</FONT>) modules linked directly to openssl library (like Crypt::SSLeay).
|
|
<P>
|
|
|
|
As it is expected that also ``another'' module will call <TT>"SSLeay_add_ssl_algorithms"</TT> at some point
|
|
we have again a trouble with multiple openssl initialization by Net::SSLeay and ``another'' module.
|
|
<P>
|
|
|
|
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).
|
|
<P>
|
|
|
|
<I>Threading with get_https and friends</I>
|
|
|
|
|
|
<P>
|
|
|
|
The convenience functions get_https, post_https etc all initialize the <FONT SIZE="-1">SSL</FONT> library by calling
|
|
Net::SSLeay::initialize which does the conventional library initialization:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::load_error_strings();
|
|
Net::SSLeay::SSLeay_add_ssl_algorithms();
|
|
Net::SSLeay::randomize();
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
Net::SSLeay::initialize initializes the <FONT SIZE="-1">SSL</FONT> 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.
|
|
<A NAME="lbAI"> </A>
|
|
<H3>Convenience routines</H3>
|
|
|
|
|
|
|
|
To be used with Low level <FONT SIZE="-1">API</FONT>
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
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);
|
|
|
|
</PRE>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="26">•<DD>
|
|
randomize
|
|
|
|
|
|
<P>
|
|
|
|
|
|
seeds the openssl <FONT SIZE="-1">PRNG</FONT> with <TT>"/dev/urandom"</TT> (see the top of <TT>"SSLeay.pm"</TT>
|
|
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 <FONT SIZE="-1">API</FONT> functions automatically
|
|
call <TT>"randomize()"</TT> so it is not needed with them. See also caveats.
|
|
<DT id="27">•<DD>
|
|
set_cert_and_key
|
|
|
|
|
|
<P>
|
|
|
|
|
|
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.
|
|
<DT id="28">•<DD>
|
|
dump_peer_certificate
|
|
|
|
|
|
<P>
|
|
|
|
|
|
allows you to get a plaintext description of the
|
|
certificate the peer (usually the server) presented to us.
|
|
<DT id="29">•<DD>
|
|
ssl_read_all
|
|
|
|
|
|
<P>
|
|
|
|
|
|
see ssl_write_all (below)
|
|
<DT id="30">•<DD>
|
|
ssl_write_all
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<TT>"ssl_read_all()"</TT> and <TT>"ssl_write_all()"</TT> provide true blocking semantics for
|
|
these operations (see limitation, below, for explanation). These are
|
|
much preferred to the low level <FONT SIZE="-1">API</FONT> equivalents (which implement <FONT SIZE="-1">BSD</FONT>
|
|
blocking semantics). The message argument to <TT>"ssl_write_all()"</TT> can be
|
|
a reference. This is helpful to avoid unnecessary copying when writing
|
|
something big, e.g:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
$data = 'A' x 1000000000;
|
|
Net::SSLeay::ssl_write_all($ssl, \$data) or die "ssl write failed";
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="31">•<DD>
|
|
ssl_read_CRLF
|
|
|
|
|
|
<P>
|
|
|
|
|
|
uses <TT>"ssl_read_all()"</TT> to read in a line terminated with a
|
|
carriage return followed by a linefeed (<FONT SIZE="-1">CRLF</FONT>). The <FONT SIZE="-1">CRLF</FONT> is included in
|
|
the returned scalar.
|
|
<DT id="32">•<DD>
|
|
ssl_read_until
|
|
|
|
|
|
<P>
|
|
|
|
|
|
uses <TT>"ssl_read_all()"</TT> to read from the <FONT SIZE="-1">SSL</FONT> input
|
|
stream until it encounters a programmer specified delimiter.
|
|
If the delimiter is undefined, <TT>$/</TT> is used. If <TT>$/</TT> is undefined,
|
|
<TT>"\n"</TT> is used. One can optionally set a maximum length of bytes to read
|
|
from the <FONT SIZE="-1">SSL</FONT> input stream.
|
|
<DT id="33">•<DD>
|
|
ssl_write_CRLF
|
|
|
|
|
|
<P>
|
|
|
|
|
|
writes <TT>$message</TT> and appends <FONT SIZE="-1">CRLF</FONT> to the <FONT SIZE="-1">SSL</FONT> output stream.
|
|
</DL>
|
|
<A NAME="lbAJ"> </A>
|
|
<H3>Initialization</H3>
|
|
|
|
|
|
|
|
In order to use the low level <FONT SIZE="-1">API</FONT> you should start your programs with
|
|
the following incantation:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
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();
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAK"> </A>
|
|
<H3>Error handling functions</H3>
|
|
|
|
|
|
|
|
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.
|
|
<DL COMPACT>
|
|
<DT id="34">•<DD>
|
|
die_now
|
|
<DT id="35">•<DD>
|
|
die_if_ssl_error
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<TT>"die_now()"</TT> and <TT>"die_if_ssl_error()"</TT> are used to conveniently print the SSLeay error
|
|
stack when something goes wrong:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::connect($ssl) or die_now("Failed SSL connect ($!)");
|
|
|
|
|
|
Net::SSLeay::write($ssl, "foo") or die_if_ssl_error("SSL write ($!)");
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="36">•<DD>
|
|
print_errs
|
|
|
|
|
|
<P>
|
|
|
|
|
|
You can also use <TT>"Net::SSLeay::print_errs()"</TT> 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.
|
|
</DL>
|
|
<A NAME="lbAL"> </A>
|
|
<H3>Sockets</H3>
|
|
|
|
|
|
|
|
Perl uses file handles for all I/O. While SSLeay has a quite flexible <FONT SIZE="-1">BIO</FONT>
|
|
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 <TT>"fileno()"</TT> to extract the underlying file descriptor:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::set_fd($ssl, fileno(S)); # Must use fileno
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
You should also set <TT>$|</TT> to 1 to eliminate <FONT SIZE="-1">STDIO</FONT> buffering so you do not
|
|
get confused if you use perl I/O functions to manipulate your socket
|
|
handle.
|
|
<P>
|
|
|
|
If you need to <TT><A HREF="/cgi-bin/man/man2html?2+select">select</A>(2)</TT> 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). <TT>"Net::SSLeay"</TT> is no different from the
|
|
C language OpenSSL in this respect.
|
|
<A NAME="lbAM"> </A>
|
|
<H3>Callbacks</H3>
|
|
|
|
|
|
|
|
You can establish a per-context verify callback function something like this:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
sub verify {
|
|
my ($ok, $x509_store_ctx) = @_;
|
|
print "Verifying certificate...\n";
|
|
...
|
|
return $ok;
|
|
}
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
It is used like this:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::set_verify ($ssl, Net::SSLeay::VERIFY_PEER, \&verify);
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
Per-context callbacks for decrypting private keys are implemented.
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
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);
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
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.
|
|
<P>
|
|
|
|
Establish it like this:
|
|
<BR> Net::SSLeay::set_session_secret_cb($ssl, \&session_secret_cb, <TT>$somedata</TT>);
|
|
<P>
|
|
|
|
It will be called like this:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
sub session_secret_cb
|
|
{
|
|
my ($secret, \@cipherlist, \$preferredcipher, $somedata) = @_;
|
|
}
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
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.
|
|
<P>
|
|
|
|
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.
|
|
<P>
|
|
|
|
If you want to use callback stuff, see examples/callback.pl! It's the
|
|
only one I am able to make work reliably.
|
|
<A NAME="lbAN"> </A>
|
|
<H3>Low level <FONT SIZE="-1">API</FONT></H3>
|
|
|
|
|
|
|
|
In addition to the high level functions outlined above, this module
|
|
contains straight-forward access to <FONT SIZE="-1">CRYPTO</FONT> and <FONT SIZE="-1">SSL</FONT> parts of OpenSSL C <FONT SIZE="-1">API.</FONT>
|
|
<P>
|
|
|
|
See the <TT>"*.h"</TT> 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 <TT>"SSL_"</TT> off of the SSLeay names.
|
|
Generally you should use <TT>"Net::SSLeay::"</TT> in its place.
|
|
<P>
|
|
|
|
Note that some functions are prefixed with <TT>"P_"</TT> - these are very close to
|
|
the original <FONT SIZE="-1">API</FONT> however contain some kind of a wrapper making its interface
|
|
more perl friendly.
|
|
<P>
|
|
|
|
For example:
|
|
<P>
|
|
|
|
In C:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
#include <<A HREF="file:///usr/include/ssl.h">ssl.h</A>>
|
|
|
|
err = SSL_set_verify (ssl, SSL_VERIFY_CLIENT_ONCE,
|
|
&your_call_back_here);
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
In Perl:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
use Net::SSLeay;
|
|
|
|
$err = Net::SSLeay::set_verify ($ssl,
|
|
Net::SSLeay::VERIFY_CLIENT_ONCE,
|
|
\&your_call_back_here);
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
If the function does not start with <TT>"SSL_"</TT> you should use the full
|
|
function name, e.g.:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
$err = Net::SSLeay::ERR_get_error;
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
The following new functions behave in perlish way:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
$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
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
<I>Low level </I><FONT SIZE="-1"><I>API:</I></FONT><I> Version related functions</I>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="37">•<DD>
|
|
SSLeay
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.42 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Gives version number (numeric) of underlaying openssl library.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
You can use it like this:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
if (Net::SSLeay::SSLeay() < 0x0090800f) {
|
|
die "you need openssl-0.9.8 or higher";
|
|
}
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="38">•<DD>
|
|
SSLeay_version
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.42 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Gives version number (string) of underlaying openssl library.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $ver_string = Net::SSLeay::SSLeay_version($type);
|
|
# $type
|
|
# SSLEAY_VERSION - e.g. 'OpenSSL 1.0.0d 8 Feb 2011'
|
|
# SSLEAY_CFLAGS - e.g. 'compiler: gcc -D_WINDLL -DOPENSSL_USE_APPLINK .....'
|
|
# SSLEAY_BUILT_ON - e.g. 'built on: Fri May 6 00:00:46 GMT 2011'
|
|
# SSLEAY_PLATFORM - e.g. 'platform: mingw'
|
|
# SSLEAY_DIR - e.g. 'OPENSSLDIR: "z:/...."'
|
|
#
|
|
# returns: string
|
|
|
|
Net::SSLeay::SSLeay_version();
|
|
#is equivalent to
|
|
Net::SSLeay::SSLeay_version(SSLEAY_VERSION);
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/man1.0.2/crypto/SSLeay_version.html">https://www.openssl.org/docs/man1.0.2/crypto/SSLeay_version.html</A>>
|
|
<DT id="39">•<DD>
|
|
OpenSSL_version_num
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.82 and before; requires at least OpenSSL 1.1.0
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Gives version number (numeric) of underlaying openssl library. See ``SSLeay'' for interpreting the result.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $ver_number = Net::SSLeay::OpenSSL_version_num();
|
|
# returns: the number identifying the openssl release
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="40">•<DD>
|
|
OpenSSL_version
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.82 and before; requires at least OpenSSL 1.1.0
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Gives version number (string) of underlaying openssl library.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $ver_string = Net::SSLeay::OpenSSL_version($t);
|
|
# $t
|
|
# OPENSSL_VERSION - e.g. 'OpenSSL 1.1.0g 2 Nov 2017'
|
|
# OPENSSL_CFLAGS - e.g. 'compiler: cc -DDSO_DLFCN -DHAVE_DLFCN_H .....'
|
|
# OPENSSL_BUILT_ON - e.g. 'built on: reproducible build, date unspecified'
|
|
# OPENSSL_PLATFORM - e.g. 'platform: darwin64-x86_64-cc'
|
|
# OPENSSL_DIR - e.g. 'OPENSSLDIR: "/opt/openssl-1.1.0g"'
|
|
# OPENSSL_ENGINES_DIR - e.g. 'ENGINESDIR: "/opt/openssl-1.1.0g/lib/engines-1.1"'
|
|
#
|
|
# returns: string
|
|
|
|
Net::SSLeay::OpenSSL_version();
|
|
#is equivalent to
|
|
Net::SSLeay::OpenSSL_version(OPENSSL_VERSION);
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/crypto/OpenSSL_version.html">https://www.openssl.org/docs/crypto/OpenSSL_version.html</A>>
|
|
</DL>
|
|
<P>
|
|
|
|
<I>Low level </I><FONT SIZE="-1"><I>API:</I></FONT><I> Initialization related functions</I>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="41">•<DD>
|
|
library_init
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Initialize <FONT SIZE="-1">SSL</FONT> library by registering algorithms.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::library_init();
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_library_init.html">http://www.openssl.org/docs/ssl/SSL_library_init.html</A>>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
While the original function from OpenSSL always returns 1, Net::SSLeay adds a
|
|
wrapper around it to make sure that the OpenSSL function is only called once.
|
|
Thus the function will return 1 if initialization was done and 0 if not, i.e. if
|
|
initialization was done already before.
|
|
<DT id="42">•<DD>
|
|
add_ssl_algorithms
|
|
|
|
|
|
<P>
|
|
|
|
|
|
The alias for ``library_init''
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::add_ssl_algorithms();
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="43">•<DD>
|
|
OpenSSL_add_ssl_algorithms
|
|
|
|
|
|
<P>
|
|
|
|
|
|
The alias for ``library_init''
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::OpenSSL_add_ssl_algorithms();
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="44">•<DD>
|
|
SSLeay_add_ssl_algorithms
|
|
|
|
|
|
<P>
|
|
|
|
|
|
The alias for ``library_init''
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::SSLeay_add_ssl_algorithms();
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="45">•<DD>
|
|
load_error_strings
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Registers the error strings for all libcrypto + libssl related functions.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::load_error_strings();
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/ERR_load_crypto_strings.html">http://www.openssl.org/docs/crypto/ERR_load_crypto_strings.html</A>>
|
|
<DT id="46">•<DD>
|
|
ERR_load_crypto_strings
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Registers the error strings for all libcrypto functions. No need to call this function if you have already called ``load_error_strings''.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::ERR_load_crypto_strings();
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/ERR_load_crypto_strings.html">http://www.openssl.org/docs/crypto/ERR_load_crypto_strings.html</A>>
|
|
<DT id="47">•<DD>
|
|
ERR_load_RAND_strings
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Registers the error strings for <FONT SIZE="-1">RAND</FONT> related functions. No need to call this function if you have already called ``load_error_strings''.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::ERR_load_RAND_strings();
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="48">•<DD>
|
|
ERR_load_SSL_strings
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Registers the error strings for <FONT SIZE="-1">SSL</FONT> related functions. No need to call this function if you have already called ``load_error_strings''.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::ERR_load_SSL_strings();
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="49">•<DD>
|
|
OpenSSL_add_all_algorithms
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Add algorithms to internal table.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::OpenSSL_add_all_algorithms();
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/OpenSSL_add_all_algorithms.html">http://www.openssl.org/docs/crypto/OpenSSL_add_all_algorithms.html</A>>
|
|
<DT id="50">•<DD>
|
|
OPENSSL_add_all_algorithms_conf
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Similar to ``OpenSSL_add_all_algorithms'' - will <FONT SIZE="-1">ALWAYS</FONT> load the config file
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::OPENSSL_add_all_algorithms_conf();
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="51">•<DD>
|
|
OPENSSL_add_all_algorithms_noconf
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Similar to ``OpenSSL_add_all_algorithms'' - will <FONT SIZE="-1">NEVER</FONT> load the config file
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::OPENSSL_add_all_algorithms_noconf();
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
</DL>
|
|
<P>
|
|
|
|
<I>Low level </I><FONT SIZE="-1"><I>API:</I></FONT><I> ERR_* and SSL_alert_* related functions</I>
|
|
|
|
|
|
<P>
|
|
|
|
<B></B><FONT SIZE="-1"><B>NOTE:</B></FONT><B></B> Please note that SSL_alert_* function have ``<FONT SIZE="-1">SSL_''</FONT> part stripped from their names.
|
|
<DL COMPACT>
|
|
<DT id="52">•<DD>
|
|
ERR_clear_error
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Clear the error queue.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::ERR_clear_error();
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/ERR_clear_error.html">http://www.openssl.org/docs/crypto/ERR_clear_error.html</A>>
|
|
<DT id="53">•<DD>
|
|
ERR_error_string
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Generates a human-readable string representing the error code <TT>$error</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::ERR_error_string($error);
|
|
# $error - (unsigned integer) error code
|
|
#
|
|
# returns: string
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/ERR_error_string.html">http://www.openssl.org/docs/crypto/ERR_error_string.html</A>>
|
|
<DT id="54">•<DD>
|
|
ERR_get_error
|
|
|
|
|
|
<P>
|
|
|
|
|
|
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.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::ERR_get_error();
|
|
#
|
|
# returns: (unsigned integer) error code
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/ERR_get_error.html">http://www.openssl.org/docs/crypto/ERR_get_error.html</A>>
|
|
<DT id="55">•<DD>
|
|
ERR_peek_error
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the earliest error code from the thread's error queue without modifying it.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::ERR_peek_error();
|
|
#
|
|
# returns: (unsigned integer) error code
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/ERR_get_error.html">http://www.openssl.org/docs/crypto/ERR_get_error.html</A>>
|
|
<DT id="56">•<DD>
|
|
ERR_put_error
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Adds an error code to the thread's error queue. It signals that the error of <TT>$reason</TT>
|
|
code reason occurred in function <TT>$func</TT> of library <TT>$lib</TT>, in line number <TT>$line</TT> of <TT>$file</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/ERR_put_error.html">http://www.openssl.org/docs/crypto/ERR_put_error.html</A>>
|
|
and <<A HREF="http://www.openssl.org/docs/crypto/err.html">http://www.openssl.org/docs/crypto/err.html</A>>
|
|
<DT id="57">•<DD>
|
|
alert_desc_string
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns a two letter string as a short form describing the reason of the alert specified by value.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_alert_type_string.html">http://www.openssl.org/docs/ssl/SSL_alert_type_string.html</A>>
|
|
<DT id="58">•<DD>
|
|
alert_desc_string_long
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns a string describing the reason of the alert specified by value.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_alert_type_string.html">http://www.openssl.org/docs/ssl/SSL_alert_type_string.html</A>>
|
|
<DT id="59">•<DD>
|
|
alert_type_string
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns a one letter string indicating the type of the alert specified by value.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_alert_type_string.html">http://www.openssl.org/docs/ssl/SSL_alert_type_string.html</A>>
|
|
<DT id="60">•<DD>
|
|
alert_type_string_long
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns a string indicating the type of the alert specified by value.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_alert_type_string.html">http://www.openssl.org/docs/ssl/SSL_alert_type_string.html</A>>
|
|
</DL>
|
|
<P>
|
|
|
|
<I>Low level </I><FONT SIZE="-1"><I>API:</I></FONT><I> SSL_METHOD_* related functions</I>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="61">•<DD>
|
|
SSLv23_method, SSLv23_server_method and SSLv23_client_method
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.82 and before.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns <FONT SIZE="-1">SSL_METHOD</FONT> structure corresponding to general-purpose version-flexible <FONT SIZE="-1">TLS</FONT> method, the return value can be later used as a param of ``CTX_new_with_method''.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>NOTE:</B></FONT><B></B> Consider using TLS_method, TLS_server_method or TLS_client_method with new code.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::SSLv2_method();
|
|
#
|
|
# returns: value corresponding to openssl's SSL_METHOD structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="62">•<DD>
|
|
SSLv2_method
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns <FONT SIZE="-1">SSL_METHOD</FONT> structure corresponding to SSLv2 method, the return value can be later used as a param of ``CTX_new_with_method''. Only available where supported by the underlying openssl.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::SSLv2_method();
|
|
#
|
|
# returns: value corresponding to openssl's SSL_METHOD structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="63">•<DD>
|
|
SSLv3_method
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns <FONT SIZE="-1">SSL_METHOD</FONT> structure corresponding to SSLv3 method, the return value can be later used as a param of ``CTX_new_with_method''.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::SSLv3_method();
|
|
#
|
|
# returns: value corresponding to openssl's SSL_METHOD structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_new.html">http://www.openssl.org/docs/ssl/SSL_CTX_new.html</A>>
|
|
<DT id="64">•<DD>
|
|
TLSv1_method, TLSv1_server_method and TLSv1_client_method
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> Server and client methods not available in Net-SSLeay-1.82 and before.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns <FONT SIZE="-1">SSL_METHOD</FONT> structure corresponding to TLSv1 method, the return value can be later used as a param of ``CTX_new_with_method''.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::TLSv1_method();
|
|
#
|
|
# returns: value corresponding to openssl's SSL_METHOD structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_new.html">http://www.openssl.org/docs/ssl/SSL_CTX_new.html</A>>
|
|
<DT id="65">•<DD>
|
|
TLSv1_1_method, TLSv1_1_server_method and TLSv1_1_client_method
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> Server and client methods not available in Net-SSLeay-1.82 and before.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns <FONT SIZE="-1">SSL_METHOD</FONT> structure corresponding to TLSv1_1 method, the return value can be later used as a param of ``CTX_new_with_method''. Only available where supported by the underlying openssl.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::TLSv1_1_method();
|
|
#
|
|
# returns: value corresponding to openssl's SSL_METHOD structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_new.html">http://www.openssl.org/docs/ssl/SSL_CTX_new.html</A>>
|
|
<DT id="66">•<DD>
|
|
TLSv1_2_method, TLSv1_2_server_method and TLSv1_2_client_method
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> Server and client methods not available in Net-SSLeay-1.82 and before.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns <FONT SIZE="-1">SSL_METHOD</FONT> structure corresponding to TLSv1_2 method, the return value can be later used as a param of ``CTX_new_with_method''. Only available where supported by the underlying openssl.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::TLSv1_2_method();
|
|
#
|
|
# returns: value corresponding to openssl's SSL_METHOD structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_new.html">http://www.openssl.org/docs/ssl/SSL_CTX_new.html</A>>
|
|
<DT id="67">•<DD>
|
|
TLS_method, TLS_server_method and TLS_client_method
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> Not available in Net-SSLeay-1.82 and before.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns <FONT SIZE="-1">SSL_METHOD</FONT> structure corresponding to general-purpose version-flexible <FONT SIZE="-1">TLS</FONT> method, the return value can be later used as a param of ``CTX_new_with_method''. Only available where supported by the underlying openssl.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::TLS_method();
|
|
#
|
|
# returns: value corresponding to openssl's SSL_METHOD structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_new.html">http://www.openssl.org/docs/ssl/SSL_CTX_new.html</A>>
|
|
</DL>
|
|
<P>
|
|
|
|
<I>Low level </I><FONT SIZE="-1"><I>API:</I></FONT><I> ENGINE_* related functions</I>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="68">•<DD>
|
|
ENGINE_load_builtin_engines
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> Requires an OpenSSL build with dynamic engine loading support.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Load all bundled ENGINEs into memory and make them visible.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::ENGINE_load_builtin_engines();
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/engine.html">http://www.openssl.org/docs/crypto/engine.html</A>>
|
|
<DT id="69">•<DD>
|
|
ENGINE_register_all_complete
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> Requires an OpenSSL build with dynamic engine loading support.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Register all loaded ENGINEs for every algorithm they collectively implement.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::ENGINE_register_all_complete();
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/engine.html">http://www.openssl.org/docs/crypto/engine.html</A>>
|
|
<DT id="70">•<DD>
|
|
ENGINE_set_default
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> Requires an OpenSSL build with dynamic engine loading support.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Set default engine to <TT>$e</TT> + set its flags to <TT>$flags</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/engine.html">http://www.openssl.org/docs/crypto/engine.html</A>>
|
|
<DT id="71">•<DD>
|
|
ENGINE_by_id
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Get <FONT SIZE="-1">ENGINE</FONT> by its identification <TT>$id</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> Requires an OpenSSL build with dynamic engine loading support.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/engine.html">http://www.openssl.org/docs/crypto/engine.html</A>>
|
|
</DL>
|
|
<P>
|
|
|
|
<I>Low level </I><FONT SIZE="-1"><I>API:</I></FONT><I> EVP_PKEY_* related functions</I>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="72">•<DD>
|
|
EVP_PKEY_copy_parameters
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Copies the parameters from key <TT>$from</TT> to key <TT>$to</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/EVP_PKEY_cmp.html">http://www.openssl.org/docs/crypto/EVP_PKEY_cmp.html</A>>
|
|
<DT id="73">•<DD>
|
|
EVP_PKEY_new
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Creates a new <FONT SIZE="-1">EVP_PKEY</FONT> structure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::EVP_PKEY_new();
|
|
#
|
|
# returns: value corresponding to openssl's EVP_PKEY structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/EVP_PKEY_new.html">http://www.openssl.org/docs/crypto/EVP_PKEY_new.html</A>>
|
|
<DT id="74">•<DD>
|
|
EVP_PKEY_free
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Free an allocated <FONT SIZE="-1">EVP_PKEY</FONT> structure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::EVP_PKEY_free($pkey);
|
|
# $pkey - value corresponding to openssl's EVP_PKEY structure
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/EVP_PKEY_new.html">http://www.openssl.org/docs/crypto/EVP_PKEY_new.html</A>>
|
|
<DT id="75">•<DD>
|
|
EVP_PKEY_assign_RSA
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Set the key referenced by <TT>$pkey</TT> to <TT>$key</TT>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>NOTE:</B></FONT><B></B> No reference counter will be increased, i.e. <TT>$key</TT> will be freed if
|
|
<TT>$pkey</TT> is freed.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/EVP_PKEY_assign_RSA.html">http://www.openssl.org/docs/crypto/EVP_PKEY_assign_RSA.html</A>>
|
|
<DT id="76">•<DD>
|
|
EVP_PKEY_assign_EC_KEY
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.74 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Set the key referenced by <TT>$pkey</TT> to <TT>$key</TT>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>NOTE:</B></FONT><B></B> No reference counter will be increased, i.e. <TT>$key</TT> will be freed if
|
|
<TT>$pkey</TT> is freed.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::EVP_PKEY_assign_EC_KEY($pkey, $key);
|
|
# $pkey - value corresponding to openssl's EVP_PKEY structure
|
|
# $key - value corresponding to openssl's EC_KEY structure
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/EVP_PKEY_assign_EC_KEY.html">http://www.openssl.org/docs/crypto/EVP_PKEY_assign_EC_KEY.html</A>>
|
|
<DT id="77">•<DD>
|
|
EVP_PKEY_bits
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the size of the key <TT>$pkey</TT> in bits.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::EVP_PKEY_bits($pkey);
|
|
# $pkey - value corresponding to openssl's EVP_PKEY structure
|
|
#
|
|
# returns: size in bits
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="78">•<DD>
|
|
EVP_PKEY_size
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the maximum size of a signature in bytes. The actual signature may be smaller.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::EVP_PKEY_size($pkey);
|
|
# $pkey - value corresponding to openssl's EVP_PKEY structure
|
|
#
|
|
# returns: the maximum size in bytes
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/EVP_SignInit.html">http://www.openssl.org/docs/crypto/EVP_SignInit.html</A>>
|
|
<DT id="79">•<DD>
|
|
EVP_PKEY_id
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before; requires at least openssl-1.0.0
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns <TT>$pkey</TT> type (integer value of corresponding <FONT SIZE="-1">NID</FONT>).
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::EVP_PKEY_id($pkey);
|
|
# $pkey - value corresponding to openssl's EVP_PKEY structure
|
|
#
|
|
# returns: (integer) key type
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Example:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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'
|
|
|
|
</PRE>
|
|
|
|
|
|
</DL>
|
|
<P>
|
|
|
|
<I>Low level </I><FONT SIZE="-1"><I>API:</I></FONT><I> PEM_* related functions</I>
|
|
|
|
|
|
<P>
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/pem.html">http://www.openssl.org/docs/crypto/pem.html</A>>
|
|
<DL COMPACT>
|
|
<DT id="80">•<DD>
|
|
PEM_read_bio_X509
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Loads <FONT SIZE="-1">PEM</FONT> formatted X509 certificate via given <FONT SIZE="-1">BIO</FONT> structure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Example:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $bio = Net::SSLeay::BIO_new_file($filename, 'r');
|
|
my $x509 = Net::SSLeay::PEM_read_bio_X509($bio);
|
|
Net::SSLeay::BIO_free($bio);
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="81">•<DD>
|
|
PEM_read_bio_X509_REQ
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Loads <FONT SIZE="-1">PEM</FONT> formatted X509_REQ object via given <FONT SIZE="-1">BIO</FONT> structure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Example:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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);
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="82">•<DD>
|
|
PEM_read_bio_DHparams
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Reads <FONT SIZE="-1">DH</FONT> structure from <FONT SIZE="-1">BIO.</FONT>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="83">•<DD>
|
|
PEM_read_bio_X509_CRL
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Reads X509_CRL structure from <FONT SIZE="-1">BIO.</FONT>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="84">•<DD>
|
|
PEM_read_bio_PrivateKey
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Loads <FONT SIZE="-1">PEM</FONT> formatted private key via given <FONT SIZE="-1">BIO</FONT> structure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Example:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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);
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
To use password you have the following options:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
$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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Callback function signature:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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";
|
|
}
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="85">•<DD>
|
|
PEM_X509_INFO_read_bio
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Reads a <FONT SIZE="-1">BIO</FONT> containing a <FONT SIZE="-1">PEM</FONT> formatted file into a <FONT SIZE="-1">STACK_OF</FONT>(X509_INFO) structure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::PEM_X509_INFO_read_bio($bio);
|
|
# $bio - value corresponding to openssl's BIO structure
|
|
#
|
|
# returns: value corresponding to openssl's STACK_OF(X509_INFO) structure.
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Example:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $bio = Net::SSLeay::BIO_new_file($filename, 'r');
|
|
my $sk_x509_info = Net::SSLeay::PEM_X509_INFO_read_bio($bio);
|
|
Net::SSLeay::BIO_free($bio);
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="86">•<DD>
|
|
PEM_get_string_X509
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>NOTE:</B></FONT><B></B> Does not exactly correspond to any low level <FONT SIZE="-1">API</FONT> function
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Converts/exports X509 certificate to string (<FONT SIZE="-1">PEM</FONT> format).
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::PEM_get_string_X509($x509);
|
|
# $x509 - value corresponding to openssl's X509 structure
|
|
#
|
|
# returns: string with $x509 in PEM format
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="87">•<DD>
|
|
PEM_get_string_PrivateKey
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Converts public key <TT>$pk</TT> into <FONT SIZE="-1">PEM</FONT> formatted string (optionally protected with password).
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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 formatted string
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Examples:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
$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"));
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="88">•<DD>
|
|
PEM_get_string_X509_CRL
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Converts X509_CRL object <TT>$x509_crl</TT> into <FONT SIZE="-1">PEM</FONT> formatted string.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::PEM_get_string_X509_CRL($x509_crl);
|
|
# $x509_crl - value corresponding to openssl's X509_CRL structure
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="89">•<DD>
|
|
PEM_get_string_X509_REQ
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Converts X509_REQ object <TT>$x509_crl</TT> into <FONT SIZE="-1">PEM</FONT> formatted string.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::PEM_get_string_X509_REQ($x509_req);
|
|
# $x509_req - value corresponding to openssl's X509_REQ structure
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
</DL>
|
|
<P>
|
|
|
|
<I>Low level </I><FONT SIZE="-1"><I>API:</I></FONT><I> d2i_* (</I><FONT SIZE="-1"><I>DER</I></FONT><I> format) related functions</I>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="90">•<DD>
|
|
d2i_X509_bio
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Loads <FONT SIZE="-1">DER</FONT> formatted X509 certificate via given <FONT SIZE="-1">BIO</FONT> structure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Example:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $bio = Net::SSLeay::BIO_new_file($filename, 'rb');
|
|
my $x509 = Net::SSLeay::d2i_X509_bio($bio);
|
|
Net::SSLeay::BIO_free($bio);
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/d2i_X509.html">http://www.openssl.org/docs/crypto/d2i_X509.html</A>>
|
|
<DT id="91">•<DD>
|
|
d2i_X509_CRL_bio
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Loads <FONT SIZE="-1">DER</FONT> formatted X509_CRL object via given <FONT SIZE="-1">BIO</FONT> structure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Example:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $bio = Net::SSLeay::BIO_new_file($filename, 'rb');
|
|
my $x509_crl = Net::SSLeay::d2i_X509_CRL_bio($bio);
|
|
Net::SSLeay::BIO_free($bio);
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="92">•<DD>
|
|
d2i_X509_REQ_bio
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Loads <FONT SIZE="-1">DER</FONT> formatted X509_REQ object via given <FONT SIZE="-1">BIO</FONT> structure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Example:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $bio = Net::SSLeay::BIO_new_file($filename, 'rb');
|
|
my $x509_req = Net::SSLeay::d2i_X509_REQ_bio($bio);
|
|
Net::SSLeay::BIO_free($bio);
|
|
|
|
</PRE>
|
|
|
|
|
|
</DL>
|
|
<P>
|
|
|
|
<I>Low level </I><FONT SIZE="-1"><I>API: PKCS12</I></FONT><I> related functions</I>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="93">•<DD>
|
|
P_PKCS12_load_file
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Loads X509 certificate + private key + certificates of <FONT SIZE="-1">CA</FONT> chain (if present in <FONT SIZE="-1">PKCS12</FONT> file).
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>IMPORTANT NOTE:</B></FONT><B></B> after you do the job you need to call <B>X509_free()</B> on <TT>$privkey</TT> + all members
|
|
of <TT>@cachain</TT> and <B>EVP_PKEY_free()</B> on <TT>$privkey</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Examples:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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);
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>NOTE</B></FONT><B></B> With some combinations of Windows, perl, compiler and compiler options, you
|
|
may see a runtime error ``no OPENSSL_Applink'', when calling
|
|
Net::SSLeay::P_PKCS12_load_file. See <FONT SIZE="-1">README</FONT>.Win32 for more details.
|
|
</DL>
|
|
<P>
|
|
|
|
<I>Low level </I><FONT SIZE="-1"><I>API:</I></FONT><I> SESSION_* related functions</I>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="94">•<DD>
|
|
d2i_SSL_SESSION
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> does not work in Net-SSLeay-1.85 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Transforms the binary <FONT SIZE="-1">ASN1</FONT> representation string of an <FONT SIZE="-1">SSL/TLS</FONT> session into an
|
|
<FONT SIZE="-1">SSL_SESSION</FONT> object.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $ses = Net::SSLeay::d2i_SSL_SESSION($data);
|
|
# $data - the session as ASN1 representation string
|
|
#
|
|
# returns: $ses - the new SSL_SESSION
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/ssl/i2d_SSL_SESSION.html">https://www.openssl.org/docs/ssl/i2d_SSL_SESSION.html</A>>
|
|
<DT id="95">•<DD>
|
|
i2d_SSL_SESSION
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> does not work in Net-SSLeay-1.85 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Transforms the <FONT SIZE="-1">SSL_SESSION</FONT> object in into the <FONT SIZE="-1">ASN1</FONT> representation and returns
|
|
it as string.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $data = Net::SSLeay::i2d_SSL_SESSION($ses);
|
|
# $ses - value corresponding to openssl's SSL_SESSION structure
|
|
#
|
|
# returns: $data - session as string
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/ssl/d2i_SSL_SESSION.html">https://www.openssl.org/docs/ssl/d2i_SSL_SESSION.html</A>>
|
|
<DT id="96">•<DD>
|
|
SESSION_new
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Creates a new <FONT SIZE="-1">SSL_SESSION</FONT> structure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::SESSION_new();
|
|
#
|
|
# returns: value corresponding to openssl's SSL_SESSION structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="97">•<DD>
|
|
SESSION_free
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Free an allocated <FONT SIZE="-1">SSL_SESSION</FONT> structure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::SESSION_free($ses);
|
|
# $ses - value corresponding to openssl's SSL_SESSION structure
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_SESSION_free.html">http://www.openssl.org/docs/ssl/SSL_SESSION_free.html</A>>
|
|
<DT id="98">•<DD>
|
|
SESSION_up_ref
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.0 or LibreSSL 2.7.0
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Increases the reference counter on a <FONT SIZE="-1">SSL_SESSION</FONT> structure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::SESSION_up_ref($ses);
|
|
# $ses - value corresponding to openssl's SSL_SESSION structure
|
|
#
|
|
# returns: 1 on success else 0
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc
|
|
<<A HREF="https://www.openssl.org/docs/ssl/SSL_SESSION_up_ref.html">https://www.openssl.org/docs/ssl/SSL_SESSION_up_ref.html</A>>
|
|
<DT id="99">•<DD>
|
|
SESSION_dup
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.1, not in LibreSSL
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Duplicates a <FONT SIZE="-1">SSL_SESSION</FONT> structure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::SESSION_dup($ses);
|
|
# $ses - value corresponding to openssl's SSL_SESSION structure
|
|
#
|
|
# returns: the duplicated session
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc
|
|
<<A HREF="https://www.openssl.org/docs/ssl/SSL_SESSION_dup.html">https://www.openssl.org/docs/ssl/SSL_SESSION_dup.html</A>>
|
|
<DT id="100">•<DD>
|
|
SESSION_is_resumable
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.1, not in LibreSSL
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Determine whether an <FONT SIZE="-1">SSL_SESSION</FONT> object can be used for resumption.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::SESSION_is_resumable($ses);
|
|
# $ses - value corresponding to openssl's SSL_SESSION structure
|
|
#
|
|
# returns: (integer) 1 if it can or 0 if not
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/manmaster/man3/SSL_SESSION_is_resumable.html">https://www.openssl.org/docs/manmaster/man3/SSL_SESSION_is_resumable.html</A>>
|
|
<DT id="101">•<DD>
|
|
SESSION_cmp
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Compare two <FONT SIZE="-1">SSL_SESSION</FONT> structures.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>NOTE:</B></FONT><B></B> Not available in openssl 1.0 or later
|
|
<DT id="102">•<DD>
|
|
SESSION_get_app_data
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Can be used to get application defined value/data.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::SESSION_get_app_data($ses);
|
|
# $ses - value corresponding to openssl's SSL_SESSION structure
|
|
#
|
|
# returns: string/buffer/pointer ???
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="103">•<DD>
|
|
SESSION_set_app_data
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Can be used to set some application defined value/data.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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: ???
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="104">•<DD>
|
|
SESSION_get_ex_data
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Is used to retrieve the information for <TT>$idx</TT> from session <TT>$ses</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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 ???
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_SESSION_get_ex_new_index.html">http://www.openssl.org/docs/ssl/SSL_SESSION_get_ex_new_index.html</A>>
|
|
<DT id="105">•<DD>
|
|
SESSION_set_ex_data
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Is used to store application data at arg for idx into the session object.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_SESSION_get_ex_new_index.html">http://www.openssl.org/docs/ssl/SSL_SESSION_get_ex_new_index.html</A>>
|
|
<DT id="106">•<DD>
|
|
SESSION_get_ex_new_index
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Is used to register a new index for application specific data.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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) ???
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_SESSION_get_ex_new_index.html">http://www.openssl.org/docs/ssl/SSL_SESSION_get_ex_new_index.html</A>>
|
|
<DT id="107">•<DD>
|
|
SESSION_get_master_key
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>NOTE:</B></FONT><B></B> Does not exactly correspond to any low level <FONT SIZE="-1">API</FONT> function
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns 'master_key' value from <FONT SIZE="-1">SSL_SESSION</FONT> structure <TT>$s</TT>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::SESSION_get_master_key($s);
|
|
# $s - value corresponding to openssl's SSL_SESSION structure
|
|
#
|
|
# returns: master key (binary data)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="108">•<DD>
|
|
SESSION_set_master_key
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets 'master_key' value for <FONT SIZE="-1">SSL_SESSION</FONT> structure <TT>$s</TT>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Not available with OpenSSL 1.1 and later.
|
|
Code that previously used
|
|
<BR> SESSION_set_master_key must now set <TT>$secret</TT> in the session_secret
|
|
<BR> callback set with SSL_set_session_secret_cb.
|
|
<DT id="109">•<DD>
|
|
SESSION_get_time
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the time at which the session s was established.
|
|
The time is given in seconds since 1.1.1970.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::SESSION_get_time($s);
|
|
# $s - value corresponding to openssl's SSL_SESSION structure
|
|
#
|
|
# returns: timestamp (seconds since 1.1.1970)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_SESSION_get_time.html">http://www.openssl.org/docs/ssl/SSL_SESSION_get_time.html</A>>
|
|
<DT id="110">•<DD>
|
|
get_time
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Technically the same functionality as ``SESSION_get_time''.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::get_time($s);
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="111">•<DD>
|
|
SESSION_get_timeout
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the timeout value set for session <TT>$s</TT> in seconds.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::SESSION_get_timeout($s);
|
|
# $s - value corresponding to openssl's SSL_SESSION structure
|
|
#
|
|
# returns: timeout (in seconds)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_SESSION_get_time.html">http://www.openssl.org/docs/ssl/SSL_SESSION_get_time.html</A>>
|
|
<DT id="112">•<DD>
|
|
get_timeout
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Technically the same functionality as ``SESSION_get_timeout''.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::get_timeout($s);
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="113">•<DD>
|
|
SESSION_print
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>NOTE:</B></FONT><B></B> Does not exactly correspond to any low level <FONT SIZE="-1">API</FONT> function
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Prints session details (e.g. protocol version, cipher, session-id ...) to <FONT SIZE="-1">BIO.</FONT>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
You have to use necessary <FONT SIZE="-1">BIO</FONT> functions like this:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
# 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);
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="114">•<DD>
|
|
SESSION_print_fp
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Prints session details (e.g. protocol version, cipher, session-id ...) to file handle.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Example:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
# 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);
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="115">•<DD>
|
|
SESSION_set_time
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Replaces the creation time of the session s with the chosen value <TT>$t</TT> (seconds since 1.1.1970).
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_SESSION_get_time.html">http://www.openssl.org/docs/ssl/SSL_SESSION_get_time.html</A>>
|
|
<DT id="116">•<DD>
|
|
set_time
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Technically the same functionality as ``SESSION_set_time''.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::set_time($ses, $t);
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="117">•<DD>
|
|
SESSION_set_timeout
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the timeout value for session s in seconds to <TT>$t</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_SESSION_get_time.html">http://www.openssl.org/docs/ssl/SSL_SESSION_get_time.html</A>>
|
|
<DT id="118">•<DD>
|
|
set_timeout
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Technically the same functionality as ``SESSION_set_timeout''.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::set_timeout($ses, $t);
|
|
|
|
</PRE>
|
|
|
|
|
|
</DL>
|
|
<P>
|
|
|
|
<I>Low level </I><FONT SIZE="-1"><I>API:</I></FONT><I> SSL_CTX_* related functions</I>
|
|
|
|
|
|
<P>
|
|
|
|
<B></B><FONT SIZE="-1"><B>NOTE:</B></FONT><B></B> Please note that the function described in this chapter have ``<FONT SIZE="-1">SSL_''</FONT> part stripped from their original openssl names.
|
|
<DL COMPACT>
|
|
<DT id="119">•<DD>
|
|
CTX_add_client_CA
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Adds the <FONT SIZE="-1">CA</FONT> name extracted from <TT>$cacert</TT> to the list of CAs sent to the client when requesting a client certificate for <TT>$ctx</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_client_CA_list.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_client_CA_list.html</A>>
|
|
<DT id="120">•<DD>
|
|
CTX_add_extra_chain_cert
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Adds the certificate <TT>$x509</TT> to the certificate chain presented together with the certificate. Several certificates can be added one after the other.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_add_extra_chain_cert.html">http://www.openssl.org/docs/ssl/SSL_CTX_add_extra_chain_cert.html</A>>
|
|
<DT id="121">•<DD>
|
|
CTX_add_session
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Adds the session <TT>$ses</TT> to the context <TT>$ctx</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_add_session.html">http://www.openssl.org/docs/ssl/SSL_CTX_add_session.html</A>>
|
|
<DT id="122">•<DD>
|
|
CTX_callback_ctrl
|
|
|
|
|
|
<P>
|
|
|
|
|
|
??? (more info needed)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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: ???
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_ctrl.html">http://www.openssl.org/docs/ssl/SSL_CTX_ctrl.html</A>>
|
|
<DT id="123">•<DD>
|
|
CTX_check_private_key
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Checks the consistency of a private key with the corresponding certificate loaded into <TT>$ctx</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_use_certificate.html">http://www.openssl.org/docs/ssl/SSL_CTX_use_certificate.html</A>>
|
|
<DT id="124">•<DD>
|
|
CTX_ctrl
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Internal handling function for <FONT SIZE="-1">SSL_CTX</FONT> objects.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>BEWARE:</B></FONT><B></B> openssl doc says: This function should never be called directly!
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_ctrl.html">http://www.openssl.org/docs/ssl/SSL_CTX_ctrl.html</A>>
|
|
<DT id="125">•<DD>
|
|
CTX_flush_sessions
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Causes a run through the session cache of <TT>$ctx</TT> to remove sessions expired at time <TT>$tm</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_flush_sessions.html">http://www.openssl.org/docs/ssl/SSL_CTX_flush_sessions.html</A>>
|
|
<DT id="126">•<DD>
|
|
CTX_free
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Free an allocated <FONT SIZE="-1">SSL_CTX</FONT> object.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::CTX_free($ctx);
|
|
# $ctx - value corresponding to openssl's SSL_CTX structure
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_free.html">http://www.openssl.org/docs/ssl/SSL_CTX_free.html</A>>
|
|
<DT id="127">•<DD>
|
|
CTX_get_app_data
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Can be used to get application defined value/data.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::CTX_get_app_data($ctx);
|
|
# $ctx - value corresponding to openssl's SSL_CTX structure
|
|
#
|
|
# returns: string/buffer/pointer ???
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="128">•<DD>
|
|
CTX_set_app_data
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Can be used to set some application defined value/data.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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: ???
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="129">•<DD>
|
|
CTX_get0_param
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.82 and before; requires at least OpenSSL 1.0.2
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the current verification parameters.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $vpm = Net::SSLeay::CTX_get0_param($ctx);
|
|
# $ctx - value corresponding to openssl's SSL_CTX structure
|
|
#
|
|
# returns: value corresponding to openssl's X509_VERIFY_PARAM structure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/ssl/SSL_CTX_get0_param.html">https://www.openssl.org/docs/ssl/SSL_CTX_get0_param.html</A>>
|
|
<DT id="130">•<DD>
|
|
CTX_get_cert_store
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the current certificate verification storage.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_cert_store.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_cert_store.html</A>>
|
|
<DT id="131">•<DD>
|
|
CTX_get_client_CA_list
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the list of client CAs explicitly set for <TT>$ctx</TT> using ``CTX_set_client_CA_list''.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_get_client_CA_list.html">http://www.openssl.org/docs/ssl/SSL_get_client_CA_list.html</A>>
|
|
<DT id="132">•<DD>
|
|
CTX_get_ex_data
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Is used to retrieve the information for index <TT>$idx</TT> from <TT>$ctx</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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 ???
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_get_ex_new_index.html">http://www.openssl.org/docs/ssl/SSL_CTX_get_ex_new_index.html</A>>
|
|
<DT id="133">•<DD>
|
|
CTX_get_ex_new_index
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Is used to register a new index for application specific data.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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) ???
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_get_ex_new_index.html">http://www.openssl.org/docs/ssl/SSL_CTX_get_ex_new_index.html</A>>
|
|
<DT id="134">•<DD>
|
|
CTX_get_mode
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the mode set for ctx.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_mode.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_mode.html</A>>
|
|
<DT id="135">•<DD>
|
|
CTX_set_mode
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Adds the mode set via bitmask in <TT>$mode</TT> to <TT>$ctx</TT>. Options already set before are not cleared.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
For bitmask details see ``CTX_get_mode'' (above).
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_mode.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_mode.html</A>>
|
|
<DT id="136">•<DD>
|
|
CTX_get_options
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the options (bitmask) set for <TT>$ctx</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::CTX_get_options($ctx);
|
|
# $ctx - value corresponding to openssl's SSL_CTX structure
|
|
#
|
|
# returns: options (bitmask)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>BEWARE:</B></FONT><B></B> The available constants and their values in bitmask depend
|
|
on the <FONT SIZE="-1">TLS</FONT> library. For example, SSL_OP_NO_TLSv1_3 became available
|
|
much later than <FONT SIZE="-1">SSL_OP_NO_COMPRESS</FONT> which is already deprecated by some
|
|
libraries. Also, some previously used option values have been recycled
|
|
and are now used for newer options. See the list of constants in this
|
|
document for options Net::SSLeay currently supports.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
You are strongly encouraged to <B>check your </B><FONT SIZE="-1"><B>TLS</B></FONT><B> library</B> if you need
|
|
to use numeric values directly. The following is a sample of historic
|
|
values. It may not be correct anymore.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
#to decode the return value (bitmask) use:
|
|
0x00000004 corresponds to SSL_OP_LEGACY_SERVER_CONNECT
|
|
0x00000800 corresponds to SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS
|
|
0x00004000 corresponds to SSL_OP_NO_TICKET
|
|
0x00010000 corresponds to SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION
|
|
0x00400000 corresponds to SSL_OP_CIPHER_SERVER_PREFERENCE
|
|
0x04000000 corresponds to SSL_OP_NO_TLSv1
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_options.html">https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_options.html</A>>
|
|
<DT id="137">•<DD>
|
|
CTX_set_options
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Adds the options set via bitmask in <TT>$options</TT> to ctx. Options already set before are not cleared.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
For bitmask details see ``CTX_get_options'' (above).
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_options.html">https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_options.html</A>>
|
|
<DT id="138">•<DD>
|
|
CTX_get_quiet_shutdown
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the 'quiet shutdown' setting of <TT>$ctx</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::CTX_get_quiet_shutdown($ctx);
|
|
# $ctx - value corresponding to openssl's SSL_CTX structure
|
|
#
|
|
# returns: (integer) the current setting
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_quiet_shutdown.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_quiet_shutdown.html</A>>
|
|
<DT id="139">•<DD>
|
|
CTX_get_read_ahead
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::CTX_get_read_ahead($ctx);
|
|
# $ctx - value corresponding to openssl's SSL_CTX structure
|
|
#
|
|
# returns: (integer) read_ahead value
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="140">•<DD>
|
|
CTX_get_session_cache_mode
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the currently used cache mode (bitmask).
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::CTX_get_session_cache_mode($ctx);
|
|
# $ctx - value corresponding to openssl's SSL_CTX structure
|
|
#
|
|
# returns: mode (bitmask)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>BEWARE:</B></FONT><B></B> <FONT SIZE="-1">SESS_CACHE_OFF</FONT> and other constants are not available in
|
|
Net-SSLeay-1.82 and before. If the constants are not available, the
|
|
following values have historically been correct. You are strongly
|
|
encouraged to <B>check your </B><FONT SIZE="-1"><B>TLS</B></FONT><B> library</B> for the current values.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
#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)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_session_cache_mode.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_session_cache_mode.html</A>>
|
|
<DT id="141">•<DD>
|
|
CTX_set_session_cache_mode
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Enables/disables session caching by setting the operational mode for <TT>$ctx</TT> to <TT>$mode</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
For bitmask details see ``CTX_get_session_cache_mode'' (above).
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_session_cache_mode.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_session_cache_mode.html</A>>
|
|
<DT id="142">•<DD>
|
|
CTX_get_timeout
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the currently set timeout value for <TT>$ctx</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::CTX_get_timeout($ctx);
|
|
# $ctx - value corresponding to openssl's SSL_CTX structure
|
|
#
|
|
# returns: timeout in seconds
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_timeout.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_timeout.html</A>>
|
|
<DT id="143">•<DD>
|
|
CTX_get_verify_depth
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the verification depth limit currently set in <TT>$ctx</TT>. If no limit has been explicitly set, -1 is returned and the default value will be used.",
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_get_verify_mode.html">http://www.openssl.org/docs/ssl/SSL_CTX_get_verify_mode.html</A>>
|
|
<DT id="144">•<DD>
|
|
CTX_get_verify_mode
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the verification mode (bitmask) currently set in <TT>$ctx</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::CTX_get_verify_mode($ctx);
|
|
# $ctx - value corresponding to openssl's SSL_CTX structure
|
|
#
|
|
# returns: mode (bitmask)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
For bitmask details see ``CTX_set_verify''.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/manmaster/man3/SSL_CTX_get_verify_mode.html">https://www.openssl.org/docs/manmaster/man3/SSL_CTX_get_verify_mode.html</A>>
|
|
<DT id="145">•<DD>
|
|
CTX_set_verify
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the verification flags for <TT>$ctx</TT> to be <TT>$mode</TT> and specifies the verify_callback function to be used.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::CTX_set_verify($ctx, $mode, $callback);
|
|
# $ctx - value corresponding to openssl's SSL_CTX structure
|
|
# $mode - mode (bitmask), see OpenSSL manual
|
|
# $callback - [optional] reference to perl callback function
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_verify.html">https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_verify.html</A>>
|
|
<DT id="146">•<DD>
|
|
CTX_set_post_handshake_auth
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.1, not in LibreSSL
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Enable the Post-Handshake Authentication extension to be added to the ClientHello such that post-handshake authentication can be requested by the server.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::CTX_set_posthandshake_auth($ctx, $val);
|
|
# $ctx - value corresponding to openssl's SSL_CTX structure
|
|
# $val - 0 then the extension is not sent, otherwise it is
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <A HREF="https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_post_handshake_auth">https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_post_handshake_auth</A> <<A HREF="https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_post_handshake_auth.html">https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_post_handshake_auth.html</A>>
|
|
<DT id="147">•<DD>
|
|
CTX_load_verify_locations
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Specifies the locations for <TT>$ctx</TT>, at which <FONT SIZE="-1">CA</FONT> certificates for verification purposes are located. The certificates available via <TT>$CAfile</TT> and <TT>$CApath</TT> are trusted.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_load_verify_locations.html">http://www.openssl.org/docs/ssl/SSL_CTX_load_verify_locations.html</A>>
|
|
<DT id="148">•<DD>
|
|
CTX_need_tmp_RSA
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Return the result of <TT>"SSL_CTX_ctrl(ctx,SSL_CTRL_NEED_TMP_RSA,0,NULL)"</TT>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Not available with OpenSSL 1.1 and later.
|
|
<DT id="149">•<DD>
|
|
CTX_new
|
|
|
|
|
|
<P>
|
|
|
|
|
|
The same as ``CTX_v23_new''
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::CTX_new();
|
|
#
|
|
# returns: value corresponding to openssl's SSL_CTX structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_new.html">http://www.openssl.org/docs/ssl/SSL_CTX_new.html</A>>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Not available with OpenSSL 1.1 and later.
|
|
<DT id="150">•<DD>
|
|
CTX_v2_new
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Creates a new <FONT SIZE="-1">SSL_CTX</FONT> object - based on <B>SSLv2_method()</B> - as framework to establish <FONT SIZE="-1">TLS/SSL</FONT> enabled connections.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::CTX_v2_new();
|
|
#
|
|
# returns: value corresponding to openssl's SSL_CTX structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="151">•<DD>
|
|
CTX_v23_new
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Creates a new <FONT SIZE="-1">SSL_CTX</FONT> object - based on <B>SSLv23_method()</B> - as framework to establish <FONT SIZE="-1">TLS/SSL</FONT> enabled connections.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::CTX_v23_new();
|
|
#
|
|
# returns: value corresponding to openssl's SSL_CTX structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="152">•<DD>
|
|
CTX_v3_new
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Creates a new <FONT SIZE="-1">SSL_CTX</FONT> object - based on <B>SSLv3_method()</B> - as framework to establish <FONT SIZE="-1">TLS/SSL</FONT> enabled connections.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::CTX_v3_new();
|
|
#
|
|
# returns: value corresponding to openssl's SSL_CTX structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="153">•<DD>
|
|
CTX_tlsv1_new
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Creates a new <FONT SIZE="-1">SSL_CTX</FONT> object - based on <B>TLSv1_method()</B> - as framework to establish <FONT SIZE="-1">TLS/SSL</FONT> enabled connections.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::CTX_tlsv1_new();
|
|
#
|
|
# returns: value corresponding to openssl's SSL_CTX structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="154">•<DD>
|
|
CTX_tlsv1_1_new
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Creates a new <FONT SIZE="-1">SSL_CTX</FONT> object - based on <B>TLSv1_1_method()</B> - as framework to establish <FONT SIZE="-1">TLS/SSL</FONT>
|
|
enabled connections. Only available where supported by the underlying openssl.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::CTX_tlsv1_1_new();
|
|
#
|
|
# returns: value corresponding to openssl's SSL_CTX structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="155">•<DD>
|
|
CTX_tlsv1_2_new
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Creates a new <FONT SIZE="-1">SSL_CTX</FONT> object - based on <B>TLSv1_2_method()</B> - as framework to establish <FONT SIZE="-1">TLS/SSL</FONT>
|
|
enabled connections. Only available where supported by the underlying openssl.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::CTX_tlsv1_2_new();
|
|
#
|
|
# returns: value corresponding to openssl's SSL_CTX structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="156">•<DD>
|
|
CTX_new_with_method
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Creates a new <FONT SIZE="-1">SSL_CTX</FONT> object based on <TT>$meth</TT> method
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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);
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_new.html">http://www.openssl.org/docs/ssl/SSL_CTX_new.html</A>>
|
|
<DT id="157">•<DD>
|
|
CTX_set_min_proto_version, CTX_set_max_proto_version, set_min_proto_version and set_max_proto_version,
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.82 and before; requires at least OpenSSL 1.1.0 or LibreSSL 2.6.0
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Set the minimum and maximum supported protocol for <TT>$ctx</TT> or <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::CTX_set_min_proto_version($ctx, $version)
|
|
# $ctx - value corresponding to openssl's SSL_CTX structure
|
|
# $version - (integer) constat version value or 0 for automatic lowest or highest value
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
#example: allow only TLS 1.2 for a SSL_CTX
|
|
my $rv_min = Net::SSLeay::CTX_set_min_proto_version($ctx, Net::SSLeay::TLS1_2_VERSION());
|
|
my $rv_max = Net::SSLeay::CTX_set_max_proto_version($ctx, Net::SSLeay::TLS1_2_VERSION());
|
|
|
|
#example: allow only TLS 1.1 for a SSL
|
|
my $rv_min = Net::SSLeay::set_min_proto_version($ssl, Net::SSLeay::TLS1_1_VERSION());
|
|
my $rv_max = Net::SSLeay::set_max_proto_version($ssl, Net::SSLeay::TLS1_1_VERSION());
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_min_proto_version.html">https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_min_proto_version.html</A>>
|
|
<DT id="158">•<DD>
|
|
CTX_get_min_proto_version, CTX_get_max_proto_version, get_min_proto_version and get_max_proto_version,
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.82 and before; requires at least OpenSSL 1.1.0g
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Get the minimum and maximum supported protocol for <TT>$ctx</TT> or <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $version = Net::SSLeay::CTX_get_min_proto_version($ctx)
|
|
# $ctx - value corresponding to openssl's SSL_CTX structure
|
|
#
|
|
# returns: 0 automatic lowest or highest value, configured value otherwise
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_min_proto_version.html">https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_min_proto_version.html</A>>
|
|
<DT id="159">•<DD>
|
|
CTX_remove_session
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Removes the session <TT>$ses</TT> from the context <TT>$ctx</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_add_session.html">http://www.openssl.org/docs/ssl/SSL_CTX_add_session.html</A>>
|
|
<DT id="160">•<DD>
|
|
CTX_sess_accept
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_sess_number.html">http://www.openssl.org/docs/ssl/SSL_CTX_sess_number.html</A>>
|
|
<DT id="161">•<DD>
|
|
CTX_sess_accept_good
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_sess_number.html">http://www.openssl.org/docs/ssl/SSL_CTX_sess_number.html</A>>
|
|
<DT id="162">•<DD>
|
|
CTX_sess_accept_renegotiate
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_sess_number.html">http://www.openssl.org/docs/ssl/SSL_CTX_sess_number.html</A>>
|
|
<DT id="163">•<DD>
|
|
CTX_sess_cache_full
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_sess_number.html">http://www.openssl.org/docs/ssl/SSL_CTX_sess_number.html</A>>
|
|
<DT id="164">•<DD>
|
|
CTX_sess_cb_hits
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_sess_number.html">http://www.openssl.org/docs/ssl/SSL_CTX_sess_number.html</A>>
|
|
<DT id="165">•<DD>
|
|
CTX_sess_connect
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_sess_number.html">http://www.openssl.org/docs/ssl/SSL_CTX_sess_number.html</A>>
|
|
<DT id="166">•<DD>
|
|
CTX_sess_connect_good
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_sess_number.html">http://www.openssl.org/docs/ssl/SSL_CTX_sess_number.html</A>>
|
|
<DT id="167">•<DD>
|
|
CTX_sess_connect_renegotiate
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_sess_number.html">http://www.openssl.org/docs/ssl/SSL_CTX_sess_number.html</A>>
|
|
<DT id="168">•<DD>
|
|
CTX_sess_get_cache_size
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the currently valid session cache size.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::CTX_sess_get_cache_size($ctx);
|
|
# $ctx - value corresponding to openssl's SSL_CTX structure
|
|
#
|
|
# returns: current size
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_sess_set_cache_size.html">http://www.openssl.org/docs/ssl/SSL_CTX_sess_set_cache_size.html</A>>
|
|
<DT id="169">•<DD>
|
|
CTX_sess_hits
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::CTX_sess_hits($ctx);
|
|
# $ctx - value corresponding to openssl's SSL_CTX structure
|
|
#
|
|
# returns: number of successfully reused sessions
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_sess_number.html">http://www.openssl.org/docs/ssl/SSL_CTX_sess_number.html</A>>
|
|
<DT id="170">•<DD>
|
|
CTX_sess_misses
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_sess_number.html">http://www.openssl.org/docs/ssl/SSL_CTX_sess_number.html</A>>
|
|
<DT id="171">•<DD>
|
|
CTX_sess_number
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_sess_number.html">http://www.openssl.org/docs/ssl/SSL_CTX_sess_number.html</A>>
|
|
<DT id="172">•<DD>
|
|
CTX_sess_set_cache_size
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the size of the internal session cache of context <TT>$ctx</TT> to <TT>$size</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_sess_set_cache_size.html">http://www.openssl.org/docs/ssl/SSL_CTX_sess_set_cache_size.html</A>>
|
|
<DT id="173">•<DD>
|
|
CTX_sess_timeouts
|
|
|
|
|
|
<P>
|
|
|
|
|
|
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.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::CTX_sess_timeouts($ctx);
|
|
# $ctx - value corresponding to openssl's SSL_CTX structure
|
|
#
|
|
# returns: number of sessions
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_sess_number.html">http://www.openssl.org/docs/ssl/SSL_CTX_sess_number.html</A>>
|
|
<DT id="174">•<DD>
|
|
CTX_sess_set_new_cb
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.85 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the callback function, which is automatically called whenever a new session was negotiated.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::CTX_sess_set_new_cb($ctx, $func);
|
|
# $ctx - value corresponding to openssl's SSL_CTX structure
|
|
# $func - perl reference to callback function
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/manmaster/man3/SSL_CTX_sess_set_new_cb.html">https://www.openssl.org/docs/manmaster/man3/SSL_CTX_sess_set_new_cb.html</A>>
|
|
<DT id="175">•<DD>
|
|
CTX_sess_set_remove_cb
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.85 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the callback function, which is automatically called whenever a session is removed by the <FONT SIZE="-1">SSL</FONT> engine.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::CTX_sess_set_remove_cb($ctx, $func);
|
|
# $ctx - value corresponding to openssl's SSL_CTX structure
|
|
# $func - perl reference to callback function
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/manmaster/man3/SSL_CTX_sess_set_remove_cb.html">https://www.openssl.org/docs/manmaster/man3/SSL_CTX_sess_set_remove_cb.html</A>>
|
|
<DT id="176">•<DD>
|
|
CTX_sessions
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns a pointer to the lhash databases containing the internal session cache for ctx.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_sessions.html">http://www.openssl.org/docs/ssl/SSL_CTX_sessions.html</A>>
|
|
<DT id="177">•<DD>
|
|
CTX_set1_param
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Applies X509 verification parameters <TT>$vpm</TT> on <TT>$ctx</TT>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/ssl/SSL_CTX_get0_param.html">https://www.openssl.org/docs/ssl/SSL_CTX_get0_param.html</A>>
|
|
<DT id="178">•<DD>
|
|
CTX_set_cert_store
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets/replaces the certificate verification storage of <TT>$ctx</TT> to/with <TT>$store</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_cert_store.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_cert_store.html</A>>
|
|
<DT id="179">•<DD>
|
|
CTX_set_cert_verify_callback
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the verification callback function for <TT>$ctx</TT>. <FONT SIZE="-1">SSL</FONT> objects that are created from <TT>$ctx</TT>
|
|
inherit the setting valid at the time when <TT>"Net::SSLeay::new($ctx)"</TT> is called.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_cert_verify_callback.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_cert_verify_callback.html</A>>
|
|
<DT id="180">•<DD>
|
|
CTX_set_cipher_list
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the list of available ciphers for <TT>$ctx</TT> using the control string <TT>$str</TT>.
|
|
The list of ciphers is inherited by all ssl objects created from <TT>$ctx</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
The format of <TT>$str</TT> is described in <<A HREF="http://www.openssl.org/docs/apps/ciphers.html">http://www.openssl.org/docs/apps/ciphers.html</A>>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_cipher_list.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_cipher_list.html</A>>
|
|
<DT id="181">•<DD>
|
|
CTX_set_ciphersuites
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.1, not in LibreSSL
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Configure the available TLSv1.3 ciphersuites.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::CTX_set_ciphersuites($ctx, $str);
|
|
# $ctx - value corresponding to openssl's SSL_CTX structure
|
|
# $str - colon (":") separated list of TLSv1.3 ciphersuite names in order of preference
|
|
#
|
|
# returns: (integer) 1 if the requested ciphersuite list was configured, and 0 otherwise
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_ciphersuites.html">https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_ciphersuites.html</A>>
|
|
<DT id="182">•<DD>
|
|
CTX_set_client_CA_list
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the list of CAs sent to the client when requesting a client certificate for <TT>$ctx</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_client_CA_list.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_client_CA_list.html</A>>
|
|
<DT id="183">•<DD>
|
|
CTX_set_default_passwd_cb
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the default password callback called when loading/storing a <FONT SIZE="-1">PEM</FONT> certificate with encryption.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_default_passwd_cb.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_default_passwd_cb.html</A>>
|
|
<DT id="184">•<DD>
|
|
CTX_set_default_passwd_cb_userdata
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets a pointer to userdata which will be provided to the password callback on invocation.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_default_passwd_cb.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_default_passwd_cb.html</A>>
|
|
<DT id="185">•<DD>
|
|
CTX_set_default_verify_paths
|
|
|
|
|
|
<P>
|
|
|
|
|
|
??? (more info needed)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="186">•<DD>
|
|
CTX_set_ex_data
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Is used to store application data at <TT>$data</TT> for <TT>$idx</TT> into the <TT>$ctx</TT> object.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_get_ex_new_index.html">http://www.openssl.org/docs/ssl/SSL_CTX_get_ex_new_index.html</A>>
|
|
<DT id="187">•<DD>
|
|
CTX_set_purpose
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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;
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="188">•<DD>
|
|
CTX_set_quiet_shutdown
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the 'quiet shutdown' flag for <TT>$ctx</TT> to be mode. <FONT SIZE="-1">SSL</FONT> objects created from <TT>$ctx</TT> inherit the mode valid at the time <TT>"Net::SSLeay::new($ctx)"</TT> is called.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_quiet_shutdown.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_quiet_shutdown.html</A>>
|
|
<DT id="189">•<DD>
|
|
CTX_set_read_ahead
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="190">•<DD>
|
|
CTX_set_session_id_context
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the context <TT>$sid_ctx</TT> of length <TT>$sid_ctx_len</TT> within which a session can be reused for the <TT>$ctx</TT> object.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_session_id_context.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_session_id_context.html</A>>
|
|
<DT id="191">•<DD>
|
|
CTX_set_ssl_version
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets a new default <FONT SIZE="-1">TLS/SSL</FONT> method for <FONT SIZE="-1">SSL</FONT> objects newly created from this <TT>$ctx</TT>.
|
|
<FONT SIZE="-1">SSL</FONT> objects already created with <TT>"Net::SSLeay::new($ctx)"</TT> are not
|
|
affected, except when <TT>"Net::SSLeay:clear($ssl)"</TT> is being called.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_ssl_version.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_ssl_version.html</A>>
|
|
<DT id="192">•<DD>
|
|
CTX_set_timeout
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the timeout for newly created sessions for <TT>$ctx</TT> to <TT>$t</TT>. The timeout value <TT>$t</TT> must be given in seconds.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_timeout.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_timeout.html</A>>
|
|
<DT id="193">•<DD>
|
|
CTX_set_tmp_dh
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets <FONT SIZE="-1">DH</FONT> parameters to be used to be <TT>$dh</TT>. The key is inherited by all ssl objects created from <TT>$ctx</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_tmp_dh_callback.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_tmp_dh_callback.html</A>>
|
|
<DT id="194">•<DD>
|
|
CTX_set_tmp_dh_callback
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the callback function for <TT>$ctx</TT> to be used when a <FONT SIZE="-1">DH</FONT> parameters are required to <TT>$tmp_dh_callback</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_tmp_dh_callback.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_tmp_dh_callback.html</A>>
|
|
<DT id="195">•<DD>
|
|
CTX_set_tmp_rsa
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the temporary/ephemeral <FONT SIZE="-1">RSA</FONT> key to be used to be <TT>$rsa</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_tmp_rsa_callback.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_tmp_rsa_callback.html</A>>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Not available with OpenSSL 1.1 and later.
|
|
<DT id="196">•<DD>
|
|
CTX_set_tmp_rsa_callback
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the callback function for ctx to be used when a temporary/ephemeral <FONT SIZE="-1">RSA</FONT> key is required to <TT>$tmp_rsa_callback</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
??? (does this function really work?)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_tmp_rsa_callback.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_tmp_rsa_callback.html</A>>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Not available with OpenSSL 1.1 and later.
|
|
<DT id="197">•<DD>
|
|
CTX_set_trust
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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;
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="198">•<DD>
|
|
CTX_set_verify_depth
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the maximum depth for the certificate chain verification that shall be allowed for ctx.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::CTX_set_verify_depth($ctx, $depth);
|
|
# $ctx - value corresponding to openssl's SSL_CTX structure
|
|
# $depth - max. depth
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_verify.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_verify.html</A>>
|
|
<DT id="199">•<DD>
|
|
CTX_use_PKCS12_file
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Adds the certificate and private key from <FONT SIZE="-1">PKCS12</FONT> file <TT>$p12filename</TT> to <TT>$ctx</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="200">•<DD>
|
|
CTX_use_PrivateKey
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Adds the private key <TT>$pkey</TT> to <TT>$ctx</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_use_certificate.html">http://www.openssl.org/docs/ssl/SSL_CTX_use_certificate.html</A>>
|
|
<DT id="201">•<DD>
|
|
CTX_use_PrivateKey_file
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Adds the first private key found in <TT>$file</TT> to <TT>$ctx</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_use_certificate.html">http://www.openssl.org/docs/ssl/SSL_CTX_use_certificate.html</A>>
|
|
<DT id="202">•<DD>
|
|
CTX_use_RSAPrivateKey
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Adds the <FONT SIZE="-1">RSA</FONT> private key <TT>$rsa</TT> to <TT>$ctx</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_use_certificate.html">http://www.openssl.org/docs/ssl/SSL_CTX_use_certificate.html</A>>
|
|
<DT id="203">•<DD>
|
|
CTX_use_RSAPrivateKey_file
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Adds the first <FONT SIZE="-1">RSA</FONT> private key found in <TT>$file</TT> to <TT>$ctx</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="204">•<DD>
|
|
CTX_use_certificate
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Loads the certificate <TT>$x</TT> into <TT>$ctx</TT>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_use_certificate.html">http://www.openssl.org/docs/ssl/SSL_CTX_use_certificate.html</A>>
|
|
<DT id="205">•<DD>
|
|
CTX_use_certificate_chain_file
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Loads a certificate chain from <TT>$file</TT> into <TT>$ctx</TT>. The certificates must be in <FONT SIZE="-1">PEM</FONT> format and must be sorted
|
|
starting with the subject's certificate (actual client or server certificate), followed by intermediate
|
|
<FONT SIZE="-1">CA</FONT> certificates if applicable, and ending at the highest level (root) <FONT SIZE="-1">CA.</FONT>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_use_certificate.html">http://www.openssl.org/docs/ssl/SSL_CTX_use_certificate.html</A>>
|
|
<DT id="206">•<DD>
|
|
CTX_use_certificate_file
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Loads the first certificate stored in <TT>$file</TT> into <TT>$ctx</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_use_certificate.html">http://www.openssl.org/docs/ssl/SSL_CTX_use_certificate.html</A>>
|
|
<DT id="207">•<DD>
|
|
CTX_get_security_level
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.0, not in LibreSSL
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the security level associated with <TT>$ctx</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $level = Net::SSLeay::CTX_get_security_level($ctx);
|
|
# $ctx - value corresponding to openssl's SSL_CTX structure
|
|
#
|
|
# returns: (integer) current security level
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/manmaster/man3/SSL_CTX_get_security_level.html">https://www.openssl.org/docs/manmaster/man3/SSL_CTX_get_security_level.html</A>>
|
|
<DT id="208">•<DD>
|
|
CTX_set_security_level
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.0, not in LibreSSL
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the security level associated with <TT>$ctx</TT> to <TT>$level</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::CTX_set_security_level($ctx, $level);
|
|
# $ssl - value corresponding to openssl's SSL_CTX structure
|
|
# $level - new security level
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_security_level.html">https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_security_level.html</A>>
|
|
<DT id="209">•<DD>
|
|
CTX_set_num_tickets
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.1, not in LibreSSL
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Set number of TLSv1.3 session tickets that will be sent to a client.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::CTX_set_num_tickets($ctx, $number_of_tickets);
|
|
# $ctx - value corresponding to openssl's SSL_CTX structure
|
|
# $number_of_tickets - number of tickets to send
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Set to zero if you do not no want to support a session resumption.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_num_tickets.html">https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_num_tickets.html</A>>
|
|
<DT id="210">•<DD>
|
|
CTX_get_num_tickets
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.1, not in LibreSSL
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Get number of TLSv1.3 session tickets that will be sent to a client.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $number_of_tickets = Net::SSLeay::CTX_get_num_tickets($ctx);
|
|
# $ctx - value corresponding to openssl's SSL_CTX structure
|
|
#
|
|
# returns: (integer) number of tickets to send
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/manmaster/man3/SSL_CTX_get_num_tickets.html">https://www.openssl.org/docs/manmaster/man3/SSL_CTX_get_num_tickets.html</A>>
|
|
</DL>
|
|
<P>
|
|
|
|
<I>Low level </I><FONT SIZE="-1"><I>API:</I></FONT><I> SSL_* related functions</I>
|
|
|
|
|
|
<P>
|
|
|
|
<B></B><FONT SIZE="-1"><B>NOTE:</B></FONT><B></B> Please note that the function described in this chapter have ``<FONT SIZE="-1">SSL_''</FONT> part stripped from their original openssl names.
|
|
<DL COMPACT>
|
|
<DT id="211">•<DD>
|
|
new
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Creates a new <FONT SIZE="-1">SSL</FONT> structure which is needed to hold the data for a <FONT SIZE="-1">TLS/SSL</FONT> connection.
|
|
The new structure inherits the settings of the underlying context <TT>$ctx:</TT> connection
|
|
method (SSLv2/v3/TLSv1), options, verification settings, timeout settings.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_new.html">http://www.openssl.org/docs/ssl/SSL_new.html</A>>
|
|
<DT id="212">•<DD>
|
|
accept
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Waits for a <FONT SIZE="-1">TLS/SSL</FONT> client to initiate the <FONT SIZE="-1">TLS/SSL</FONT> handshake. The communication
|
|
channel must already have been set and assigned to the ssl by setting an underlying <FONT SIZE="-1">BIO.</FONT>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::accept($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: 1 = success, 0 = handshake not successful, <0 = fatal error during handshake
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_accept.html">http://www.openssl.org/docs/ssl/SSL_accept.html</A>>
|
|
<DT id="213">•<DD>
|
|
add_client_CA
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Adds the <FONT SIZE="-1">CA</FONT> 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 <FONT SIZE="-1">SSL_CTX</FONT> object.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_client_CA_list.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_client_CA_list.html</A>>
|
|
<DT id="214">•<DD>
|
|
callback_ctrl
|
|
|
|
|
|
<P>
|
|
|
|
|
|
??? (more info needed)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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: ???
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_ctrl.html">http://www.openssl.org/docs/ssl/SSL_CTX_ctrl.html</A>>
|
|
<DT id="215">•<DD>
|
|
check_private_key
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Checks the consistency of a private key with the corresponding certificate loaded into <TT>$ssl</TT>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_use_certificate.html">http://www.openssl.org/docs/ssl/SSL_CTX_use_certificate.html</A>>
|
|
<DT id="216">•<DD>
|
|
clear
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Reset <FONT SIZE="-1">SSL</FONT> object to allow another connection.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::clear($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_clear.html">http://www.openssl.org/docs/ssl/SSL_clear.html</A>>
|
|
<DT id="217">•<DD>
|
|
connect
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Initiate the <FONT SIZE="-1">TLS/SSL</FONT> handshake with an <FONT SIZE="-1">TLS/SSL</FONT> server.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::connect($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: 1 = success, 0 = handshake not successful, <0 = fatal error during handshake
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_connect.html">http://www.openssl.org/docs/ssl/SSL_connect.html</A>>
|
|
<DT id="218">•<DD>
|
|
copy_session_id
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Copies the session structure fro <TT>$from</TT> to <TT>$to</TT> (+ also the private key and certificate associated with <TT>$from</TT>).
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="219">•<DD>
|
|
ctrl
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Internal handling function for <FONT SIZE="-1">SSL</FONT> objects.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>BEWARE:</B></FONT><B></B> openssl doc says: This function should never be called directly!
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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 ???
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
For more details about valid <TT>$cmd</TT> values check ``CTX_ctrl''.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_ctrl.html">http://www.openssl.org/docs/ssl/SSL_CTX_ctrl.html</A>>
|
|
<DT id="220">•<DD>
|
|
do_handshake
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Will wait for a <FONT SIZE="-1">SSL/TLS</FONT> 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 <B><A HREF="/cgi-bin/man/man2html?3+SSL_set_accept_state">SSL_set_accept_state</A></B>(3).
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::do_handshake($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: 1 = success, 0 = handshake not successful, <0 = fatal error during handshake
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_do_handshake.html">http://www.openssl.org/docs/ssl/SSL_do_handshake.html</A>>
|
|
<DT id="221">•<DD>
|
|
dup
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns a duplicate of <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="222">•<DD>
|
|
free
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Free an allocated <FONT SIZE="-1">SSL</FONT> structure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::free($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_free.html">http://www.openssl.org/docs/ssl/SSL_free.html</A>>
|
|
<DT id="223">•<DD>
|
|
get0_param
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.82 and before; requires at least OpenSSL 1.0.2
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the current verification parameters.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $vpm = Net::SSLeay::get0_param($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: value corresponding to openssl's X509_VERIFY_PARAM structure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/ssl/SSL_CTX_get0_param.html">https://www.openssl.org/docs/ssl/SSL_CTX_get0_param.html</A>>
|
|
<DT id="224">•<DD>
|
|
get_SSL_CTX
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns a pointer to the <FONT SIZE="-1">SSL_CTX</FONT> object, from which <TT>$ssl</TT> was created with Net::SSLeay::new.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_get_SSL_CTX.html">http://www.openssl.org/docs/ssl/SSL_get_SSL_CTX.html</A>>
|
|
<DT id="225">•<DD>
|
|
set_SSL_CTX
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the <FONT SIZE="-1">SSL_CTX</FONT> the corresponds to an <FONT SIZE="-1">SSL</FONT> session.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="226">•<DD>
|
|
get_app_data
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Can be used to get application defined value/data.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::get_app_data($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: string/buffer/pointer ???
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="227">•<DD>
|
|
set_app_data
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Can be used to set some application defined value/data.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::set_app_data($ssl, $arg);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $arg - (string/buffer/pointer ???) data
|
|
#
|
|
# returns: ???
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="228">•<DD>
|
|
get_certificate
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Gets X509 certificate from an established <FONT SIZE="-1">SSL</FONT> connection.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="229">•<DD>
|
|
get_cipher
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Obtains the name of the currently used cipher.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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.
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_get_current_cipher.html">http://www.openssl.org/docs/ssl/SSL_get_current_cipher.html</A>>
|
|
<DT id="230">•<DD>
|
|
get_cipher_bits
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Obtain the number of secret/algorithm bits used.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_get_current_cipher.html">http://www.openssl.org/docs/ssl/SSL_get_current_cipher.html</A>>
|
|
and <<A HREF="http://www.openssl.org/docs/ssl/SSL_CIPHER_get_name.html">http://www.openssl.org/docs/ssl/SSL_CIPHER_get_name.html</A>>
|
|
<DT id="231">•<DD>
|
|
get_cipher_list
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the name (string) of the <FONT SIZE="-1">SSL_CIPHER</FONT> listed for <TT>$ssl</TT> with priority <TT>$n</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Call Net::SSLeay::get_cipher_list with priority starting from 0 to obtain
|
|
the sorted list of available ciphers, until '' is returned:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $priority = 0;
|
|
while (my $c = Net::SSLeay::get_cipher_list($ssl, $priority)) {
|
|
print "cipher[$priority] = $c\n";
|
|
$priority++;
|
|
}
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_get_ciphers.html">http://www.openssl.org/docs/ssl/SSL_get_ciphers.html</A>>
|
|
<DT id="232">•<DD>
|
|
get_client_CA_list
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the list of client CAs explicitly set for <TT>$ssl</TT> using <TT>"Net::SSleay::set_client_CA_list"</TT>
|
|
or <TT>$ssl</TT>'s <FONT SIZE="-1">SSL_CTX</FONT> object with <TT>"Net::SSLeay::CTX_set_client_CA_list"</TT>, when in server mode.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
In client mode, returns the list of client CAs sent from the server, if any.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_get_client_CA_list.html">http://www.openssl.org/docs/ssl/SSL_get_client_CA_list.html</A>>
|
|
<DT id="233">•<DD>
|
|
get_current_cipher
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the cipher actually used.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_get_current_cipher.html">http://www.openssl.org/docs/ssl/SSL_get_current_cipher.html</A>>
|
|
<DT id="234">•<DD>
|
|
get_default_timeout
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the default timeout value assigned to <FONT SIZE="-1">SSL_SESSION</FONT> objects negotiated for the protocol valid for <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::get_default_timeout($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: (long) timeout in seconds
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_get_default_timeout.html">http://www.openssl.org/docs/ssl/SSL_get_default_timeout.html</A>>
|
|
<DT id="235">•<DD>
|
|
get_error
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns a result code for a preceding call to <TT>"connect"</TT>, <TT>"accept"</TT>, <TT>"do_handshake"</TT>, <TT>"read"</TT>, <TT>"peek"</TT> or <TT>"write"</TT> on <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_get_error.html">http://www.openssl.org/docs/ssl/SSL_get_error.html</A>>
|
|
<DT id="236">•<DD>
|
|
get_ex_data
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Is used to retrieve the information for <TT>$idx</TT> from <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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 ???
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_get_ex_new_index.html">http://www.openssl.org/docs/ssl/SSL_get_ex_new_index.html</A>>
|
|
<DT id="237">•<DD>
|
|
set_ex_data
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Is used to store application data at <TT>$data</TT> for <TT>$idx</TT> into the <TT>$ssl</TT> object.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_get_ex_new_index.html">http://www.openssl.org/docs/ssl/SSL_get_ex_new_index.html</A>>
|
|
<DT id="238">•<DD>
|
|
get_ex_new_index
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Is used to register a new index for application specific data.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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) ???
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_get_ex_new_index.html">http://www.openssl.org/docs/ssl/SSL_get_ex_new_index.html</A>>
|
|
<DT id="239">•<DD>
|
|
get_fd
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the file descriptor which is linked to <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::get_fd($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: file descriptor (>=0) or -1 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_get_fd.html">http://www.openssl.org/docs/ssl/SSL_get_fd.html</A>>
|
|
<DT id="240">•<DD>
|
|
get_finished
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Obtains the latest 'Finished' message sent to the peer. Return value
|
|
is zero if there's been no Finished message yet. Default count is
|
|
2*EVP_MAX_MD_SIZE that is long enough for all possible Finish
|
|
messages. If you supply a non-default count, the resulting return
|
|
value may be longer than returned buf's length.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
# $count - [optional] max size of return data - default is 2*EVP_MAX_MD_SIZE
|
|
#
|
|
# returns: length of latest Finished message
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="241">•<DD>
|
|
get_peer_finished
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Obtains the latest 'Finished' message expected from the
|
|
peer. Parameters and return value are similar to <B>get_finished()</B>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
# $count - [optional] max size of return data - default is 2*EVP_MAX_MD_SIZE
|
|
#
|
|
# returns: length of latest Finished message
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="242">•<DD>
|
|
get_keyblock_size
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Gets the length of the <FONT SIZE="-1">TLS</FONT> keyblock.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>NOTE:</B></FONT><B></B> Does not exactly correspond to any low level <FONT SIZE="-1">API</FONT> function.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::get_keyblock_size($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: keyblock size, -1 on error
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="243">•<DD>
|
|
get_mode
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the mode (bitmask) set for <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::get_mode($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: mode (bitmask)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
To decode the return value (bitmask) see documentation for ``CTX_get_mode''.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_mode.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_mode.html</A>>
|
|
<DT id="244">•<DD>
|
|
set_mode
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Adds the mode set via bitmask in <TT>$mode</TT> to <TT>$ssl</TT>. Options already set before are not cleared.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
For <TT>$mode</TT> bitmask details see ``CTX_get_mode''.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_mode.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_mode.html</A>>
|
|
<DT id="245">•<DD>
|
|
get_options
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the options (bitmask) set for <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::get_options($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: options (bitmask)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
To decode the return value (bitmask) see documentation for ``CTX_get_options''.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_options.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_options.html</A>>
|
|
<DT id="246">•<DD>
|
|
set_options
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Adds the options set via bitmask in <TT>$options</TT> to <TT>$ssl</TT>. Options already set before are not cleared!
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
For <TT>$options</TT> bitmask details see ``CTX_get_options''.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_options.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_options.html</A>>
|
|
<DT id="247">•<DD>
|
|
get_peer_certificate
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Get the X509 certificate of the peer.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_get_peer_certificate.html">http://www.openssl.org/docs/ssl/SSL_get_peer_certificate.html</A>>
|
|
<DT id="248">•<DD>
|
|
get_peer_cert_chain
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Get the certificate chain of the peer as an array of X509 structures.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my @rv = Net::SSLeay::get_peer_cert_chain($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: list of X509 structures
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_get_peer_certificate.html">http://www.openssl.org/docs/ssl/SSL_get_peer_certificate.html</A>>
|
|
<DT id="249">•<DD>
|
|
get_quiet_shutdown
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the 'quiet shutdown' setting of ssl.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::get_quiet_shutdown($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: (integer) current 'quiet shutdown' value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_quiet_shutdown.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_quiet_shutdown.html</A>>
|
|
<DT id="250">•<DD>
|
|
get_rbio
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Get 'read' <FONT SIZE="-1">BIO</FONT> linked to an <FONT SIZE="-1">SSL</FONT> object <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_get_rbio.html">http://www.openssl.org/docs/ssl/SSL_get_rbio.html</A>>
|
|
<DT id="251">•<DD>
|
|
get_read_ahead
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::get_read_ahead($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: (integer) read_ahead value
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="252">•<DD>
|
|
set_read_ahead
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::set_read_ahead($ssl, $val);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $val - read_ahead value to be set
|
|
#
|
|
# returns: the original read_ahead value
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="253">•<DD>
|
|
get_security_level
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.0, not in LibreSSL
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the security level associated with <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $level = Net::SSLeay::get_security_level($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: (integer) current security level
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/manmaster/man3/SSL_get_security_level.html">https://www.openssl.org/docs/manmaster/man3/SSL_get_security_level.html</A>>
|
|
<DT id="254">•<DD>
|
|
set_security_level
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.0, not in LibreSSL
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the security level associated with <TT>$ssl</TT> to <TT>$level</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::set_security_level($ssl, $level);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $level - new security level
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/manmaster/man3/SSL_set_security_level.html">https://www.openssl.org/docs/manmaster/man3/SSL_set_security_level.html</A>>
|
|
<DT id="255">•<DD>
|
|
set_num_tickets
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.1, not in LibreSSL
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Set number of TLSv1.3 session tickets that will be sent to a client.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::set_num_tickets($ssl, $number_of_tickets);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $number_of_tickets - number of tickets to send
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Set to zero if you do not no want to support a session resumption.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/manmaster/man3/SSL_set_num_tickets.html">https://www.openssl.org/docs/manmaster/man3/SSL_set_num_tickets.html</A>>
|
|
<DT id="256">•<DD>
|
|
get_num_tickets
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.1, not in LibreSSL
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Get number of TLSv1.3 session tickets that will be sent to a client.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $number_of_tickets = Net::SSLeay::get_num_tickets($ctx);
|
|
# $ctx - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: number of tickets to send
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/manmaster/man3/SSL_get_num_tickets.html">https://www.openssl.org/docs/manmaster/man3/SSL_get_num_tickets.html</A>>
|
|
<DT id="257">•<DD>
|
|
get_server_random
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns internal SSLv3 server_random value.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::get_server_random($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: server_random value (binary data)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="258">•<DD>
|
|
get_client_random
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>NOTE:</B></FONT><B></B> Does not exactly correspond to any low level <FONT SIZE="-1">API</FONT> function
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns internal SSLv3 client_random value.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::get_client_random($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: client_random value (binary data)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="259">•<DD>
|
|
export_keying_material
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns keying material based on the string <TT>$label</TT> and optional
|
|
<TT>$context</TT>. Note that with TLSv1.2 and lower, empty context (empty
|
|
string) and undefined context (no value or 'undef') will return
|
|
different values.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $out = Net::SSLeay::export_keying_material($ssl, $olen, $label, $context);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $olen - number of bytes to return
|
|
# $label - application specific label
|
|
# $context - [optional] context - default is undef for no context
|
|
#
|
|
# returns: keying material (binary data) or undef on error
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/manmaster/man3/SSL_export_keying_material.html">https://www.openssl.org/docs/manmaster/man3/SSL_export_keying_material.html</A>>
|
|
<DT id="260">•<DD>
|
|
get_session
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Retrieve <FONT SIZE="-1">TLS/SSL</FONT> session data used in <TT>$ssl</TT>. The reference count of the <FONT SIZE="-1">SSL_SESSION</FONT> is <FONT SIZE="-1">NOT</FONT> incremented.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::get_session($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: value corresponding to openssl's SSL_SESSION structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_get_session.html">http://www.openssl.org/docs/ssl/SSL_get_session.html</A>>
|
|
<DT id="261">•<DD>
|
|
SSL_get0_session
|
|
|
|
|
|
<P>
|
|
|
|
|
|
The alias for ``get_session'' (note that the name is <TT>"SSL_get0_session"</TT> <FONT SIZE="-1">NOT</FONT> <TT>"get0_session"</TT>).
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::SSL_get0_session();
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="262">•<DD>
|
|
get1_session
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns a pointer to the <FONT SIZE="-1">SSL_SESSION</FONT> actually used in <TT>$ssl</TT>. The reference count of the <FONT SIZE="-1">SSL_SESSION</FONT> is incremented by 1.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::get1_session($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: value corresponding to openssl's SSL_SESSION structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_get_session.html">http://www.openssl.org/docs/ssl/SSL_get_session.html</A>>
|
|
<DT id="263">•<DD>
|
|
get_shared_ciphers
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns string with a list (colon ':' separated) of ciphers shared between client and server
|
|
within <FONT SIZE="-1">SSL</FONT> session <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::get_shared_ciphers()
|
|
#
|
|
# returns: string like 'ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES256-SHA:DHE-DSS-AES256-SHA:...'
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="264">•<DD>
|
|
get_shutdown
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the shutdown mode of <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::get_shutdown($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: shutdown mode (bitmask) of ssl
|
|
|
|
#to decode the return value (bitmask) use:
|
|
0 - No shutdown setting, yet
|
|
1 - SSL_SENT_SHUTDOWN
|
|
2 - SSL_RECEIVED_SHUTDOWN
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_set_shutdown.html">http://www.openssl.org/docs/ssl/SSL_set_shutdown.html</A>>
|
|
<DT id="265">•<DD>
|
|
get_ssl_method
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns a function pointer to the <FONT SIZE="-1">TLS/SSL</FONT> method set in <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::get_ssl_method($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: value corresponding to openssl's SSL_METHOD structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_ssl_version.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_ssl_version.html</A>>
|
|
<DT id="266">•<DD>
|
|
in_init, in_before, is_init_finished, in_connect_init, in_accept_init
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.85 and before.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Retrieve information about the handshake state machine. All functions take <TT>$ssl</TT> as the only argument and return 0 or 1. These functions are recommended over <B>get_state()</B> and <B>state()</B>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::is_init_finished($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: All functions return 1 or 0
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <A HREF="https://www.openssl.org/docs/ssl/SSL_in_init.html">https://www.openssl.org/docs/ssl/SSL_in_init.html</A> <<A HREF="http://www.openssl.org/docs/ssl/SSL_in_init.html">http://www.openssl.org/docs/ssl/SSL_in_init.html</A>>
|
|
<DT id="267">•<DD>
|
|
get_state
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> OpenSSL 1.1.0 and later use different constants which are not made available. Use <B>is_init_finished()</B> and related functions instead.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the <FONT SIZE="-1">SSL</FONT> connection state.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::get_state($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: (integer) state value
|
|
# to decode the returned state check:
|
|
# SSL_ST_* constants in openssl/ssl.h
|
|
# SSL2_ST_* constants in openssl/ssl2.h
|
|
# SSL23_ST_* constants in openssl/ssl23.h
|
|
# SSL3_ST_* + DTLS1_ST_* constants in openssl/ssl3.h
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="268">•<DD>
|
|
state
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Exactly the same as ``get_state''.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::state($ssl);
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="269">•<DD>
|
|
set_state
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the <FONT SIZE="-1">SSL</FONT> connection state.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::set_state($ssl,Net::SSLeay::SSL_ST_ACCEPT());
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Not available with OpenSSL 1.1 and later.
|
|
<DT id="270">•<DD>
|
|
get_verify_depth
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the verification depth limit currently set in <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::get_verify_depth($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: current depth or -1 if no limit has been explicitly set
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_get_verify_mode.html">http://www.openssl.org/docs/ssl/SSL_CTX_get_verify_mode.html</A>>
|
|
<DT id="271">•<DD>
|
|
set_verify_depth
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the maximum depth for the certificate chain verification that shall be allowed for <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::set_verify_depth($ssl, $depth);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $depth - (integer) depth
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_verify.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_verify.html</A>>
|
|
<DT id="272">•<DD>
|
|
get_verify_mode
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the verification mode (bitmask) currently set in <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::get_verify_mode($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: mode (bitmask)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
To decode the return value (bitmask) see documentation for ``CTX_get_verify_mode''.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_get_verify_mode.html">http://www.openssl.org/docs/ssl/SSL_CTX_get_verify_mode.html</A>>
|
|
<DT id="273">•<DD>
|
|
set_verify
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the verification flags for <TT>$ssl</TT> to be <TT>$mode</TT> and specifies the <TT>$verify_callback</TT> function to be used.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::set_verify($ssl, $mode, $callback);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $mode - mode (bitmask)
|
|
# $callback - [optional] reference to perl callback function
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
For <TT>$mode</TT> bitmask details see ``CTX_get_verify_mode''.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_verify.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_verify.html</A>>
|
|
<DT id="274">•<DD>
|
|
set_post_handshake_auth
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.1, not in LibreSSL
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Enable the Post-Handshake Authentication extension to be added to the ClientHello such that post-handshake authentication can be requested by the server.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::set_posthandshake_auth($ssl, $val);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $val - 0 then the extension is not sent, otherwise it is
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <A HREF="https://www.openssl.org/docs/manmaster/man3/SSL_set_post_handshake_auth">https://www.openssl.org/docs/manmaster/man3/SSL_set_post_handshake_auth</A> <<A HREF="https://www.openssl.org/docs/manmaster/man3/SSL_set_post_handshake_auth.html">https://www.openssl.org/docs/manmaster/man3/SSL_set_post_handshake_auth.html</A>>
|
|
<DT id="275">•<DD>
|
|
verify_client_post_handshake
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.1, not in LibreSSL
|
|
|
|
|
|
<P>
|
|
|
|
|
|
verify_client_post_handshake causes a CertificateRequest message to be sent by a server on the given ssl connection.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::verify_client_post_handshake($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: 1 if the request succeeded, and 0 if the request failed. The error stack can be examined to determine the failure reason.
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/manmaster/man3/SSL_verify_client_post_handshake.html">https://www.openssl.org/docs/manmaster/man3/SSL_verify_client_post_handshake.html</A>>
|
|
<DT id="276">•<DD>
|
|
get_verify_result
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the result of the verification of the X509 certificate presented by the peer, if any.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::get_verify_result($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: (integer)
|
|
# 0 - X509_V_OK: ok
|
|
# 2 - X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: unable to get issuer certificate
|
|
# 3 - X509_V_ERR_UNABLE_TO_GET_CRL: unable to get certificate CRL
|
|
# 4 - X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE: unable to decrypt certificate's signature
|
|
# 5 - X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE: unable to decrypt CRL's signature
|
|
# 6 - X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY: unable to decode issuer public key
|
|
# 7 - X509_V_ERR_CERT_SIGNATURE_FAILURE: certificate signature failure
|
|
# 8 - X509_V_ERR_CRL_SIGNATURE_FAILURE: CRL signature failure
|
|
# 9 - X509_V_ERR_CERT_NOT_YET_VALID: certificate is not yet valid
|
|
# 10 - X509_V_ERR_CERT_HAS_EXPIRED: certificate has expired
|
|
# 11 - X509_V_ERR_CRL_NOT_YET_VALID: CRL is not yet valid
|
|
# 12 - X509_V_ERR_CRL_HAS_EXPIRED: CRL has expired
|
|
# 13 - X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD: format error in certificate's notBefore field
|
|
# 14 - X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD: format error in certificate's notAfter field
|
|
# 15 - X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD: format error in CRL's lastUpdate field
|
|
# 16 - X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD: format error in CRL's nextUpdate field
|
|
# 17 - X509_V_ERR_OUT_OF_MEM: out of memory
|
|
# 18 - X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT: self signed certificate
|
|
# 19 - X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN: self signed certificate in certificate chain
|
|
# 20 - X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY: unable to get local issuer certificate
|
|
# 21 - X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE: unable to verify the first certificate
|
|
# 22 - X509_V_ERR_CERT_CHAIN_TOO_LONG: certificate chain too long
|
|
# 23 - X509_V_ERR_CERT_REVOKED: certificate revoked
|
|
# 24 - X509_V_ERR_INVALID_CA: invalid CA certificate
|
|
# 25 - X509_V_ERR_PATH_LENGTH_EXCEEDED: path length constraint exceeded
|
|
# 26 - X509_V_ERR_INVALID_PURPOSE: unsupported certificate purpose
|
|
# 27 - X509_V_ERR_CERT_UNTRUSTED: certificate not trusted
|
|
# 28 - X509_V_ERR_CERT_REJECTED: certificate rejected
|
|
# 29 - X509_V_ERR_SUBJECT_ISSUER_MISMATCH: subject issuer mismatch
|
|
# 30 - X509_V_ERR_AKID_SKID_MISMATCH: authority and subject key identifier mismatch
|
|
# 31 - X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH: authority and issuer serial number mismatch
|
|
# 32 - X509_V_ERR_KEYUSAGE_NO_CERTSIGN:key usage does not include certificate signing
|
|
# 50 - X509_V_ERR_APPLICATION_VERIFICATION: application verification failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_get_verify_result.html">http://www.openssl.org/docs/ssl/SSL_get_verify_result.html</A>>
|
|
<DT id="277">•<DD>
|
|
set_verify_result
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Override result of peer certificate verification.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::set_verify_result($ssl, $v);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $v - (integer) result value
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
For more info about valid return values see ``get_verify_result''
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_set_verify_result.html">http://www.openssl.org/docs/ssl/SSL_set_verify_result.html</A>>
|
|
<DT id="278">•<DD>
|
|
get_wbio
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Get 'write' <FONT SIZE="-1">BIO</FONT> linked to an <FONT SIZE="-1">SSL</FONT> object <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::get_wbio($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: value corresponding to openssl's BIO structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_get_rbio.html">http://www.openssl.org/docs/ssl/SSL_get_rbio.html</A>>
|
|
<DT id="279">•<DD>
|
|
load_client_CA_file
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Load X509 certificates from file (<FONT SIZE="-1">PEM</FONT> formatted).
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::load_client_CA_file($file);
|
|
# $file - (string) file name
|
|
#
|
|
# returns: value corresponding to openssl's STACK_OF(X509_NAME) structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_load_client_CA_file.html">http://www.openssl.org/docs/ssl/SSL_load_client_CA_file.html</A>>
|
|
<DT id="280">•<DD>
|
|
clear_num_renegotiations
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Executes <FONT SIZE="-1">SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS</FONT> command on <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::clear_num_renegotiations($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: command result
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="281">•<DD>
|
|
need_tmp_RSA
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Executes <FONT SIZE="-1">SSL_CTRL_NEED_TMP_RSA</FONT> command on <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::need_tmp_RSA($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: command result
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Not available with OpenSSL 1.1 and later.
|
|
<DT id="282">•<DD>
|
|
num_renegotiations
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Executes <FONT SIZE="-1">SSL_CTRL_GET_NUM_RENEGOTIATIONS</FONT> command on <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::num_renegotiations($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: command result
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="283">•<DD>
|
|
total_renegotiations
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Executes <FONT SIZE="-1">SSL_CTRL_GET_TOTAL_RENEGOTIATIONS</FONT> command on <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::total_renegotiations($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: command result
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="284">•<DD>
|
|
peek
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Copies <TT>$max</TT> bytes from the specified <TT>$ssl</TT> into the returned value.
|
|
In contrast to the <TT>"Net::SSLeay::read()"</TT> function, the data in the <FONT SIZE="-1">SSL</FONT>
|
|
buffer is unmodified after the <B>SSL_peek()</B> operation.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::peek($ssl, $max);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $max - [optional] max bytes to peek (integer) - default is 32768
|
|
#
|
|
# in scalar context: data read from the TLS/SSL connection, undef on error
|
|
# in list context: two-item array consisting of data read (undef on error),
|
|
# and return code from SSL_peek().
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="285">•<DD>
|
|
peek_ex
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.1, not in LibreSSL
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Copies <TT>$max</TT> bytes from the specified <TT>$ssl</TT> into the returned value.
|
|
In contrast to the <TT>"Net::SSLeay::read_ex()"</TT> function, the data in the <FONT SIZE="-1">SSL</FONT>
|
|
buffer is unmodified after the <B>SSL_peek_ex()</B> operation.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my($got, $rv) = Net::SSLeay::peek_ex($ssl, $max);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $max - [optional] max bytes to peek (integer) - default is 32768
|
|
#
|
|
# returns a list: two-item list consisting of data read (undef on error),
|
|
# and return code from SSL_peek_ex().
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/manmaster/man3/SSL_peek_ex.html">https://www.openssl.org/docs/manmaster/man3/SSL_peek_ex.html</A>>
|
|
<DT id="286">•<DD>
|
|
pending
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Obtain number of readable bytes buffered in <TT>$ssl</TT> object.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::pending($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: the number of bytes pending
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_pending.html">http://www.openssl.org/docs/ssl/SSL_pending.html</A>>
|
|
<DT id="287">•<DD>
|
|
has_pending
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.0, not in LibreSSL
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns 1 if <TT>$ssl</TT> has buffered data (whether processed or unprocessed) and 0 otherwise.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::has_pending($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: (integer) 1 or 0
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/manmaster/man3/SSL_has_pending.html">https://www.openssl.org/docs/manmaster/man3/SSL_has_pending.html</A>>
|
|
<DT id="288">•<DD>
|
|
read
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Tries to read <TT>$max</TT> bytes from the specified <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $got = Net::SSLeay::read($ssl, $max);
|
|
my($got, $rv) = Net::SSLeay::read($ssl, $max);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $max - [optional] max bytes to read (integer) - default is 32768
|
|
#
|
|
# returns:
|
|
# in scalar context: data read from the TLS/SSL connection, undef on error
|
|
# in list context: two-item array consisting of data read (undef on error),
|
|
# and return code from SSL_read().
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_read.html">http://www.openssl.org/docs/ssl/SSL_read.html</A>>
|
|
<DT id="289">•<DD>
|
|
read_ex
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.1, not in LibreSSL
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Tries to read <TT>$max</TT> bytes from the specified <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my($got, $rv) = Net::SSLeay::read_ex($ssl, $max);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $max - [optional] max bytes to read (integer) - default is 32768
|
|
#
|
|
# returns a list: two-item list consisting of data read (undef on error),
|
|
# and return code from SSL_read_ex().
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/manmaster/man3/SSL_read_ex.html">https://www.openssl.org/docs/manmaster/man3/SSL_read_ex.html</A>>
|
|
<DT id="290">•<DD>
|
|
renegotiate
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Turn on flags for renegotiation so that renegotiation will happen
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::renegotiate($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="291">•<DD>
|
|
rstate_string
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns a 2 letter string indicating the current read state of the <FONT SIZE="-1">SSL</FONT> object <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::rstate_string($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: 2-letter string
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_rstate_string.html">http://www.openssl.org/docs/ssl/SSL_rstate_string.html</A>>
|
|
<DT id="292">•<DD>
|
|
rstate_string_long
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns a string indicating the current read state of the <FONT SIZE="-1">SSL</FONT> object ssl.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::rstate_string_long($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: string with current state
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_rstate_string.html">http://www.openssl.org/docs/ssl/SSL_rstate_string.html</A>>
|
|
<DT id="293">•<DD>
|
|
session_reused
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Query whether a reused session was negotiated during handshake.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::session_reused($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: 0 - new session was negotiated; 1 - session was reused.
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_session_reused.html">http://www.openssl.org/docs/ssl/SSL_session_reused.html</A>>
|
|
<DT id="294">•<DD>
|
|
set1_param
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Applies X509 verification parameters <TT>$vpm</TT> on <TT>$ssl</TT>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::set1_param($ssl, $vpm);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $vpm - value corresponding to openssl's X509_VERIFY_PARAM structure
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="295">•<DD>
|
|
set_accept_state
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets <TT>$ssl</TT> to work in server mode.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::set_accept_state($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_set_connect_state.html">http://www.openssl.org/docs/ssl/SSL_set_connect_state.html</A>>
|
|
<DT id="296">•<DD>
|
|
set_bio
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Connects the BIOs <TT>$rbio</TT> and <TT>$wbio</TT> for the read and write operations of the <FONT SIZE="-1">TLS/SSL</FONT> (encrypted) side of <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::set_bio($ssl, $rbio, $wbio);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $rbio - value corresponding to openssl's BIO structure
|
|
# $wbio - value corresponding to openssl's BIO structure
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_set_bio.html">http://www.openssl.org/docs/ssl/SSL_set_bio.html</A>>
|
|
<DT id="297">•<DD>
|
|
set_cipher_list
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the list of ciphers only for ssl.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::set_cipher_list($ssl, $str);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $str - (string) cipher list e.g. '3DES:+RSA'
|
|
#
|
|
# returns: 1 if any cipher could be selected and 0 on complete failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_cipher_list.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_cipher_list.html</A>>
|
|
<DT id="298">•<DD>
|
|
set_ciphersuites
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.1, not in LibreSSL
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Configure the available TLSv1.3 ciphersuites.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::set_ciphersuites($ssl, $str);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $str - colon (":") separated list of TLSv1.3 ciphersuite names in order of preference
|
|
#
|
|
# returns: (integer) 1 if the requested ciphersuite list was configured, and 0 otherwise
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/manmaster/man3/SSL_set_ciphersuites.html">https://www.openssl.org/docs/manmaster/man3/SSL_set_ciphersuites.html</A>>
|
|
<DT id="299">•<DD>
|
|
set_client_CA_list
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the list of CAs sent to the client when requesting a client certificate
|
|
for the chosen <TT>$ssl</TT>, overriding the setting valid for <TT>$ssl</TT>'s <FONT SIZE="-1">SSL_CTX</FONT> object.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::set_client_CA_list($ssl, $list);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $list - value corresponding to openssl's STACK_OF(X509_NAME) structure
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_client_CA_list.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_client_CA_list.html</A>>
|
|
<DT id="300">•<DD>
|
|
set_connect_state
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets <TT>$ssl</TT> to work in client mode.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::set_connect_state($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_set_connect_state.html">http://www.openssl.org/docs/ssl/SSL_set_connect_state.html</A>>
|
|
<DT id="301">•<DD>
|
|
set_fd
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the file descriptor <TT>$fd</TT> as the input/output facility for the <FONT SIZE="-1">TLS/SSL</FONT> (encrypted)
|
|
side of <TT>$ssl</TT>, <TT>$fd</TT> will typically be the socket file descriptor of a network connection.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::set_fd($ssl, $fd);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $fd - (integer) file handle (got via perl's fileno)
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_set_fd.html">http://www.openssl.org/docs/ssl/SSL_set_fd.html</A>>
|
|
<DT id="302">•<DD>
|
|
set_psk_client_callback
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the psk client callback.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::set_psk_client_callback($ssl, sub { my $hint = shift; return ($identity, $key) } );
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $hint - PSK identity hint send by the server
|
|
# $identity - PSK identity
|
|
# $key - PSK key, hex string without the leading '0x', e.g. 'deadbeef'
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_set_psk_client_callback.html">http://www.openssl.org/docs/ssl/SSL_set_psk_client_callback.html</A>>
|
|
<DT id="303">•<DD>
|
|
set_rfd
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the file descriptor <TT>$fd</TT> as the input (read) facility for the <FONT SIZE="-1">TLS/SSL</FONT> (encrypted) side of <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::set_rfd($ssl, $fd);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $fd - (integer) file handle (got via perl's fileno)
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_set_fd.html">http://www.openssl.org/docs/ssl/SSL_set_fd.html</A>>
|
|
<DT id="304">•<DD>
|
|
set_wfd
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::set_wfd($ssl, $fd);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $fd - (integer) file handle (got via perl's fileno)
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_set_fd.html">http://www.openssl.org/docs/ssl/SSL_set_fd.html</A>>
|
|
<DT id="305">•<DD>
|
|
set_info_callback
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the callback function, that can be used to obtain state information for <TT>$ssl</TT> during connection setup and use.
|
|
When callback is undef, the callback setting currently valid for ctx is used.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::set_info_callback($ssl, $cb, [$data]);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $cb - sub { my ($ssl,$where,$ret,$data) = @_; ... }
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_info_callback.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_info_callback.html</A>>
|
|
<DT id="306">•<DD>
|
|
CTX_set_info_callback
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the callback function on ctx, that can be used to obtain state information during ssl connection setup and use.
|
|
When callback is undef, an existing callback will be disabled.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::CTX_set_info_callback($ssl, $cb, [$data]);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $cb - sub { my ($ssl,$where,$ret,$data) = @_; ... }
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_info_callback.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_info_callback.html</A>>
|
|
<DT id="307">•<DD>
|
|
set_pref_cipher
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the list of available ciphers for <TT>$ssl</TT> using the control string <TT>$str</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::set_pref_cipher($ssl, $str);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $str - (string) cipher list e.g. '3DES:+RSA'
|
|
#
|
|
# returns: 1 if any cipher could be selected and 0 on complete failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_cipher_list.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_cipher_list.html</A>>
|
|
<DT id="308">•<DD>
|
|
CTX_set_psk_client_callback
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the psk client callback.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::CTX_set_psk_client_callback($ssl, sub { my $hint = shift; return ($identity, $key) } );
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $hint - PSK identity hint send by the server
|
|
# $identity - PSK identity
|
|
# $key - PSK key, hex string without the leading '0x', e.g. 'deadbeef'
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_psk_client_callback.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_psk_client_callback.html</A>>
|
|
<DT id="309">•<DD>
|
|
set_purpose
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::set_purpose($ssl, $purpose);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $purpose - (integer) purpose identifier
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
For more info about available <TT>$purpose</TT> identifiers see ``CTX_set_purpose''.
|
|
<DT id="310">•<DD>
|
|
set_quiet_shutdown
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the 'quiet shutdown' flag for <TT>$ssl</TT> to be <TT>$mode</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::set_quiet_shutdown($ssl, $mode);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $mode - 0 or 1
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_quiet_shutdown.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_quiet_shutdown.html</A>>
|
|
<DT id="311">•<DD>
|
|
set_session
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Set a <FONT SIZE="-1">TLS/SSL</FONT> session to be used during <FONT SIZE="-1">TLS/SSL</FONT> connect.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::set_session($to, $ses);
|
|
# $to - value corresponding to openssl's SSL structure
|
|
# $ses - value corresponding to openssl's SSL_SESSION structure
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_set_session.html">http://www.openssl.org/docs/ssl/SSL_set_session.html</A>>
|
|
<DT id="312">•<DD>
|
|
set_session_id_context
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the context <TT>$sid_ctx</TT> of length <TT>$sid_ctx_len</TT> within which a session can be reused for the <TT>$ssl</TT> object.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::set_session_id_context($ssl, $sid_ctx, $sid_ctx_len);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $sid_ctx - data buffer
|
|
# $sid_ctx_len - length of data in $sid_ctx
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_session_id_context.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_session_id_context.html</A>>
|
|
<DT id="313">•<DD>
|
|
set_session_secret_cb
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Setup pre-shared secret session resumption function.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::set_session_secret_cb($ssl, $func, $data);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $func - perl reference to callback function
|
|
# $data - [optional] data that will be passed to callback function when invoked
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
The callback function will be called like:
|
|
callback_function($secret, <TT>$ciphers</TT>, <TT>$pref_cipher</TT>, <TT>$data</TT>);
|
|
|
|
|
|
<P>
|
|
|
|
|
|
# <TT>$secret</TT> is the current master session key, usually all 0s at the beginning of a session
|
|
# <TT>$ciphers</TT> is ref to an array of peer cipher names
|
|
# <TT>$pref_cipher</TT> is a ref to an index into the list of cipher names of
|
|
# the preferred cipher. Set it if you want to specify a preferred cipher
|
|
# <TT>$data</TT> is the data passed to set_session_secret_cb
|
|
|
|
|
|
<P>
|
|
|
|
|
|
The callback function should return 1 if it likes the suggested cipher (or has selected an alternative
|
|
by setting pref_cipher), else it should return 0 (in which case OpenSSL will select its own preferred cipher).
|
|
|
|
|
|
<P>
|
|
|
|
|
|
With OpenSSL 1.1 and later, callback_function can change the master key for the session by
|
|
altering <TT>$secret</TT> and returning 1.
|
|
<DT id="314">•<DD>
|
|
CTX_set_tlsext_ticket_getkey_cb
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Setup encryption for <FONT SIZE="-1">TLS</FONT> session tickets (stateless session reuse).
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::CTX_set_tlsext_ticket_getkey_cb($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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
The callback function will be called like:
|
|
getkey($data,[$key_name]) -> ($key,$current_key_name)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
# <TT>$data</TT> is the data passed to set_session_secret_cb
|
|
# <TT>$key_name</TT> is the name of the key OpenSSL has extracted from the session ticket
|
|
# <TT>$key</TT> is the requested key for ticket encryption + <FONT SIZE="-1">HMAC</FONT>
|
|
# <TT>$current_key_name</TT> is the name for the currently valid key
|
|
|
|
|
|
<P>
|
|
|
|
|
|
OpenSSL will call the function without a key name if it generates a new ticket.
|
|
It then needs the callback to return the encryption+HMAC key and an identifier
|
|
(key name) for this key.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
When OpenSSL gets a session ticket from the client it extracts the key name and
|
|
calls the callback with this name as argument. It then expects the callback to
|
|
return the encryption+HMAC key matching the requested key name and and also the
|
|
key name which should be used at the moment. If the requested key name and the
|
|
returned key name differ it means that this session ticket was created with an
|
|
expired key and need to be renewed. In this case OpenSSL will call the callback
|
|
again with no key name to create a new session ticket based on the old one.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
The key must be at least 32 byte of random data which can be created with
|
|
RAND_bytes. Internally the first 16 byte are used as key in <FONT SIZE="-1">AES-128</FONT> encryption
|
|
while the next 16 byte are used for the <FONT SIZE="-1">SHA-256 HMAC.</FONT>
|
|
The key name are binary data and must be exactly 16 byte long.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Example:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::RAND_bytes(my $oldkey,32);
|
|
Net::SSLeay::RAND_bytes(my $newkey,32);
|
|
my $oldkey_name = pack("a16",'oldsecret');
|
|
my $newkey_name = pack("a16",'newsecret');
|
|
|
|
my @keys = (
|
|
[ $newkey_name, $newkey ], # current active key
|
|
[ $oldkey_name, $oldkey ], # already expired
|
|
);
|
|
|
|
Net::SSLeay::CTX_set_tlsext_ticket_getkey_cb($server2->_ctx, sub {
|
|
my ($mykeys,$name) = @_;
|
|
|
|
# return (current_key, current_key_name) if no name given
|
|
return ($mykeys->[0][1],$mykeys->[0][0]) if ! $name;
|
|
|
|
# return (matching_key, current_key_name) if we find a key matching
|
|
# the given name
|
|
for(my $i = 0; $i<@$mykeys; $i++) {
|
|
next if $name ne $mykeys->[$i][0];
|
|
return ($mykeys->[$i][1],$mykeys->[0][0]);
|
|
}
|
|
|
|
# no matching key found
|
|
return;
|
|
},\@keys);
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
This function is based on the OpenSSL function SSL_CTX_set_tlsext_ticket_key_cb
|
|
but provides a simpler to use interface. For more information see
|
|
<<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_tlsext_ticket_key_cb.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_tlsext_ticket_key_cb.html</A>>
|
|
<DT id="315">•<DD>
|
|
set_session_ticket_ext_cb
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Setup callback for <FONT SIZE="-1">TLS</FONT> session tickets (stateless session reuse).
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::set_session_ticket_ext_cb($ssl, $func, $data);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $func - perl reference to callback function
|
|
# $data - [optional] data that will be passed to callback function when invoked
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
The callback function will be called like:
|
|
getticket($ssl,$ticket,$data) -> <TT>$return_value</TT>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
# <TT>$ssl</TT> is a value corresponding to openssl's <FONT SIZE="-1">SSL</FONT> structure
|
|
# <TT>$ticket</TT> is a value of received <FONT SIZE="-1">TLS</FONT> session ticket (can also be empty)
|
|
# <TT>$data</TT> is the data passed to set_session_ticket_ext_cb
|
|
# <TT>$return_value</TT> is either 0 (failure) or 1 (success)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
This function is based on the OpenSSL function SSL_set_session_ticket_ext_cb.
|
|
<DT id="316">•<DD>
|
|
set_session_ticket_ext
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Set <FONT SIZE="-1">TLS</FONT> session ticket (stateless session reuse).
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::set_session_ticket_ext($ssl, $ticket);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $ticket - is a value of TLS session ticket which client will send (can also be empty string)
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
The callback function will be called like:
|
|
getticket($ssl,$ticket,$data) -> <TT>$return_value</TT>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
# <TT>$ssl</TT> is a value corresponding to openssl's <FONT SIZE="-1">SSL</FONT> structure
|
|
# <TT>$ticket</TT> is a value of received <FONT SIZE="-1">TLS</FONT> session ticket (can also be empty)
|
|
# <TT>$data</TT> is the data passed to set_session_ticket_ext_cb
|
|
# <TT>$return_value</TT> is either 0 (failure) or 1 (success)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
This function is based on the OpenSSL function SSL_set_session_ticket_ext_cb.
|
|
<DT id="317">•<DD>
|
|
set_shutdown
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the shutdown state of <TT>$ssl</TT> to <TT>$mode</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::set_shutdown($ssl, $mode);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $mode - (integer) shutdown mode:
|
|
# 0 - No shutdown
|
|
# 1 - SSL_SENT_SHUTDOWN
|
|
# 2 - SSL_RECEIVED_SHUTDOWN
|
|
# 3 - SSL_RECEIVED_SHUTDOWN+SSL_SENT_SHUTDOWN
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_set_shutdown.html">http://www.openssl.org/docs/ssl/SSL_set_shutdown.html</A>>
|
|
<DT id="318">•<DD>
|
|
set_ssl_method
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets a new <FONT SIZE="-1">TLS/SSL</FONT> method for a particular <TT>$ssl</TT> object.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::set_ssl_method($ssl, $method);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $method - value corresponding to openssl's SSL_METHOD structure
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_ssl_version.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_ssl_version.html</A>>
|
|
<DT id="319">•<DD>
|
|
set_tmp_dh
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets <FONT SIZE="-1">DH</FONT> parameters to be used to be <TT>$dh</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::set_tmp_dh($ssl, $dh);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $dh - value corresponding to openssl's DH structure
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_tmp_dh_callback.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_tmp_dh_callback.html</A>>
|
|
<DT id="320">•<DD>
|
|
set_tmp_dh_callback
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the callback function for <TT>$ssl</TT> to be used when a <FONT SIZE="-1">DH</FONT> parameters are required to <TT>$dh_cb</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
??? (does this function really work?)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::set_tmp_dh_callback($ssl, $dh);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $dh_cb - pointer to function ???
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_tmp_dh_callback.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_tmp_dh_callback.html</A>>
|
|
<DT id="321">•<DD>
|
|
set_tmp_rsa
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the temporary/ephemeral <FONT SIZE="-1">RSA</FONT> key to be used in <TT>$ssl</TT> to be <TT>$rsa</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::set_tmp_rsa($ssl, $rsa);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $rsa - value corresponding to openssl's RSA structure
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Example:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
$rsakey = Net::SSLeay::RSA_generate_key();
|
|
Net::SSLeay::set_tmp_rsa($ssl, $rsakey);
|
|
Net::SSLeay::RSA_free($rsakey);
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_tmp_rsa_callback.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_tmp_rsa_callback.html</A>>
|
|
<DT id="322">•<DD>
|
|
set_tmp_rsa_callback
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the callback function for <TT>$ssl</TT> to be used when a temporary/ephemeral <FONT SIZE="-1">RSA</FONT> key is required to <TT>$tmp_rsa_callback</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
??? (does this function really work?)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::set_tmp_rsa_callback($ssl, $tmp_rsa_callback);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $tmp_rsa_callback - (function pointer) ???
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_tmp_rsa_callback.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_tmp_rsa_callback.html</A>>
|
|
<DT id="323">•<DD>
|
|
set_trust
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::set_trust($ssl, $trust);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $trust - (integer) trust identifier
|
|
#
|
|
# returns: the original value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
For more details about <TT>$trust</TT> values see ``CTX_set_trust''.
|
|
<DT id="324">•<DD>
|
|
shutdown
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Shuts down an active <FONT SIZE="-1">TLS/SSL</FONT> connection. It sends the 'close notify' shutdown alert to the peer.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::shutdown($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: 1 - shutdown was successfully completed
|
|
# 0 - shutdown is not yet finished,
|
|
# -1 - shutdown was not successful
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_shutdown.html">http://www.openssl.org/docs/ssl/SSL_shutdown.html</A>>
|
|
<DT id="325">•<DD>
|
|
state_string
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns a 6 letter string indicating the current state of the <FONT SIZE="-1">SSL</FONT> object <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::state_string($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: 6-letter string
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_state_string.html">http://www.openssl.org/docs/ssl/SSL_state_string.html</A>>
|
|
<DT id="326">•<DD>
|
|
state_string_long
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns a string indicating the current state of the <FONT SIZE="-1">SSL</FONT> object <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::state_string_long($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: state strings
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_state_string.html">http://www.openssl.org/docs/ssl/SSL_state_string.html</A>>
|
|
<DT id="327">•<DD>
|
|
set_default_passwd_cb
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.82 and before; requires at least OpenSSL 1.1.0f. Not needed with LibreSSL.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the default password callback called when loading/storing a <FONT SIZE="-1">PEM</FONT> certificate with encryption for <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::set_default_passwd_cb($ssl, $func);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $func - perl reference to callback function
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_default_passwd_cb.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_default_passwd_cb.html</A>>
|
|
<DT id="328">•<DD>
|
|
set_default_passwd_cb_userdata
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.82 and before; requires at least OpenSSL 1.1.0f. Not needed with LibreSSL.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets a pointer to userdata which will be provided to the password callback of <TT>$ssl</TT> on invocation.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::set_default_passwd_cb_userdata($ssl, $userdata);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $userdata - data that will be passed to callback function when invoked
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_default_passwd_cb.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_default_passwd_cb.html</A>>
|
|
<DT id="329">•<DD>
|
|
use_PrivateKey
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Adds <TT>$pkey</TT> as private key to <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::use_PrivateKey($ssl, $pkey);
|
|
# $ssl - value corresponding to openssl's SSL 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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_use_certificate.html">http://www.openssl.org/docs/ssl/SSL_CTX_use_certificate.html</A>>
|
|
<DT id="330">•<DD>
|
|
use_PrivateKey_ASN1
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Adds the private key of type <TT>$pk</TT> stored in <TT>$data</TT> to <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::use_PrivateKey_ASN1($pk, $ssl, $d, $len);
|
|
# $pk - (integer) key type, NID of corresponding algorithm
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $data - key data (binary)
|
|
# $len - length of $data
|
|
#
|
|
# returns: 1 on success, otherwise check out the error stack to find out the reason
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_use_certificate.html">http://www.openssl.org/docs/ssl/SSL_CTX_use_certificate.html</A>>
|
|
<DT id="331">•<DD>
|
|
use_PrivateKey_file
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Adds the first private key found in <TT>$file</TT> to <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::use_PrivateKey_file($ssl, $file, $type);
|
|
# $ssl - value corresponding to openssl's SSL 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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_use_certificate.html">http://www.openssl.org/docs/ssl/SSL_CTX_use_certificate.html</A>>
|
|
<DT id="332">•<DD>
|
|
use_RSAPrivateKey
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Adds <TT>$rsa</TT> as <FONT SIZE="-1">RSA</FONT> private key to <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::use_RSAPrivateKey($ssl, $rsa);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $rsa - value corresponding to openssl's RSA structure
|
|
#
|
|
# returns: 1 on success, otherwise check out the error stack to find out the reason
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_use_certificate.html">http://www.openssl.org/docs/ssl/SSL_CTX_use_certificate.html</A>>
|
|
<DT id="333">•<DD>
|
|
use_RSAPrivateKey_ASN1
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Adds <FONT SIZE="-1">RSA</FONT> private key stored in <TT>$data</TT> to <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::use_RSAPrivateKey_ASN1($ssl, $data, $len);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $data - key data (binary)
|
|
# $len - length of $data
|
|
#
|
|
# returns: 1 on success, otherwise check out the error stack to find out the reason
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_use_certificate.html">http://www.openssl.org/docs/ssl/SSL_CTX_use_certificate.html</A>>
|
|
<DT id="334">•<DD>
|
|
use_RSAPrivateKey_file
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Adds the first <FONT SIZE="-1">RSA</FONT> private key found in <TT>$file</TT> to <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::use_RSAPrivateKey_file($ssl, $file, $type);
|
|
# $ssl - value corresponding to openssl's SSL 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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_use_certificate.html">http://www.openssl.org/docs/ssl/SSL_CTX_use_certificate.html</A>>
|
|
<DT id="335">•<DD>
|
|
use_certificate
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Loads the certificate <TT>$x</TT> into <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::use_certificate($ssl, $x);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $x - value corresponding to openssl's X509 structure
|
|
#
|
|
# returns: 1 on success, otherwise check out the error stack to find out the reason
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_use_certificate.html">http://www.openssl.org/docs/ssl/SSL_CTX_use_certificate.html</A>>
|
|
<DT id="336">•<DD>
|
|
use_certificate_ASN1
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Loads the <FONT SIZE="-1">ASN1</FONT> encoded certificate from <TT>$data</TT> to <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::use_certificate_ASN1($ssl, $data, $len);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $data - certificate data (binary)
|
|
# $len - length of $data
|
|
#
|
|
# returns: 1 on success, otherwise check out the error stack to find out the reason
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_use_certificate.html">http://www.openssl.org/docs/ssl/SSL_CTX_use_certificate.html</A>>
|
|
<DT id="337">•<DD>
|
|
use_certificate_chain_file
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY</B></FONT><B></B>: not available in Net-SSLeay-1.82 and before; requires at least OpenSSL 1.1.0
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Loads a certificate chain from <TT>$file</TT> into <TT>$ssl</TT>. The certificates must be in <FONT SIZE="-1">PEM</FONT> format and must be sorted
|
|
starting with the subject's certificate (actual client or server certificate), followed by intermediate
|
|
<FONT SIZE="-1">CA</FONT> certificates if applicable, and ending at the highest level (root) <FONT SIZE="-1">CA.</FONT>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::use_certificate_chain_file($ssl, $file);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $file - (string) file name
|
|
#
|
|
# returns: 1 on success, otherwise check out the error stack to find out the reason
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_use_certificate.html">http://www.openssl.org/docs/ssl/SSL_CTX_use_certificate.html</A>>
|
|
<DT id="338">•<DD>
|
|
use_certificate_file
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Loads the first certificate stored in <TT>$file</TT> into <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::use_certificate_file($ssl, $file, $type);
|
|
# $ssl - value corresponding to openssl's SSL 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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_use_certificate.html">http://www.openssl.org/docs/ssl/SSL_CTX_use_certificate.html</A>>
|
|
<DT id="339">•<DD>
|
|
get_version
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns <FONT SIZE="-1">SSL/TLS</FONT> protocol name
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::get_version($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: (string) protocol name, see OpenSSL manual for the full list
|
|
# TLSv1
|
|
# TLSv1.3
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/manmaster/man3/SSL_get_version.html">https://www.openssl.org/docs/manmaster/man3/SSL_get_version.html</A>>
|
|
<DT id="340">•<DD>
|
|
version
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns <FONT SIZE="-1">SSL/TLS</FONT> protocol version
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::version($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: (integer) protocol version, see OpenSSL manual for the full list
|
|
# 0x0301 - TLS1_VERSION (TLSv1)
|
|
# 0xFEFF - DTLS1_VERSION (DTLSv1)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/manmaster/man3/SSL_version.html">https://www.openssl.org/docs/manmaster/man3/SSL_version.html</A>>
|
|
<DT id="341">•<DD>
|
|
client_version
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.0, not in LibreSSL
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns <FONT SIZE="-1">TLS</FONT> protocol version used by the client when initiating the connection
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::client_version($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: (integer) protocol version, see OpenSSL manual for the full list
|
|
# 0x0301 - TLS1_VERSION (TLSv1)
|
|
# 0xFEFF - DTLS1_VERSION (DTLSv1)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/manmaster/man3/SSL_client_version.html">https://www.openssl.org/docs/manmaster/man3/SSL_client_version.html</A>>
|
|
<DT id="342">•<DD>
|
|
is_dtls
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.0, not in LibreSSL
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::is_dtls($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: (integer) zero or one
|
|
# 0 - connection is not using DTLS
|
|
# 1 - connection is using DTLS
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/manmaster/man3/SSL_is_dtls.html">https://www.openssl.org/docs/manmaster/man3/SSL_is_dtls.html</A>>
|
|
<DT id="343">•<DD>
|
|
want
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns state information for the <FONT SIZE="-1">SSL</FONT> object <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::want($ssl);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: state
|
|
# 1 - SSL_NOTHING
|
|
# 2 - SSL_WRITING
|
|
# 3 - SSL_READING
|
|
# 4 - SSL_X509_LOOKUP
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_want.html">http://www.openssl.org/docs/ssl/SSL_want.html</A>>
|
|
<DT id="344">•<DD>
|
|
write
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Writes data from the buffer <TT>$data</TT> into the specified <TT>$ssl</TT> connection.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::write($ssl, $data);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $data - data to be written
|
|
#
|
|
# returns: >0 - (success) number of bytes actually written to the TLS/SSL connection
|
|
# 0 - write not successful, probably the underlying connection was closed
|
|
# <0 - error
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_write.html">http://www.openssl.org/docs/ssl/SSL_write.html</A>>
|
|
<DT id="345">•<DD>
|
|
write_ex
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.1, not in LibreSSL
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Writes data from the buffer <TT>$data</TT> into the specified <TT>$ssl</TT> connection.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my ($len, $rv) = Net::SSLeay::write_ex($ssl, $data);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $data - data to be written
|
|
#
|
|
# returns a list: two-item list consisting of number of bytes written,
|
|
# and return code from SSL_write_ex()
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/manmaster/man3/SSL_write_ex.html">https://www.openssl.org/docs/manmaster/man3/SSL_write_ex.html</A>>
|
|
<DT id="346">•<DD>
|
|
write_partial
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>NOTE:</B></FONT><B></B> Does not exactly correspond to any low level <FONT SIZE="-1">API</FONT> function
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Writes a fragment of data in <TT>$data</TT> from the buffer <TT>$data</TT> into the specified
|
|
<TT>$ssl</TT> connection. This is a non-blocking function like <B>Net::SSLeay::write()</B>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::write_partial($ssl, $from, $count, $data);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $from - (integer) offset from the beginning of $data
|
|
# $count - (integer) length of data to be written
|
|
# $data - data buffer
|
|
#
|
|
# returns: >0 - (success) number of bytes actually written to the TLS/SSL connection
|
|
# 0 - write not successful, probably the underlying connection was closed
|
|
# <0 - error
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="347">•<DD>
|
|
set_tlsext_host_name
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before; requires at least openssl-0.9.8f
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets <FONT SIZE="-1">TLS</FONT> servername extension on <FONT SIZE="-1">SLL</FONT> object <TT>$ssl</TT> to value <TT>$name</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = set_tlsext_host_name($ssl, $name);
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
# $name - (string) name to be set
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
</DL>
|
|
<P>
|
|
|
|
<I>Low level </I><FONT SIZE="-1"><I>API:</I></FONT><I> RAND_* related functions</I>
|
|
|
|
|
|
<P>
|
|
|
|
Check openssl doc related to <FONT SIZE="-1">RAND</FONT> stuff <<A HREF="http://www.openssl.org/docs/crypto/rand.html">http://www.openssl.org/docs/crypto/rand.html</A>>
|
|
<DL COMPACT>
|
|
<DT id="348">•<DD>
|
|
RAND_add
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Mixes the <TT>$num</TT> bytes at <TT>$buf</TT> into the <FONT SIZE="-1">PRNG</FONT> state.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::RAND_add($buf, $num, $entropy);
|
|
# $buf - buffer with data to be mixed into the PRNG state
|
|
# $num - number of bytes in $buf
|
|
# $entropy - estimate of how much randomness is contained in $buf (in bytes)
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/RAND_add.html">http://www.openssl.org/docs/crypto/RAND_add.html</A>>
|
|
<DT id="349">•<DD>
|
|
RAND_seed
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Equivalent to ``RAND_add'' when <TT>$num</TT> == <TT>$entropy</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::RAND_seed($buf); # Perlishly figures out buf size
|
|
# $buf - buffer with data to be mixed into the PRNG state
|
|
# $num - number of bytes in $buf
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/RAND_add.html">http://www.openssl.org/docs/crypto/RAND_add.html</A>>
|
|
<DT id="350">•<DD>
|
|
RAND_status
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Gives <FONT SIZE="-1">PRNG</FONT> status (seeded enough or not).
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::RAND_status();
|
|
#returns: 1 if the PRNG has been seeded with enough data, 0 otherwise
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/RAND_add.html">http://www.openssl.org/docs/crypto/RAND_add.html</A>>
|
|
<DT id="351">•<DD>
|
|
RAND_bytes
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Puts <TT>$num</TT> cryptographically strong pseudo-random bytes into <TT>$buf</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::RAND_bytes($buf, $num);
|
|
# $buf - buffer where the random data will be stored
|
|
# $num - the size (in bytes) of requested random data
|
|
#
|
|
# returns: 1 on success, -1 if not supported by the current RAND method, or 0 on other failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/manmaster/man3/RAND_bytes.html">http://www.openssl.org/docs/manmaster/man3/RAND_bytes.html</A>>
|
|
<DT id="352">•<DD>
|
|
RAND_priv_bytes
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.85 and before; requires at least OpenSSL 1.1.1, not in LibreSSL
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Puts <TT>$num</TT> cryptographically strong pseudo-random bytes into <TT>$buf</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::RAND_priv_bytes($buf, $num);
|
|
# $buf - buffer where the random data will be stored
|
|
# $num - the size (in bytes) of requested random data
|
|
#
|
|
# returns: 1 on success, -1 if not supported by the current RAND method, or 0 on other failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
RAND_priv_bytes has the same semantics as RAND_bytes, but see see the documentation for more information.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/manmaster/man3/RAND_priv_bytes.html">http://www.openssl.org/docs/manmaster/man3/RAND_priv_bytes.html</A>>
|
|
<DT id="353">•<DD>
|
|
RAND_pseudo_bytes
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Puts <TT>$num</TT> pseudo-random (not necessarily unpredictable) bytes into <TT>$buf</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::RAND_pseudo_bytes($buf, $num);
|
|
# $buf - buffer where the random data will be stored
|
|
# $num - the size (in bytes) of requested random data
|
|
#
|
|
# returns: 1 if the bytes generated are cryptographically strong, 0 otherwise
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/RAND_bytes.html">http://www.openssl.org/docs/crypto/RAND_bytes.html</A>>
|
|
<DT id="354">•<DD>
|
|
RAND_cleanup
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Erase the <FONT SIZE="-1">PRNG</FONT> state.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::RAND_cleanup();
|
|
# no args, no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/RAND_cleanup.html">http://www.openssl.org/docs/crypto/RAND_cleanup.html</A>>
|
|
<DT id="355">•<DD>
|
|
RAND_egd_bytes
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Queries the entropy gathering daemon <FONT SIZE="-1">EGD</FONT> on socket <TT>$path</TT> for <TT>$bytes</TT> bytes.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::RAND_egd_bytes($path, $bytes);
|
|
# $path - path to a socket of entropy gathering daemon EGD
|
|
# $bytes - number of bytes we want from EGD
|
|
#
|
|
# returns: the number of bytes read from the daemon on success, and -1 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/RAND_egd.html">http://www.openssl.org/docs/crypto/RAND_egd.html</A>>
|
|
<DT id="356">•<DD>
|
|
RAND_file_name
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Generates a default path for the random seed file.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $file = Net::SSLeay::RAND_file_name($num);
|
|
# $num - maximum size of returned file name
|
|
#
|
|
# returns: string with file name on success, '' (empty string) on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/RAND_load_file.html">http://www.openssl.org/docs/crypto/RAND_load_file.html</A>>
|
|
<DT id="357">•<DD>
|
|
RAND_load_file
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> Is no longer functional on LibreSSL
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Reads <TT>$max_bytes</TT> of bytes from <TT>$file_name</TT> and adds them to the <FONT SIZE="-1">PRNG.</FONT>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::RAND_load_file($file_name, $max_bytes);
|
|
# $file_name - the name of file
|
|
# $max_bytes - bytes to read from $file_name; -1 => the complete file is read
|
|
#
|
|
# returns: the number of bytes read
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/RAND_load_file.html">http://www.openssl.org/docs/crypto/RAND_load_file.html</A>>
|
|
<DT id="358">•<DD>
|
|
RAND_write_file
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Writes 1024 random bytes to <TT>$file_name</TT> which can be used to initialize the <FONT SIZE="-1">PRNG</FONT> by calling ``RAND_load_file'' in a later session.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::RAND_write_file($file_name);
|
|
# $file_name - the name of file
|
|
#
|
|
# returns: the number of bytes written, and -1 if the bytes written were generated without appropriate seed
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/RAND_load_file.html">http://www.openssl.org/docs/crypto/RAND_load_file.html</A>>
|
|
<DT id="359">•<DD>
|
|
RAND_poll
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Collects some entropy from operating system and adds it to the <FONT SIZE="-1">PRNG.</FONT>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::RAND_poll();
|
|
# returns: 1 on success, 0 on failure (unable to gather reasonable entropy)
|
|
|
|
</PRE>
|
|
|
|
|
|
</DL>
|
|
<P>
|
|
|
|
<I>Low level </I><FONT SIZE="-1"><I>API:</I></FONT><I> OBJ_* related functions</I>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="360">•<DD>
|
|
OBJ_cmp
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Compares <FONT SIZE="-1">ASN1_OBJECT</FONT> <TT>$a</TT> to <FONT SIZE="-1">ASN1_OBJECT</FONT> <TT>$b</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::OBJ_cmp($a, $b);
|
|
# $a - value corresponding to openssl's ASN1_OBJECT structure
|
|
# $b - value corresponding to openssl's ASN1_OBJECT structure
|
|
#
|
|
# returns: if the two are identical 0 is returned
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/OBJ_nid2obj.html">http://www.openssl.org/docs/crypto/OBJ_nid2obj.html</A>>
|
|
<DT id="361">•<DD>
|
|
OBJ_dup
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns a copy/duplicate of <TT>$o</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::OBJ_dup($o);
|
|
# $o - value corresponding to openssl's ASN1_OBJECT structure
|
|
#
|
|
# returns: value corresponding to openssl's ASN1_OBJECT structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/OBJ_nid2obj.html">http://www.openssl.org/docs/crypto/OBJ_nid2obj.html</A>>
|
|
<DT id="362">•<DD>
|
|
OBJ_nid2ln
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns long name for given <FONT SIZE="-1">NID</FONT> <TT>$n</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::OBJ_nid2ln($n);
|
|
# $n - (integer) NID
|
|
#
|
|
# returns: (string) long name e.g. 'commonName'
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/OBJ_nid2obj.html">http://www.openssl.org/docs/crypto/OBJ_nid2obj.html</A>>
|
|
<DT id="363">•<DD>
|
|
OBJ_ln2nid
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns <FONT SIZE="-1">NID</FONT> corresponding to given long name <TT>$n</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::OBJ_ln2nid($s);
|
|
# $s - (string) long name e.g. 'commonName'
|
|
#
|
|
# returns: (integer) NID
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="364">•<DD>
|
|
OBJ_nid2sn
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns short name for given <FONT SIZE="-1">NID</FONT> <TT>$n</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::OBJ_nid2sn($n);
|
|
# $n - (integer) NID
|
|
#
|
|
# returns: (string) short name e.g. 'CN'
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Example:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
print Net::SSLeay::OBJ_nid2sn(&Net::SSLeay::NID_commonName);
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="365">•<DD>
|
|
OBJ_sn2nid
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns <FONT SIZE="-1">NID</FONT> corresponding to given short name <TT>$s</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::OBJ_sn2nid($s);
|
|
# $s - (string) short name e.g. 'CN'
|
|
#
|
|
# returns: (integer) NID
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Example:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
print "NID_commonName constant=", &Net::SSLeay::NID_commonName;
|
|
print "OBJ_sn2nid('CN')=", Net::SSLeay::OBJ_sn2nid('CN');
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="366">•<DD>
|
|
OBJ_nid2obj
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns <FONT SIZE="-1">ASN1_OBJECT</FONT> for given <FONT SIZE="-1">NID</FONT> <TT>$n</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::OBJ_nid2obj($n);
|
|
# $n - (integer) NID
|
|
#
|
|
# returns: value corresponding to openssl's ASN1_OBJECT structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/OBJ_nid2obj.html">http://www.openssl.org/docs/crypto/OBJ_nid2obj.html</A>>
|
|
<DT id="367">•<DD>
|
|
OBJ_obj2nid
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns <FONT SIZE="-1">NID</FONT> corresponding to given <FONT SIZE="-1">ASN1_OBJECT</FONT> <TT>$o</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::OBJ_obj2nid($o);
|
|
# $o - value corresponding to openssl's ASN1_OBJECT structure
|
|
#
|
|
# returns: (integer) NID
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/OBJ_nid2obj.html">http://www.openssl.org/docs/crypto/OBJ_nid2obj.html</A>>
|
|
<DT id="368">•<DD>
|
|
OBJ_txt2obj
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Converts the text string s into an <FONT SIZE="-1">ASN1_OBJECT</FONT> structure. If <TT>$no_name</TT> is 0 then
|
|
long names (e.g. 'commonName') and short names (e.g. '<FONT SIZE="-1">CN</FONT>') will be interpreted
|
|
as well as numerical forms (e.g. '2.5.4.3'). If <TT>$no_name</TT> is 1 only the numerical
|
|
form is acceptable.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::OBJ_txt2obj($s, $no_name);
|
|
# $s - text string to be converted
|
|
# $no_name - (integer) 0 or 1
|
|
#
|
|
# returns: value corresponding to openssl's ASN1_OBJECT structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/OBJ_nid2obj.html">http://www.openssl.org/docs/crypto/OBJ_nid2obj.html</A>>
|
|
<DT id="369">•<DD>
|
|
OBJ_obj2txt
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Converts the <FONT SIZE="-1">ASN1_OBJECT</FONT> a into a textual representation.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::OBJ_obj2txt($a, $no_name);
|
|
# $a - value corresponding to openssl's ASN1_OBJECT structure
|
|
# $no_name - (integer) 0 or 1
|
|
#
|
|
# returns: textual representation e.g. 'commonName' ($no_name=0), '2.5.4.3' ($no_name=1)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/OBJ_nid2obj.html">http://www.openssl.org/docs/crypto/OBJ_nid2obj.html</A>>
|
|
<DT id="370">•<DD>
|
|
OBJ_txt2nid
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns <FONT SIZE="-1">NID</FONT> corresponding to text string <TT>$s</TT> which can be a long name, a short name or the numerical representation of an object.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::OBJ_txt2nid($s);
|
|
# $s - (string) e.g. 'commonName' or 'CN' or '2.5.4.3'
|
|
#
|
|
# returns: (integer) NID
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Example:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $nid = Net::SSLeay::OBJ_txt2nid('2.5.4.3');
|
|
Net::SSLeay::OBJ_nid2sn($n);
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/OBJ_nid2obj.html">http://www.openssl.org/docs/crypto/OBJ_nid2obj.html</A>>
|
|
</DL>
|
|
<P>
|
|
|
|
<I>Low level </I><FONT SIZE="-1"><I>API:</I></FONT><I> ASN1_INTEGER_* related functions</I>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="371">•<DD>
|
|
ASN1_INTEGER_new
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Creates a new <FONT SIZE="-1">ASN1_INTEGER</FONT> structure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::ASN1_INTEGER_new();
|
|
#
|
|
# returns: value corresponding to openssl's ASN1_INTEGER structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="372">•<DD>
|
|
ASN1_INTEGER_free
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Free an allocated <FONT SIZE="-1">ASN1_INTEGER</FONT> structure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::ASN1_INTEGER_free($i);
|
|
# $i - value corresponding to openssl's ASN1_INTEGER structure
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="373">•<DD>
|
|
ASN1_INTEGER_get
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns integer value of given <FONT SIZE="-1">ASN1_INTEGER</FONT> object.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>BEWARE:</B></FONT><B></B> If the value stored in <FONT SIZE="-1">ASN1_INTEGER</FONT> is greater than max. integer that can be stored
|
|
in 'long' type (usually 32bit but may vary according to platform) then this function will return -1.
|
|
For getting large <FONT SIZE="-1">ASN1_INTEGER</FONT> values consider using ``P_ASN1_INTEGER_get_dec'' or ``P_ASN1_INTEGER_get_hex''.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::ASN1_INTEGER_get($a);
|
|
# $a - value corresponding to openssl's ASN1_INTEGER structure
|
|
#
|
|
# returns: integer value of ASN1_INTEGER object in $a
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="374">•<DD>
|
|
ASN1_INTEGER_set
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets value of given <FONT SIZE="-1">ASN1_INTEGER</FONT> object to value <TT>$val</TT>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>BEWARE:</B></FONT><B></B> <TT>$val</TT> has max. limit (= max. integer that can be stored in 'long' type).
|
|
For setting large <FONT SIZE="-1">ASN1_INTEGER</FONT> values consider using ``P_ASN1_INTEGER_set_dec'' or ``P_ASN1_INTEGER_set_hex''.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::ASN1_INTEGER_set($i, $val);
|
|
# $i - value corresponding to openssl's ASN1_INTEGER structure
|
|
# $val - integer value
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="375">•<DD>
|
|
P_ASN1_INTEGER_get_dec
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns string with decimal representation of integer value of given <FONT SIZE="-1">ASN1_INTEGER</FONT> object.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::P_ASN1_INTEGER_get_dec($i);
|
|
# $i - value corresponding to openssl's ASN1_INTEGER structure
|
|
#
|
|
# returns: string with decimal representation
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="376">•<DD>
|
|
P_ASN1_INTEGER_get_hex
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns string with hexadecimal representation of integer value of given <FONT SIZE="-1">ASN1_INTEGER</FONT> object.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::P_ASN1_INTEGER_get_hex($i);
|
|
# $i - value corresponding to openssl's ASN1_INTEGER structure
|
|
#
|
|
# returns: string with hexadecimal representation
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="377">•<DD>
|
|
P_ASN1_INTEGER_set_dec
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets value of given <FONT SIZE="-1">ASN1_INTEGER</FONT> object to value <TT>$val</TT> (decimal string, suitable for large integers)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::P_ASN1_INTEGER_set_dec($i, $str);
|
|
# $i - value corresponding to openssl's ASN1_INTEGER structure
|
|
# $str - string with decimal representation
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="378">•<DD>
|
|
P_ASN1_INTEGER_set_hex
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets value of given <FONT SIZE="-1">ASN1_INTEGER</FONT> object to value <TT>$val</TT> (hexadecimal string, suitable for large integers)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::P_ASN1_INTEGER_set_hex($i, $str);
|
|
# $i - value corresponding to openssl's ASN1_INTEGER structure
|
|
# $str - string with hexadecimal representation
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
</DL>
|
|
<P>
|
|
|
|
<I>Low level </I><FONT SIZE="-1"><I>API:</I></FONT><I> ASN1_STRING_* related functions</I>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="379">•<DD>
|
|
P_ASN1_STRING_get
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns string value of given <FONT SIZE="-1">ASN1_STRING</FONT> object.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::P_ASN1_STRING_get($s, $utf8_decode);
|
|
# $s - value corresponding to openssl's ASN1_STRING structure
|
|
# $utf8_decode - [optional] 0 or 1 whether the returned value should be utf8 decoded (default=0)
|
|
#
|
|
# returns: string
|
|
|
|
$string = Net::SSLeay::P_ASN1_STRING_get($s);
|
|
#is the same as:
|
|
$string = Net::SSLeay::P_ASN1_STRING_get($s, 0);
|
|
|
|
</PRE>
|
|
|
|
|
|
</DL>
|
|
<P>
|
|
|
|
<I>Low level </I><FONT SIZE="-1"><I>API:</I></FONT><I> ASN1_TIME_* related functions</I>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="380">•<DD>
|
|
ASN1_TIME_new
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.42 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $time = ASN1_TIME_new();
|
|
# returns: value corresponding to openssl's ASN1_TIME structure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="381">•<DD>
|
|
ASN1_TIME_free
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.42 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
ASN1_TIME_free($time);
|
|
# $time - value corresponding to openssl's ASN1_TIME structure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="382">•<DD>
|
|
ASN1_TIME_set
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.42 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
ASN1_TIME_set($time, $t);
|
|
# $time - value corresponding to openssl's ASN1_TIME structure
|
|
# $t - time value in seconds since 1.1.1970
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>BEWARE:</B></FONT><B></B> It is platform dependent how this function will handle dates after 2038.
|
|
Although perl's integer is large enough the internal implementation of this function
|
|
is dependent on the size of time_t structure (32bit time_t has problem with 2038).
|
|
|
|
|
|
<P>
|
|
|
|
|
|
If you want to safely set date and time after 2038 use function ``P_ASN1_TIME_set_isotime''.
|
|
<DT id="383">•<DD>
|
|
P_ASN1_TIME_get_isotime
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.42 and before; requires at least openssl-0.9.7e
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>NOTE:</B></FONT><B></B> Does not exactly correspond to any low level <FONT SIZE="-1">API</FONT> function
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Gives <FONT SIZE="-1">ISO-8601</FONT> string representation of <FONT SIZE="-1">ASN1_TIME</FONT> structure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $datetime_string = P_ASN1_TIME_get_isotime($time);
|
|
# $time - value corresponding to openssl's ASN1_TIME structure
|
|
#
|
|
# returns: datetime string like '2033-05-16T20:39:37Z' or '' on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
The output format is compatible with module DateTime::Format::RFC3339
|
|
<DT id="384">•<DD>
|
|
P_ASN1_TIME_set_isotime
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.42 and before; requires at least openssl-0.9.7e
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>NOTE:</B></FONT><B></B> Does not exactly correspond to any low level <FONT SIZE="-1">API</FONT> function
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets time and date value of ANS1_time structure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = P_ASN1_TIME_set_isotime($time, $string);
|
|
# $time - value corresponding to openssl's ASN1_TIME structure
|
|
# $string - ISO-8601 timedate string like '2033-05-16T20:39:37Z'
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
The <TT>$string</TT> parameter has to be in full form like <TT>"2012-03-22T23:55:33"</TT> or
|
|
<TT>"2012-03-22T23:55:33Z"</TT> or <TT>"2012-03-22T23:55:33CET"</TT>. Short forms like
|
|
<TT>"2012-03-22T23:55"</TT> or <TT>"2012-03-22"</TT> are not supported.
|
|
<DT id="385">•<DD>
|
|
P_ASN1_TIME_put2string
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.42 and before, has bugs with openssl-0.9.8i
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>NOTE:</B></FONT><B></B> Does not exactly correspond to any low level <FONT SIZE="-1">API</FONT> function
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Gives string representation of <FONT SIZE="-1">ASN1_TIME</FONT> structure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $str = P_ASN1_TIME_put2string($time);
|
|
# $time - value corresponding to openssl's ASN1_TIME structure
|
|
#
|
|
# returns: datetime string like 'May 16 20:39:37 2033 GMT'
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="386">•<DD>
|
|
P_ASN1_UTCTIME_put2string
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>NOTE:</B></FONT><B></B> deprecated function, only for backward compatibility, just an alias
|
|
for ``P_ASN1_TIME_put2string''
|
|
</DL>
|
|
<P>
|
|
|
|
<I>Low level </I><FONT SIZE="-1"><I>API:</I></FONT><I> X509_* related functions</I>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="387">•<DD>
|
|
X509_new
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Allocates and initializes a X509 structure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_new();
|
|
#
|
|
# returns: value corresponding to openssl's X509 structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/X509_new.html">http://www.openssl.org/docs/crypto/X509_new.html</A>>
|
|
<DT id="388">•<DD>
|
|
X509_free
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Frees up the X509 structure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::X509_free($a);
|
|
# $a - value corresponding to openssl's X509 structure
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/X509_new.html">http://www.openssl.org/docs/crypto/X509_new.html</A>>
|
|
<DT id="389">•<DD>
|
|
X509_check_host
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.68 and before; requires at
|
|
least OpenSSL 1.0.2. X509_CHECK_FLAG_NEVER_CHECK_SUBJECT requires OpenSSL 1.1.0.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Checks f the certificate Subject Alternative Name (<FONT SIZE="-1">SAN</FONT>) or Subject CommonName
|
|
(<FONT SIZE="-1">CN</FONT>) matches the specified host name.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_check_host($cert, $name, $flags, $peername);
|
|
# $cert - value corresponding to openssl's X509 structure
|
|
# $name - host name to check
|
|
# $flags (optional, default: 0) - can be the bitwise OR of:
|
|
# &Net::SSLeay::X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT
|
|
# &Net::SSLeay::X509_CHECK_FLAG_NO_WILDCARDS
|
|
# &Net::SSLeay::X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS
|
|
# &Net::SSLeay::X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS
|
|
# &Net::SSLeay::X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS
|
|
# &Net::SSLeay::X509_CHECK_FLAG_NEVER_CHECK_SUBJECT
|
|
# $peername (optional) - If not omitted and $host matches $cert,
|
|
# a copy of the matching SAN or CN from
|
|
# the peer certificate is stored in $peername.
|
|
#
|
|
# returns:
|
|
# 1 for a successful match
|
|
# 0 for a failed match
|
|
# -1 for an internal error
|
|
# -2 if the input is malformed
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/crypto/X509_check_host.html">https://www.openssl.org/docs/crypto/X509_check_host.html</A>>.
|
|
<DT id="390">•<DD>
|
|
X509_check_email
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.68 and before; requires at least OpenSSL 1.0.2.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Checks if the certificate matches the specified email address.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_check_email($cert, $address, $flags);
|
|
# $cert - value corresponding to openssl's X509 structure
|
|
# $address - email address to check
|
|
# $flags (optional, default: 0) - see X509_check_host()
|
|
#
|
|
# returns: see X509_check_host()
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/crypto/X509_check_email.html">https://www.openssl.org/docs/crypto/X509_check_email.html</A>>.
|
|
<DT id="391">•<DD>
|
|
X509_check_ip
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.68 and before; requires at least OpenSSL 1.0.2.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Checks if the certificate matches the specified IPv4 or IPv6 address.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_check_email($cert, $address, $flags);
|
|
# $cert - value corresponding to openssl's X509 structure
|
|
# $address - IP address to check in binary format, in network byte order
|
|
# $flags (optional, default: 0) - see X509_check_host()
|
|
#
|
|
# returns: see X509_check_host()
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/crypto/X509_check_ip.html">https://www.openssl.org/docs/crypto/X509_check_ip.html</A>>.
|
|
<DT id="392">•<DD>
|
|
X509_check_ip_asc
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.68 and before; requires at least OpenSSL 1.0.2.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Checks if the certificate matches the specified IPv4 or IPv6 address.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_check_email($cert, $address, $flags);
|
|
# $cert - value corresponding to openssl's X509 structure
|
|
# $address - IP address to check in text representation
|
|
# $flags (optional, default: 0) - see X509_check_host()
|
|
#
|
|
# returns: see X509_check_host()
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/crypto/X509_check_ip_asc.html">https://www.openssl.org/docs/crypto/X509_check_ip_asc.html</A>>.
|
|
<DT id="393">•<DD>
|
|
X509_certificate_type
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns bitmask with type of certificate <TT>$x</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_certificate_type($x);
|
|
# $x - value corresponding to openssl's X509 structure
|
|
#
|
|
# returns: (integer) bitmask with certificate type
|
|
|
|
#to decode bitmask returned by this function use these constants:
|
|
&Net::SSLeay::EVP_PKS_DSA
|
|
&Net::SSLeay::EVP_PKS_EC
|
|
&Net::SSLeay::EVP_PKS_RSA
|
|
&Net::SSLeay::EVP_PKT_ENC
|
|
&Net::SSLeay::EVP_PKT_EXCH
|
|
&Net::SSLeay::EVP_PKT_EXP
|
|
&Net::SSLeay::EVP_PKT_SIGN
|
|
&Net::SSLeay::EVP_PK_DH
|
|
&Net::SSLeay::EVP_PK_DSA
|
|
&Net::SSLeay::EVP_PK_EC
|
|
&Net::SSLeay::EVP_PK_RSA
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="394">•<DD>
|
|
X509_digest
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Computes digest/fingerprint of X509 <TT>$data</TT> using <TT>$type</TT> hash function.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $digest_value = Net::SSLeay::X509_digest($data, $type);
|
|
# $data - value corresponding to openssl's X509 structure
|
|
# $type - value corresponding to openssl's EVP_MD structure - e.g. got via EVP_get_digestbyname()
|
|
#
|
|
# returns: hash value (binary)
|
|
|
|
#to get printable (hex) value of digest use:
|
|
print unpack('H*', $digest_value);
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="395">•<DD>
|
|
X509_issuer_and_serial_hash
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sort of a checksum of issuer name and serial number of X509 certificate <TT>$x</TT>.
|
|
The result is not a full hash (e.g. sha-1), it is kind-of-a-hash truncated to the size of 'unsigned long' (32 bits).
|
|
The resulting value might differ across different openssl versions for the same X509 certificate.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_issuer_and_serial_hash($x);
|
|
# $x - value corresponding to openssl's X509 structure
|
|
#
|
|
# returns: number representing checksum
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="396">•<DD>
|
|
X509_issuer_name_hash
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sort of a checksum of issuer name of X509 certificate <TT>$x</TT>.
|
|
The result is not a full hash (e.g. sha-1), it is kind-of-a-hash truncated to the size of 'unsigned long' (32 bits).
|
|
The resulting value might differ across different openssl versions for the same X509 certificate.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_issuer_name_hash($x);
|
|
# $x - value corresponding to openssl's X509 structure
|
|
#
|
|
# returns: number representing checksum
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="397">•<DD>
|
|
X509_subject_name_hash
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sort of a checksum of subject name of X509 certificate <TT>$x</TT>.
|
|
The result is not a full hash (e.g. sha-1), it is kind-of-a-hash truncated to the size of 'unsigned long' (32 bits).
|
|
The resulting value might differ across different openssl versions for the same X509 certificate.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_subject_name_hash($x);
|
|
# $x - value corresponding to openssl's X509 structure
|
|
#
|
|
# returns: number representing checksum
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="398">•<DD>
|
|
X509_pubkey_digest
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before; requires at least openssl-0.9.7
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Computes digest/fingerprint of public key from X509 certificate <TT>$data</TT> using <TT>$type</TT> hash function.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $digest_value = Net::SSLeay::X509_pubkey_digest($data, $type);
|
|
# $data - value corresponding to openssl's X509 structure
|
|
# $type - value corresponding to openssl's EVP_MD structure - e.g. got via EVP_get_digestbyname()
|
|
#
|
|
# returns: hash value (binary)
|
|
|
|
#to get printable (hex) value of digest use:
|
|
print unpack('H*', $digest_value);
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="399">•<DD>
|
|
X509_set_issuer_name
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets issuer of X509 certificate <TT>$x</TT> to <TT>$name</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_set_issuer_name($x, $name);
|
|
# $x - value corresponding to openssl's X509 structure
|
|
# $name - value corresponding to openssl's X509_NAME structure
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="400">•<DD>
|
|
X509_set_pubkey
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets public key of X509 certificate <TT>$x</TT> to <TT>$pkey</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_set_pubkey($x, $pkey);
|
|
# $x - value corresponding to openssl's X509 structure
|
|
# $pkey - value corresponding to openssl's EVP_PKEY structure
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="401">•<DD>
|
|
X509_set_serialNumber
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets serial number of X509 certificate <TT>$x</TT> to <TT>$serial</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_set_serialNumber($x, $serial);
|
|
# $x - value corresponding to openssl's X509 structure
|
|
# $serial - value corresponding to openssl's ASN1_INTEGER structure
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
#to create $serial value use one of these:
|
|
$serial = Net::SSLeay::P_ASN1_INTEGER_set_hex('45ad6f');
|
|
$serial = Net::SSLeay::P_ASN1_INTEGER_set_dec('7896541238529631478');
|
|
$serial = Net::SSLeay::ASN1_INTEGER_set(45896);
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="402">•<DD>
|
|
X509_set_subject_name
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets subject of X509 certificate <TT>$x</TT> to <TT>$name</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_set_subject_name($x, $name);
|
|
# $x - value corresponding to openssl's X509 structure
|
|
# $name - value corresponding to openssl's X509_NAME structure
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="403">•<DD>
|
|
X509_set_version
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Set 'version' value for X509 certificate $ to <TT>$version</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_set_version($x, $version);
|
|
# $x - value corresponding to openssl's X509 structure
|
|
# $version - (integer) version number
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="404">•<DD>
|
|
X509_sign
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sign X509 certificate <TT>$x</TT> with private key <TT>$pkey</TT> (using digest algorithm <TT>$md</TT>).
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_sign($x, $pkey, $md);
|
|
# $x - value corresponding to openssl's X509 structure
|
|
# $pkey - value corresponding to openssl's EVP_PKEY structure
|
|
# $md - value corresponding to openssl's EVP_MD structure
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="405">•<DD>
|
|
X509_verify
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Verifies X509 object <TT>$a</TT> using public key <TT>$r</TT> (pubkey of issuing <FONT SIZE="-1">CA</FONT>).
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_verify($x, $r);
|
|
# $x - value corresponding to openssl's X509 structure
|
|
# $r - value corresponding to openssl's EVP_PKEY structure
|
|
#
|
|
# returns: 0 - verify failure, 1 - verify OK, <0 - error
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="406">•<DD>
|
|
X509_get_ext_count
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the total number of extensions in X509 object <TT>$x</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_get_ext_count($x);
|
|
# $x - value corresponding to openssl's X509 structure
|
|
#
|
|
# returns: count of extensions
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="407">•<DD>
|
|
X509_get_pubkey
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns public key corresponding to given X509 object <TT>$x</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_get_pubkey($x);
|
|
# $x - value corresponding to openssl's X509 structure
|
|
#
|
|
# returns: value corresponding to openssl's EVP_PKEY structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>NOTE:</B></FONT><B></B> This method returns only the public key's key bits, without the
|
|
algorithm or parameters. Use <TT>"X509_get_X509_PUBKEY()"</TT> to return the full
|
|
public key (<FONT SIZE="-1">SPKI</FONT>) instead.
|
|
<DT id="408">•<DD>
|
|
X509_get_X509_PUBKEY
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.72 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the full public key (<FONT SIZE="-1">SPKI</FONT>) of given X509 certificate <TT>$x</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::X509_get_X509_PUBKEY($x);
|
|
# $x - value corresponding to openssl's X509 structure
|
|
#
|
|
# returns: public key data in DER format (binary)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="409">•<DD>
|
|
X509_get_serialNumber
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns serial number of X509 certificate <TT>$x</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_get_serialNumber($x);
|
|
# $x - value corresponding to openssl's X509 structure
|
|
#
|
|
# returns: value corresponding to openssl's ASN1_INTEGER structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
See ``P_ASN1_INTEGER_get_dec'', ``P_ASN1_INTEGER_get_hex'' or ``ASN1_INTEGER_get'' to decode <FONT SIZE="-1">ASN1_INTEGER</FONT> object.
|
|
<DT id="410">•<DD>
|
|
X509_get0_serialNumber
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> available in Net-SSLeay-1.86 onwards
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B>X509_get0_serialNumber()</B> is the same as <B>X509_get_serialNumber()</B> except it accepts a const parameter and returns a const result.
|
|
<DT id="411">•<DD>
|
|
X509_get_version
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns 'version' value of given X509 certificate <TT>$x</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_get_version($x);
|
|
# $x - value corresponding to openssl's X509 structure
|
|
#
|
|
# returns: (integer) version
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="412">•<DD>
|
|
X509_get_ext
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns X509_EXTENSION from <TT>$x509</TT> based on given position/index.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_get_ext($x509, $index);
|
|
# $x509 - value corresponding to openssl's X509 structure
|
|
# $index - (integer) position/index of extension within $x509
|
|
#
|
|
# returns: value corresponding to openssl's X509_EXTENSION structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="413">•<DD>
|
|
X509_get_ext_by_NID
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns X509_EXTENSION from <TT>$x509</TT> based on given <FONT SIZE="-1">NID.</FONT>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_get_ext_by_NID($x509, $nid, $loc);
|
|
# $x509 - value corresponding to openssl's X509 structure
|
|
# $nid - (integer) NID value
|
|
# $loc - (integer) position to start lookup at
|
|
#
|
|
# returns: position/index of extension, negative value on error
|
|
# call Net::SSLeay::X509_get_ext($x509, $rv) to get the actual extension
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="414">•<DD>
|
|
X509_get_fingerprint
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns fingerprint of certificate <TT>$cert</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>NOTE:</B></FONT><B></B> Does not exactly correspond to any low level <FONT SIZE="-1">API</FONT> function. The implementation
|
|
is basen on openssl's <TT>"X509_digest()"</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::X509_get_fingerprint($x509, $type);
|
|
# $x509 - value corresponding to openssl's X509 structure
|
|
# $type - (string) digest type, currently supported values:
|
|
# "md5"
|
|
# "sha1"
|
|
# "sha256"
|
|
# "ripemd160"
|
|
#
|
|
# returns: certificate digest - hexadecimal string (NOT binary data!)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="415">•<DD>
|
|
X509_get_issuer_name
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Return an X509_NAME object representing the issuer of the certificate <TT>$cert</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_get_issuer_name($cert);
|
|
# $cert - value corresponding to openssl's X509 structure
|
|
#
|
|
# returns: value corresponding to openssl's X509_NAME structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="416">•<DD>
|
|
X509_get_notAfter
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Return an object giving the time after which the certificate <TT>$cert</TT> is not valid.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_get_notAfter($cert);
|
|
# $cert - value corresponding to openssl's X509 structure
|
|
#
|
|
# returns: value corresponding to openssl's ASN1_TIME structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
To get human readable/printable form the return value you can use:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $time = Net::SSLeay::X509_get_notAfter($cert);
|
|
print "notAfter=", Net::SSLeay::P_ASN1_TIME_get_isotime($time), "\n";
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="417">•<DD>
|
|
X509_get_notBefore
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Return an object giving the time before which the certificate <TT>$cert</TT> is not valid
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_get_notBefore($cert);
|
|
# $cert - value corresponding to openssl's X509 structure
|
|
#
|
|
# returns: value corresponding to openssl's ASN1_TIME structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
To get human readable/printable form the return value you can use:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $time = Net::SSLeay::X509_get_notBefore($cert);
|
|
print "notBefore=", Net::SSLeay::P_ASN1_TIME_get_isotime($time), "\n";
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="418">•<DD>
|
|
X509_get_subjectAltNames
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>NOTE:</B></FONT><B></B> Does not exactly correspond to any low level <FONT SIZE="-1">API</FONT> function.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the list of alternative subject names from X509 certificate <TT>$cert</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my @rv = Net::SSLeay::X509_get_subjectAltNames($cert);
|
|
# $cert - value corresponding to openssl's X509 structure
|
|
#
|
|
# returns: list containing pairs - name_type (integer), name_value (string)
|
|
# where name_type can be:
|
|
# 0 - GEN_OTHERNAME
|
|
# 1 - GEN_EMAIL
|
|
# 2 - GEN_DNS
|
|
# 3 - GEN_X400
|
|
# 4 - GEN_DIRNAME
|
|
# 5 - GEN_EDIPARTY
|
|
# 6 - GEN_URI
|
|
# 7 - GEN_IPADD
|
|
# 8 - GEN_RID
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Note: type 7 - <FONT SIZE="-1">GEN_IPADD</FONT> contains the <FONT SIZE="-1">IP</FONT> address as a packed binary address.
|
|
<DT id="419">•<DD>
|
|
X509_get_subject_name
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the subject of the certificate <TT>$cert</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_get_subject_name($cert);
|
|
# $cert - value corresponding to openssl's X509 structure
|
|
#
|
|
# returns: value corresponding to openssl's X509_NAME structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="420">•<DD>
|
|
X509_gmtime_adj
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Adjust th <FONT SIZE="-1">ASN1_TIME</FONT> object to the timestamp (in <FONT SIZE="-1">GMT</FONT>).
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_gmtime_adj($s, $adj);
|
|
# $s - value corresponding to openssl's ASN1_TIME structure
|
|
# $adj - timestamp (seconds since 1.1.1970)
|
|
#
|
|
# returns: value corresponding to openssl's ASN1_TIME structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>BEWARE:</B></FONT><B></B> this function may fail for dates after 2038 as it is dependent on time_t size on your
|
|
system (32bit time_t does not work after 2038). Consider using ``P_ASN1_TIME_set_isotime'' instead).
|
|
<DT id="421">•<DD>
|
|
X509_load_cert_crl_file
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Takes <FONT SIZE="-1">PEM</FONT> file and loads all X509 certificates and X509 CRLs from that file into X509_LOOKUP structure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_load_cert_crl_file($ctx, $file, $type);
|
|
# $ctx - value corresponding to openssl's X509_LOOKUP structure
|
|
# $file - (string) file name
|
|
# $type - (integer) type - use constants &Net::SSLeay::FILETYPE_PEM or &Net::SSLeay::FILETYPE_ASN1
|
|
# if not FILETYPE_PEM then behaves as Net::SSLeay::X509_load_cert_file()
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="422">•<DD>
|
|
X509_load_cert_file
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Loads/adds X509 certificate from <TT>$file</TT> to X509_LOOKUP structure
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_load_cert_file($ctx, $file, $type);
|
|
# $ctx - value corresponding to openssl's X509_LOOKUP structure
|
|
# $file - (string) file name
|
|
# $type - (integer) type - use constants &Net::SSLeay::FILETYPE_PEM or &Net::SSLeay::FILETYPE_ASN1
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="423">•<DD>
|
|
X509_load_crl_file
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Loads/adds X509 <FONT SIZE="-1">CRL</FONT> from <TT>$file</TT> to X509_LOOKUP structure
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_load_crl_file($ctx, $file, $type);
|
|
# $ctx - value corresponding to openssl's X509_LOOKUP structure
|
|
# $file - (string) file name
|
|
# $type - (integer) type - use constants &Net::SSLeay::FILETYPE_PEM or &Net::SSLeay::FILETYPE_ASN1
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="424">•<DD>
|
|
X509_policy_level_get0_node
|
|
|
|
|
|
<P>
|
|
|
|
|
|
??? (more info needed)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_policy_level_get0_node($level, $i);
|
|
# $level - value corresponding to openssl's X509_POLICY_LEVEL structure
|
|
# $i - (integer) index/position
|
|
#
|
|
# returns: value corresponding to openssl's X509_POLICY_NODE structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="425">•<DD>
|
|
X509_policy_level_node_count
|
|
|
|
|
|
<P>
|
|
|
|
|
|
??? (more info needed)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_policy_level_node_count($level);
|
|
# $level - value corresponding to openssl's X509_POLICY_LEVEL structure
|
|
#
|
|
# returns: (integer) node count
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="426">•<DD>
|
|
X509_policy_node_get0_parent
|
|
|
|
|
|
<P>
|
|
|
|
|
|
??? (more info needed)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_policy_node_get0_parent($node);
|
|
# $node - value corresponding to openssl's X509_POLICY_NODE structure
|
|
#
|
|
# returns: value corresponding to openssl's X509_POLICY_NODE structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="427">•<DD>
|
|
X509_policy_node_get0_policy
|
|
|
|
|
|
<P>
|
|
|
|
|
|
??? (more info needed)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_policy_node_get0_policy($node);
|
|
# $node - value corresponding to openssl's X509_POLICY_NODE structure
|
|
#
|
|
# returns: value corresponding to openssl's ASN1_OBJECT structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="428">•<DD>
|
|
X509_policy_node_get0_qualifiers
|
|
|
|
|
|
<P>
|
|
|
|
|
|
??? (more info needed)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_policy_node_get0_qualifiers($node);
|
|
# $node - value corresponding to openssl's X509_POLICY_NODE structure
|
|
#
|
|
# returns: value corresponding to openssl's STACK_OF(POLICYQUALINFO) structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="429">•<DD>
|
|
X509_policy_tree_free
|
|
|
|
|
|
<P>
|
|
|
|
|
|
??? (more info needed)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::X509_policy_tree_free($tree);
|
|
# $tree - value corresponding to openssl's X509_POLICY_TREE structure
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="430">•<DD>
|
|
X509_policy_tree_get0_level
|
|
|
|
|
|
<P>
|
|
|
|
|
|
??? (more info needed)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_policy_tree_get0_level($tree, $i);
|
|
# $tree - value corresponding to openssl's X509_POLICY_TREE structure
|
|
# $i - (integer) level index
|
|
#
|
|
# returns: value corresponding to openssl's X509_POLICY_LEVEL structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="431">•<DD>
|
|
X509_policy_tree_get0_policies
|
|
|
|
|
|
<P>
|
|
|
|
|
|
??? (more info needed)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_policy_tree_get0_policies($tree);
|
|
# $tree - value corresponding to openssl's X509_POLICY_TREE structure
|
|
#
|
|
# returns: value corresponding to openssl's X509_POLICY_NODE structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="432">•<DD>
|
|
X509_policy_tree_get0_user_policies
|
|
|
|
|
|
<P>
|
|
|
|
|
|
??? (more info needed)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_policy_tree_get0_user_policies($tree);
|
|
# $tree - value corresponding to openssl's X509_POLICY_TREE structure
|
|
#
|
|
# returns: value corresponding to openssl's X509_POLICY_NODE structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="433">•<DD>
|
|
X509_policy_tree_level_count
|
|
|
|
|
|
<P>
|
|
|
|
|
|
??? (more info needed)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_policy_tree_level_count($tree);
|
|
# $tree - value corresponding to openssl's X509_POLICY_TREE structure
|
|
#
|
|
# returns: (integer) count
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="434">•<DD>
|
|
X509_verify_cert_error_string
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns a human readable error string for verification error <TT>$n</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_verify_cert_error_string($n);
|
|
# $n - (long) numeric error code
|
|
#
|
|
# returns: error string
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/X509_STORE_CTX_get_error.html">http://www.openssl.org/docs/crypto/X509_STORE_CTX_get_error.html</A>>
|
|
<DT id="435">•<DD>
|
|
P_X509_add_extensions
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Adds one or more X509 extensions to X509 object <TT>$x</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::P_X509_add_extensions($x, $ca_cert, $nid, $value);
|
|
# $x - value corresponding to openssl's X509 structure
|
|
# $ca_cert - value corresponding to openssl's X509 structure (issuer's cert - necessary for sertting NID_authority_key_identifier)
|
|
# $nid - NID identifying extension to be set
|
|
# $value - extension value
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
You can set more extensions at once:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::P_X509_add_extensions($x509, $ca_cert,
|
|
&Net::SSLeay::NID_key_usage => 'digitalSignature,keyEncipherment',
|
|
&Net::SSLeay::NID_subject_key_identifier => 'hash',
|
|
&Net::SSLeay::NID_authority_key_identifier => 'keyid',
|
|
&Net::SSLeay::NID_authority_key_identifier => 'issuer',
|
|
&Net::SSLeay::NID_basic_constraints => 'CA:FALSE',
|
|
&Net::SSLeay::NID_ext_key_usage => 'serverAuth,clientAuth',
|
|
&Net::SSLeay::NID_netscape_cert_type => 'server',
|
|
&Net::SSLeay::NID_subject_alt_name => 'DNS:s1.dom.com,DNS:s2.dom.com,DNS:s3.dom.com',
|
|
);
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="436">•<DD>
|
|
P_X509_copy_extensions
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Copies X509 extensions from X509_REQ object to X509 object - handy when you need to turn X509_REQ into X509 certificate.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::P_X509_copy_extensions($x509_req, $x509, $override);
|
|
# $x509_req - value corresponding to openssl's X509_REQ structure
|
|
# $x509 - value corresponding to openssl's X509 structure
|
|
# $override - (integer) flag indication whether to override already existing items in $x509 (default 1)
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="437">•<DD>
|
|
P_X509_get_crl_distribution_points
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before; requires at least openssl-0.9.7
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Get the list of <FONT SIZE="-1">CRL</FONT> distribution points from X509 certificate.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my @cdp = Net::SSLeay::P_X509_get_crl_distribution_points($x509);
|
|
# $x509 - value corresponding to openssl's X509 structure
|
|
#
|
|
# returns: list of distribution points (usually URLs)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="438">•<DD>
|
|
P_X509_get_ext_key_usage
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before; requires at least openssl-0.9.7
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Gets the list of extended key usage of given X509 certificate <TT>$cert</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my @ext_usage = Net::SSLeay::P_X509_get_ext_key_usage($cert, $format);
|
|
# $cert - value corresponding to openssl's X509 structure
|
|
# $format - choose type of return values: 0=OIDs, 1=NIDs, 2=shortnames, 3=longnames
|
|
#
|
|
# returns: list of values
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Examples:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my @extkeyusage_oid = Net::SSLeay::P_X509_get_ext_key_usage($x509,0);
|
|
# returns for example: ("1.3.6.1.5.5.7.3.1", "1.3.6.1.5.5.7.3.2")
|
|
|
|
my @extkeyusage_nid = Net::SSLeay::P_X509_get_ext_key_usage($x509,1);
|
|
# returns for example: (129, 130)
|
|
|
|
my @extkeyusage_sn = Net::SSLeay::P_X509_get_ext_key_usage($x509,2);
|
|
# returns for example: ("serverAuth", "clientAuth")
|
|
|
|
my @extkeyusage_ln = Net::SSLeay::P_X509_get_ext_key_usage($x509,3);
|
|
# returns for example: ("TLS Web Server Authentication", "TLS Web Client Authentication")
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="439">•<DD>
|
|
P_X509_get_key_usage
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Gets the list of key usage of given X509 certificate <TT>$cert</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my @keyusage = Net::SSLeay::P_X509_get_key_usage($cert);
|
|
# $cert - value corresponding to openssl's X509 structure
|
|
#
|
|
# returns: list of key usage values which can be none, one or more from the following list:
|
|
# "digitalSignature"
|
|
# "nonRepudiation"
|
|
# "keyEncipherment"
|
|
# "dataEncipherment"
|
|
# "keyAgreement"
|
|
# "keyCertSign"
|
|
# "cRLSign"
|
|
# "encipherOnly"
|
|
# "decipherOnly"
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="440">•<DD>
|
|
P_X509_get_netscape_cert_type
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Gets the list of Netscape cert types of given X509 certificate <TT>$cert</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::P_X509_get_netscape_cert_type($cert);
|
|
# $cert - value corresponding to openssl's X509 structure
|
|
#
|
|
# returns: list of Netscape type values which can be none, one or more from the following list:
|
|
# "client"
|
|
# "server"
|
|
# "email"
|
|
# "objsign"
|
|
# "reserved"
|
|
# "sslCA"
|
|
# "emailCA"
|
|
# "objCA"
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="441">•<DD>
|
|
P_X509_get_pubkey_alg
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns <FONT SIZE="-1">ASN1_OBJECT</FONT> corresponding to X509 certificate public key algorithm.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::P_X509_get_pubkey_alg($x);
|
|
# $x - value corresponding to openssl's X509 structure
|
|
#
|
|
# returns: value corresponding to openssl's ASN1_OBJECT structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
To get textual representation use:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $alg = Net::SSLeay::OBJ_obj2txt(Net::SSLeay::P_X509_get_pubkey_alg($x509));
|
|
# returns for example: "rsaEncryption"
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="442">•<DD>
|
|
P_X509_get_signature_alg
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns <FONT SIZE="-1">ASN1_OBJECT</FONT> corresponding to X509 signarite key algorithm.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::P_X509_get_signature_alg($x);
|
|
# $x - value corresponding to openssl's X509 structure
|
|
#
|
|
# returns: value corresponding to openssl's ASN1_OBJECT structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
To get textual representation use:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $alg = Net::SSLeay::OBJ_obj2txt(Net::SSLeay::P_X509_get_signature_alg($x509))
|
|
# returns for example: "sha1WithRSAEncryption"
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="443">•<DD>
|
|
sk_X509_new_null
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns a new, empty, <FONT SIZE="-1">STACK_OF</FONT>(X509) structure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::sk_X509_new_null();
|
|
#
|
|
# returns: value corresponding to openssl's STACK_OF(X509) structure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="444">•<DD>
|
|
sk_X509_push
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Pushes an X509 structure onto a <FONT SIZE="-1">STACK_OF</FONT>(X509) structure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::sk_X509_push($sk_x509, $x509);
|
|
# $sk_x509 - value corresponding to openssl's STACK_OF(X509) structure
|
|
# $x509 - value corresponding to openssl's X509 structure
|
|
#
|
|
# returns: 1 if successful, 0 if unsuccessful
|
|
|
|
</PRE>
|
|
|
|
|
|
</DL>
|
|
<P>
|
|
|
|
<I>Low level </I><FONT SIZE="-1"><I>API:</I></FONT><I> X509_REQ_* related functions</I>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="445">•<DD>
|
|
X509_REQ_new
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Creates a new X509_REQ structure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_REQ_new();
|
|
#
|
|
# returns: value corresponding to openssl's X509_REQ structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="446">•<DD>
|
|
X509_REQ_free
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Free an allocated X509_REQ structure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::X509_REQ_free($x);
|
|
# $x - value corresponding to openssl's X509_REQ structure
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="447">•<DD>
|
|
X509_REQ_add1_attr_by_NID
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Adds an attribute whose name is defined by a <FONT SIZE="-1">NID</FONT> <TT>$nid</TT>. The field value to be added is in <TT>$bytes</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_REQ_add1_attr_by_NID($req, $nid, $type, $bytes);
|
|
# $req - value corresponding to openssl's X509_REQ structure
|
|
# $nid - (integer) NID value
|
|
# $type - (integer) type of data in $bytes (see below)
|
|
# $bytes - data to be set
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
# values for $type - use constants:
|
|
&Net::SSLeay::MBSTRING_UTF8 - $bytes contains utf8 encoded data
|
|
&Net::SSLeay::MBSTRING_ASC - $bytes contains ASCII data
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="448">•<DD>
|
|
X509_REQ_digest
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Computes digest/fingerprint of X509_REQ <TT>$data</TT> using <TT>$type</TT> hash function.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $digest_value = Net::SSLeay::X509_REQ_digest($data, $type);
|
|
# $data - value corresponding to openssl's X509_REQ structure
|
|
# $type - value corresponding to openssl's EVP_MD structure - e.g. got via EVP_get_digestbyname()
|
|
#
|
|
# returns: hash value (binary)
|
|
|
|
#to get printable (hex) value of digest use:
|
|
print unpack('H*', $digest_value);
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="449">•<DD>
|
|
X509_REQ_get_attr_by_NID
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Retrieve the next index matching <TT>$nid</TT> after <TT>$lastpos</TT> ($lastpos should initially be set to -1).
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_REQ_get_attr_by_NID($req, $nid, $lastpos=-1);
|
|
# $req - value corresponding to openssl's X509_REQ structure
|
|
# $nid - (integer) NID value
|
|
# $lastpos - [optional] (integer) index where to start search (default -1)
|
|
#
|
|
# returns: index (-1 if there are no more entries)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Note: use ``P_X509_REQ_get_attr'' to get the actual attribute value - e.g.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $index = Net::SSLeay::X509_REQ_get_attr_by_NID($req, $nid);
|
|
my @attr_values = Net::SSLeay::P_X509_REQ_get_attr($req, $index);
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="450">•<DD>
|
|
X509_REQ_get_attr_by_OBJ
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Retrieve the next index matching <TT>$obj</TT> after <TT>$lastpos</TT> ($lastpos should initially be set to -1).
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_REQ_get_attr_by_OBJ($req, $obj, $lastpos=-1);
|
|
# $req - value corresponding to openssl's X509_REQ structure
|
|
# $obj - value corresponding to openssl's ASN1_OBJECT structure
|
|
# $lastpos - [optional] (integer) index where to start search (default -1)
|
|
#
|
|
# returns: index (-1 if there are no more entries)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Note: use ``P_X509_REQ_get_attr'' to get the actual attribute value - e.g.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $index = Net::SSLeay::X509_REQ_get_attr_by_NID($req, $nid);
|
|
my @attr_values = Net::SSLeay::P_X509_REQ_get_attr($req, $index);
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="451">•<DD>
|
|
X509_REQ_get_attr_count
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the total number of attributes in <TT>$req</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_REQ_get_attr_count($req);
|
|
# $req - value corresponding to openssl's X509_REQ structure
|
|
#
|
|
# returns: (integer) items count
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="452">•<DD>
|
|
X509_REQ_get_pubkey
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns public key corresponding to given X509_REQ object <TT>$x</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_REQ_get_pubkey($x);
|
|
# $x - value corresponding to openssl's X509_REQ structure
|
|
#
|
|
# returns: value corresponding to openssl's EVP_PKEY structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="453">•<DD>
|
|
X509_REQ_get_subject_name
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns X509_NAME object corresponding to subject name of given X509_REQ object <TT>$x</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_REQ_get_subject_name($x);
|
|
# $x - value corresponding to openssl's X509_REQ structure
|
|
#
|
|
# returns: value corresponding to openssl's X509_NAME structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="454">•<DD>
|
|
X509_REQ_get_version
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns 'version' value for given X509_REQ object <TT>$x</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_REQ_get_version($x);
|
|
# $x - value corresponding to openssl's X509_REQ structure
|
|
#
|
|
# returns: (integer) version e.g. 0 = "version 1"
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="455">•<DD>
|
|
X509_REQ_set_pubkey
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets public key of given X509_REQ object <TT>$x</TT> to <TT>$pkey</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_REQ_set_pubkey($x, $pkey);
|
|
# $x - value corresponding to openssl's X509_REQ structure
|
|
# $pkey - value corresponding to openssl's EVP_PKEY structure
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="456">•<DD>
|
|
X509_REQ_set_subject_name
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets subject name of given X509_REQ object <TT>$x</TT> to X509_NAME object <TT>$name</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_REQ_set_subject_name($x, $name);
|
|
# $x - value corresponding to openssl's X509_REQ structure
|
|
# $name - value corresponding to openssl's X509_NAME structure
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="457">•<DD>
|
|
X509_REQ_set_version
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets 'version' of given X509_REQ object <TT>$x</TT> to <TT>$version</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_REQ_set_version($x, $version);
|
|
# $x - value corresponding to openssl's X509_REQ structure
|
|
# $version - (integer) e.g. 0 = "version 1"
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="458">•<DD>
|
|
X509_REQ_sign
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sign X509_REQ object <TT>$x</TT> with private key <TT>$pk</TT> (using digest algorithm <TT>$md</TT>).
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_REQ_sign($x, $pk, $md);
|
|
# $x - value corresponding to openssl's X509_REQ structure
|
|
# $pk - value corresponding to openssl's EVP_PKEY structure (requestor's private key)
|
|
# $md - value corresponding to openssl's EVP_MD structure
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="459">•<DD>
|
|
X509_REQ_verify
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Verifies X509_REQ object <TT>$x</TT> using public key <TT>$r</TT> (pubkey of requesting party).
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_REQ_verify($x, $r);
|
|
# $x - value corresponding to openssl's X509_REQ structure
|
|
# $r - value corresponding to openssl's EVP_PKEY structure
|
|
#
|
|
# returns: 0 - verify failure, 1 - verify OK, <0 - error
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="460">•<DD>
|
|
P_X509_REQ_add_extensions
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Adds one or more X509 extensions to X509_REQ object <TT>$x</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::P_X509_REQ_add_extensions($x, $nid, $value);
|
|
# $x - value corresponding to openssl's X509_REQ structure
|
|
# $nid - NID identifying extension to be set
|
|
# $value - extension value
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
You can set more extensions at once:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::P_X509_REQ_add_extensions($x509_req,
|
|
&Net::SSLeay::NID_key_usage => 'digitalSignature,keyEncipherment',
|
|
&Net::SSLeay::NID_basic_constraints => 'CA:FALSE',
|
|
&Net::SSLeay::NID_ext_key_usage => 'serverAuth,clientAuth',
|
|
&Net::SSLeay::NID_netscape_cert_type => 'server',
|
|
&Net::SSLeay::NID_subject_alt_name => 'DNS:s1.com,DNS:s2.com',
|
|
&Net::SSLeay::NID_crl_distribution_points => 'URI:<A HREF="http://pki.com/crl1,URI:http://pki.com/crl2',">http://pki.com/crl1,URI:http://pki.com/crl2',</A>
|
|
);
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="461">•<DD>
|
|
P_X509_REQ_get_attr
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before; requires at least openssl-0.9.7
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns attribute value for X509_REQ's attribute at index <TT>$n</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::P_X509_REQ_get_attr($req, $n);
|
|
# $req - value corresponding to openssl's X509_REQ structure
|
|
# $n - (integer) attribute index
|
|
#
|
|
# returns: value corresponding to openssl's ASN1_STRING structure
|
|
|
|
</PRE>
|
|
|
|
|
|
</DL>
|
|
<P>
|
|
|
|
<I>Low level </I><FONT SIZE="-1"><I>API:</I></FONT><I> X509_CRL_* related functions</I>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="462">•<DD>
|
|
X509_CRL_new
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Creates a new X509_CRL structure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_CRL_new();
|
|
#
|
|
# returns: value corresponding to openssl's X509_CRL structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="463">•<DD>
|
|
X509_CRL_free
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Free an allocated X509_CRL structure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::X509_CRL_free($x);
|
|
# $x - value corresponding to openssl's X509_CRL structure
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="464">•<DD>
|
|
X509_CRL_digest
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Computes digest/fingerprint of X509_CRL <TT>$data</TT> using <TT>$type</TT> hash function.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $digest_value = Net::SSLeay::X509_CRL_digest($data, $type);
|
|
# $data - value corresponding to openssl's X509_CRL structure
|
|
# $type - value corresponding to openssl's EVP_MD structure - e.g. got via EVP_get_digestbyname()
|
|
#
|
|
# returns: hash value (binary)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Example:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $x509_crl
|
|
my $md = Net::SSLeay::EVP_get_digestbyname("sha1");
|
|
my $digest_value = Net::SSLeay::X509_CRL_digest($x509_crl, $md);
|
|
#to get printable (hex) value of digest use:
|
|
print "digest=", unpack('H*', $digest_value), "\n";
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="465">•<DD>
|
|
X509_CRL_get_ext
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.54 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns X509_EXTENSION from <TT>$x509</TT> based on given position/index.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_CRL_get_ext($x509, $index);
|
|
# $x509 - value corresponding to openssl's X509_CRL structure
|
|
# $index - (integer) position/index of extension within $x509
|
|
#
|
|
# returns: value corresponding to openssl's X509_EXTENSION structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="466">•<DD>
|
|
X509_CRL_get_ext_by_NID
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.54 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns X509_EXTENSION from <TT>$x509</TT> based on given <FONT SIZE="-1">NID.</FONT>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_CRL_get_ext_by_NID($x509, $nid, $loc);
|
|
# $x509 - value corresponding to openssl's X509_CRL structure
|
|
# $nid - (integer) NID value
|
|
# $loc - (integer) position to start lookup at
|
|
#
|
|
# returns: position/index of extension, negative value on error
|
|
# call Net::SSLeay::X509_CRL_get_ext($x509, $rv) to get the actual extension
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="467">•<DD>
|
|
X509_CRL_get_ext_count
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.54 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the total number of extensions in X509_CRL object <TT>$x</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_CRL_get_ext_count($x);
|
|
# $x - value corresponding to openssl's X509_CRL structure
|
|
#
|
|
# returns: count of extensions
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="468">•<DD>
|
|
X509_CRL_get_issuer
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns X509_NAME object corresponding to the issuer of X509_CRL <TT>$x</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_CRL_get_issuer($x);
|
|
# $x - value corresponding to openssl's X509_CRL structure
|
|
#
|
|
# returns: value corresponding to openssl's X509_NAME structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
See other <TT>"X509_NAME_*"</TT> functions to get more info from X509_NAME structure.
|
|
<DT id="469">•<DD>
|
|
X509_CRL_get_lastUpdate
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns 'lastUpdate' date-time value of X509_CRL object <TT>$x</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_CRL_get_lastUpdate($x);
|
|
# $x - value corresponding to openssl's X509_CRL structure
|
|
#
|
|
# returns: value corresponding to openssl's ASN1_TIME structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="470">•<DD>
|
|
X509_CRL_get_nextUpdate
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns 'nextUpdate' date-time value of X509_CRL object <TT>$x</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_CRL_get_nextUpdate($x);
|
|
# $x - value corresponding to openssl's X509_CRL structure
|
|
#
|
|
# returns: value corresponding to openssl's ASN1_TIME structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="471">•<DD>
|
|
X509_CRL_get_version
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns 'version' value of given X509_CRL structure <TT>$x</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_CRL_get_version($x);
|
|
# $x - value corresponding to openssl's X509_CRL structure
|
|
#
|
|
# returns: (integer) version
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="472">•<DD>
|
|
X509_CRL_set_issuer_name
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before; requires at least openssl-0.9.7
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the issuer of X509_CRL object <TT>$x</TT> to X509_NAME object <TT>$name</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_CRL_set_issuer_name($x, $name);
|
|
# $x - value corresponding to openssl's X509_CRL structure
|
|
# $name - value corresponding to openssl's X509_NAME structure
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="473">•<DD>
|
|
X509_CRL_set_lastUpdate
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before; requires at least openssl-0.9.7
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets 'lastUpdate' value of X509_CRL object <TT>$x</TT> to <TT>$tm</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_CRL_set_lastUpdate($x, $tm);
|
|
# $x - value corresponding to openssl's X509_CRL structure
|
|
# $tm - value corresponding to openssl's ASN1_TIME structure
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="474">•<DD>
|
|
X509_CRL_set_nextUpdate
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before; requires at least openssl-0.9.7
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets 'nextUpdate' value of X509_CRL object <TT>$x</TT> to <TT>$tm</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_CRL_set_nextUpdate($x, $tm);
|
|
# $x - value corresponding to openssl's X509_CRL structure
|
|
# $tm - value corresponding to openssl's ASN1_TIME structure
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="475">•<DD>
|
|
X509_CRL_set_version
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before; requires at least openssl-0.9.7
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets 'version' value of given X509_CRL structure <TT>$x</TT> to <TT>$version</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_CRL_set_version($x, $version);
|
|
# $x - value corresponding to openssl's X509_CRL structure
|
|
# $version - (integer) version number (1 = version 2 CRL)
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Note that if you want to use any X509_CRL extension you need to set ``version 2 <FONT SIZE="-1">CRL''</FONT> - <TT>"Net::SSLeay::X509_CRL_set_version($x, 1)"</TT>.
|
|
<DT id="476">•<DD>
|
|
X509_CRL_sign
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sign X509_CRL object <TT>$x</TT> with private key <TT>$pkey</TT> (using digest algorithm <TT>$md</TT>).
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_CRL_sign($x, $pkey, $md);
|
|
# $x - value corresponding to openssl's X509_CRL structure
|
|
# $pkey - value corresponding to openssl's EVP_PKEY structure
|
|
# $md - value corresponding to openssl's EVP_MD structure
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="477">•<DD>
|
|
X509_CRL_sort
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before; requires at least openssl-0.9.7
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sorts the data of X509_CRL object so it will be written in serial number order.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_CRL_sort($x);
|
|
# $x - value corresponding to openssl's X509_CRL structure
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="478">•<DD>
|
|
X509_CRL_verify
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Verifies X509_CRL object <TT>$a</TT> using public key <TT>$r</TT> (pubkey of issuing <FONT SIZE="-1">CA</FONT>).
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_CRL_verify($a, $r);
|
|
# $a - value corresponding to openssl's X509_CRL structure
|
|
# $r - value corresponding to openssl's EVP_PKEY structure
|
|
#
|
|
# returns: 0 - verify failure, 1 - verify OK, <0 - error
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="479">•<DD>
|
|
P_X509_CRL_add_revoked_serial_hex
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before; requires at least openssl-0.9.7
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Adds given serial number <TT>$serial_hex</TT> to X509_CRL object <TT>$crl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::P_X509_CRL_add_revoked_serial_hex($crl, $serial_hex, $rev_time, $reason_code, $comp_time);
|
|
# $crl - value corresponding to openssl's X509_CRL structure
|
|
# $serial_hex - string (hexadecimal) representation of serial number
|
|
# $rev_time - (revocation time) value corresponding to openssl's ASN1_TIME structure
|
|
# $reason_code - [optional] (integer) reason code (see below) - default 0
|
|
# $comp_time - [optional] (compromise time) value corresponding to openssl's ASN1_TIME structure
|
|
#
|
|
# returns: no return value
|
|
|
|
reason codes:
|
|
0 - unspecified
|
|
1 - keyCompromise
|
|
2 - CACompromise
|
|
3 - affiliationChanged
|
|
4 - superseded
|
|
5 - cessationOfOperation
|
|
6 - certificateHold
|
|
7 - removeFromCRL
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="480">•<DD>
|
|
P_X509_CRL_get_serial
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before; requires at least openssl-0.9.7
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns serial number of X509_CRL object.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::P_X509_CRL_get_serial($crl);
|
|
# $crl - value corresponding to openssl's X509_CRL structure
|
|
#
|
|
# returns: value corresponding to openssl's ASN1_INTEGER structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="481">•<DD>
|
|
P_X509_CRL_set_serial
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before; requires at least openssl-0.9.7
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets serial number of X509_CRL object to <TT>$crl_number</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::P_X509_CRL_set_serial($crl, $crl_number);
|
|
# $crl - value corresponding to openssl's X509_CRL structure
|
|
# $crl_number - value corresponding to openssl's ASN1_INTEGER structure
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
</DL>
|
|
<P>
|
|
|
|
<I>Low level </I><FONT SIZE="-1"><I>API:</I></FONT><I> X509_EXTENSION_* related functions</I>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="482">•<DD>
|
|
X509_EXTENSION_get_critical
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns 'critical' flag of given X509_EXTENSION object <TT>$ex</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_EXTENSION_get_critical($ex);
|
|
# $ex - value corresponding to openssl's X509_EXTENSION structure
|
|
#
|
|
# returns: (integer) 1 - critical, 0 - noncritical
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="483">•<DD>
|
|
X509_EXTENSION_get_data
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns value (raw data) of X509_EXTENSION object <TT>$ne</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_EXTENSION_get_data($ne);
|
|
# $ne - value corresponding to openssl's X509_EXTENSION structure
|
|
#
|
|
# returns: value corresponding to openssl's ASN1_OCTET_STRING structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Note: you can use ``P_ASN1_STRING_get'' to convert <FONT SIZE="-1">ASN1_OCTET_STRING</FONT> into perl scalar variable.
|
|
<DT id="484">•<DD>
|
|
X509_EXTENSION_get_object
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns <FONT SIZE="-1">OID</FONT> (<FONT SIZE="-1">ASN1_OBJECT</FONT>) of X509_EXTENSION object <TT>$ne</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_EXTENSION_get_object($ex);
|
|
# $ex - value corresponding to openssl's X509_EXTENSION structure
|
|
#
|
|
# returns: value corresponding to openssl's ASN1_OBJECT structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="485">•<DD>
|
|
X509V3_EXT_print
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns string representation of given X509_EXTENSION object <TT>$ext</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::X509V3_EXT_print($ext, $flags, $utf8_decode);
|
|
# $ext - value corresponding to openssl's X509_EXTENSION structure
|
|
# $flags - [optional] (integer) Currently the flag argument is unused and should be set to 0
|
|
# $utf8_decode - [optional] 0 or 1 whether the returned value should be utf8 decoded (default=0)
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="486">•<DD>
|
|
X509V3_EXT_d2i
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Parses an extension and returns its internal structure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509V3_EXT_d2i($ext);
|
|
# $ext - value corresponding to openssl's X509_EXTENSION structure
|
|
#
|
|
# returns: pointer ???
|
|
|
|
</PRE>
|
|
|
|
|
|
</DL>
|
|
<P>
|
|
|
|
<I>Low level </I><FONT SIZE="-1"><I>API:</I></FONT><I> X509_NAME_* related functions</I>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="487">•<DD>
|
|
X509_NAME_ENTRY_get_data
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Retrieves the field value of <TT>$ne</TT> in and <FONT SIZE="-1">ASN1_STRING</FONT> structure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_NAME_ENTRY_get_data($ne);
|
|
# $ne - value corresponding to openssl's X509_NAME_ENTRY structure
|
|
#
|
|
# returns: value corresponding to openssl's ASN1_STRING structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/X509_NAME_ENTRY_get_object.html">http://www.openssl.org/docs/crypto/X509_NAME_ENTRY_get_object.html</A>>
|
|
<DT id="488">•<DD>
|
|
X509_NAME_ENTRY_get_object
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Retrieves the field name of <TT>$ne</TT> in and <FONT SIZE="-1">ASN1_OBJECT</FONT> structure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_NAME_ENTRY_get_object($ne);
|
|
# $ne - value corresponding to openssl's X509_NAME_ENTRY structure
|
|
#
|
|
# returns: value corresponding to openssl's ASN1_OBJECT structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/X509_NAME_ENTRY_get_object.html">http://www.openssl.org/docs/crypto/X509_NAME_ENTRY_get_object.html</A>>
|
|
<DT id="489">•<DD>
|
|
X509_NAME_new
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.55 and before; requires at least openssl-0.9.5
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Creates a new X509_NAME structure.
|
|
Adds a field whose name is defined by a string <TT>$field</TT>. The field value to be added is in <TT>$bytes</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_NAME_new();
|
|
#
|
|
# returns: value corresponding to openssl's X509_NAME structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="490">•<DD>
|
|
X509_NAME_hash
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.55 and before; requires at least openssl-0.9.5
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sort of a checksum of issuer name <TT>$name</TT>.
|
|
The result is not a full hash (e.g. sha-1), it is kind-of-a-hash truncated to the size of 'unsigned long' (32 bits).
|
|
The resulting value might differ across different openssl versions for the same X509 certificate.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_NAME_hash($name);
|
|
# $name - value corresponding to openssl's X509_NAME structure
|
|
#
|
|
# returns: number representing checksum
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="491">•<DD>
|
|
X509_NAME_add_entry_by_txt
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before; requires at least openssl-0.9.5
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Adds a field whose name is defined by a string <TT>$field</TT>. The field value to be added is in <TT>$bytes</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_NAME_add_entry_by_txt($name, $field, $type, $bytes, $len, $loc, $set);
|
|
# $name - value corresponding to openssl's X509_NAME structure
|
|
# $field - (string) field definition (name) - e.g. "organizationName"
|
|
# $type - (integer) type of data in $bytes (see below)
|
|
# $bytes - data to be set
|
|
# $loc - [optional] (integer) index where the new entry is inserted: if it is -1 (default) it is appended
|
|
# $set - [optional] (integer) determines how the new type is added. If it is 0 (default) a new RDN is created
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
# values for $type - use constants:
|
|
&Net::SSLeay::MBSTRING_UTF8 - $bytes contains utf8 encoded data
|
|
&Net::SSLeay::MBSTRING_ASC - $bytes contains ASCII data
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Unicode note: when passing non-ascii (unicode) string in <TT>$bytes</TT> do not forget to set <TT>"$flags = &Net::SSLeay::MBSTRING_UTF8"</TT> and encode the perl <TT>$string</TT> via <TT>"$bytes = encode('utf-8', $string)"</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/X509_NAME_add_entry_by_txt.html">http://www.openssl.org/docs/crypto/X509_NAME_add_entry_by_txt.html</A>>
|
|
<DT id="492">•<DD>
|
|
X509_NAME_add_entry_by_NID
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before; requires at least openssl-0.9.5
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Adds a field whose name is defined by a <FONT SIZE="-1">NID</FONT> <TT>$nid</TT>. The field value to be added is in <TT>$bytes</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_NAME_add_entry_by_NID($name, $nid, $type, $bytes, $len, $loc, $set);
|
|
# $name - value corresponding to openssl's X509_NAME structure
|
|
# $nid - (integer) field definition - NID value
|
|
# $type - (integer) type of data in $bytes (see below)
|
|
# $bytes - data to be set
|
|
# $loc - [optional] (integer) index where the new entry is inserted: if it is -1 (default) it is appended
|
|
# $set - [optional] (integer) determines how the new type is added. If it is 0 (default) a new RDN is created
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/X509_NAME_add_entry_by_txt.html">http://www.openssl.org/docs/crypto/X509_NAME_add_entry_by_txt.html</A>>
|
|
<DT id="493">•<DD>
|
|
X509_NAME_add_entry_by_OBJ
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before; requires at least openssl-0.9.5
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Adds a field whose name is defined by a object (<FONT SIZE="-1">OID</FONT>) <TT>$obj</TT> . The field value to be added is in <TT>$bytes</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_NAME_add_entry_by_OBJ($name, $obj, $type, $bytes, $len, $loc, $set);
|
|
# $name - value corresponding to openssl's X509_NAME structure
|
|
# $obj - field definition - value corresponding to openssl's ASN1_OBJECT structure
|
|
# $type - (integer) type of data in $bytes (see below)
|
|
# $bytes - data to be set
|
|
# $loc - [optional] (integer) index where the new entry is inserted: if it is -1 (default) it is appended
|
|
# $set - [optional] (integer) determines how the new type is added. If it is 0 (default) a new RDN is created
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/X509_NAME_add_entry_by_txt.html">http://www.openssl.org/docs/crypto/X509_NAME_add_entry_by_txt.html</A>>
|
|
<DT id="494">•<DD>
|
|
X509_NAME_cmp
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Compares two X509_NAME obejcts.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_NAME_cmp($a, $b);
|
|
# $a - value corresponding to openssl's X509_NAME structure
|
|
# $b - value corresponding to openssl's X509_NAME structure
|
|
#
|
|
# returns: 0 if $a matches $b; non zero otherwise
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="495">•<DD>
|
|
X509_NAME_digest
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Computes digest/fingerprint of X509_NAME <TT>$data</TT> using <TT>$type</TT> hash function.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $digest_value = Net::SSLeay::X509_NAME_digest($data, $type);
|
|
# $data - value corresponding to openssl's X509_NAME structure
|
|
# $type - value corresponding to openssl's EVP_MD structure - e.g. got via EVP_get_digestbyname()
|
|
#
|
|
# returns: hash value (binary)
|
|
|
|
#to get printable (hex) value of digest use:
|
|
print unpack('H*', $digest_value);
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="496">•<DD>
|
|
X509_NAME_entry_count
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the total number of entries in <TT>$name</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_NAME_entry_count($name);
|
|
# $name - value corresponding to openssl's X509_NAME structure
|
|
#
|
|
# returns: (integer) entries count
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/X509_NAME_get_index_by_NID.html">http://www.openssl.org/docs/crypto/X509_NAME_get_index_by_NID.html</A>>
|
|
<DT id="497">•<DD>
|
|
X509_NAME_get_entry
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Retrieves the X509_NAME_ENTRY from <TT>$name</TT> corresponding to index <TT>$loc</TT>. Acceptable values for <TT>$loc</TT> run
|
|
from 0 to <TT>"Net::SSLeay::X509_NAME_entry_count($name)- 1"</TT>. The value returned is an internal pointer which must not be freed.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_NAME_get_entry($name, $loc);
|
|
# $name - value corresponding to openssl's X509_NAME structure
|
|
# $loc - (integer) index of wanted entry
|
|
#
|
|
# returns: value corresponding to openssl's X509_NAME_ENTRY structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/X509_NAME_get_index_by_NID.html">http://www.openssl.org/docs/crypto/X509_NAME_get_index_by_NID.html</A>>
|
|
<DT id="498">•<DD>
|
|
X509_NAME_print_ex
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns a string with human readable version of <TT>$name</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::X509_NAME_print_ex($name, $flags, $utf8_decode);
|
|
# $name - value corresponding to openssl's X509_NAME structure
|
|
# $flags - [optional] conversion flags (default XN_FLAG_RFC2253) - see below
|
|
# $utf8_decode - [optional] 0 or 1 whether the returned value should be utf8 decoded (default=0)
|
|
#
|
|
# returns: string representation of $name
|
|
|
|
#available conversion flags - use constants:
|
|
&Net::SSLeay::XN_FLAG_COMPAT
|
|
&Net::SSLeay::XN_FLAG_DN_REV
|
|
&Net::SSLeay::XN_FLAG_DUMP_UNKNOWN_FIELDS
|
|
&Net::SSLeay::XN_FLAG_FN_ALIGN
|
|
&Net::SSLeay::XN_FLAG_FN_LN
|
|
&Net::SSLeay::XN_FLAG_FN_MASK
|
|
&Net::SSLeay::XN_FLAG_FN_NONE
|
|
&Net::SSLeay::XN_FLAG_FN_OID
|
|
&Net::SSLeay::XN_FLAG_FN_SN
|
|
&Net::SSLeay::XN_FLAG_MULTILINE
|
|
&Net::SSLeay::XN_FLAG_ONELINE
|
|
&Net::SSLeay::XN_FLAG_RFC2253
|
|
&Net::SSLeay::XN_FLAG_SEP_COMMA_PLUS
|
|
&Net::SSLeay::XN_FLAG_SEP_CPLUS_SPC
|
|
&Net::SSLeay::XN_FLAG_SEP_MASK
|
|
&Net::SSLeay::XN_FLAG_SEP_MULTILINE
|
|
&Net::SSLeay::XN_FLAG_SEP_SPLUS_SPC
|
|
&Net::SSLeay::XN_FLAG_SPC_EQ
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Most likely you will be fine with default:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::X509_NAME_print_ex($name, &Net::SSLeay::XN_FLAG_RFC2253);
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Or you might want RFC2253-like output without utf8 chars escaping:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
use Net::SSLeay qw/XN_FLAG_RFC2253 ASN1_STRFLGS_ESC_MSB/;
|
|
my $flag_rfc22536_utf8 = (XN_FLAG_RFC2253) & (~ ASN1_STRFLGS_ESC_MSB);
|
|
my $result = Net::SSLeay::X509_NAME_print_ex($name, $flag_rfc22536_utf8, 1);
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/X509_NAME_print_ex.html">http://www.openssl.org/docs/crypto/X509_NAME_print_ex.html</A>>
|
|
<DT id="499">•<DD>
|
|
X509_NAME_get_text_by_NID
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Retrieves the text from the first entry in name which matches <TT>$nid</TT>, if no
|
|
such entry exists -1 is returned.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B>openssl note:</B> this is a legacy function which has various limitations which
|
|
makes it of minimal use in practice. It can only find the first matching
|
|
entry and will copy the contents of the field verbatim: this can be highly
|
|
confusing if the target is a multicharacter string type like a BMPString or a UTF8String.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::X509_NAME_get_text_by_NID($name, $nid);
|
|
# $name - value corresponding to openssl's X509_NAME structure
|
|
# $nid - NID value (integer)
|
|
#
|
|
# returns: text value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/X509_NAME_get_index_by_NID.html">http://www.openssl.org/docs/crypto/X509_NAME_get_index_by_NID.html</A>>
|
|
<DT id="500">•<DD>
|
|
X509_NAME_oneline
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Return an <FONT SIZE="-1">ASCII</FONT> version of <TT>$name</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::X509_NAME_oneline($name);
|
|
# $name - value corresponding to openssl's X509_NAME structure
|
|
#
|
|
# returns: (string) ASCII version of $name
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/X509_NAME_print_ex.html">http://www.openssl.org/docs/crypto/X509_NAME_print_ex.html</A>>
|
|
<DT id="501">•<DD>
|
|
sk_X509_NAME_free
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Free an allocated <FONT SIZE="-1">STACK_OF</FONT>(X509_NAME) structure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::sk_X509_NAME_free($sk);
|
|
# $sk - value corresponding to openssl's STACK_OF(X509_NAME) structure
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="502">•<DD>
|
|
sk_X509_NAME_num
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Return number of items in <FONT SIZE="-1">STACK_OF</FONT>(X509_NAME)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::sk_X509_NAME_num($sk);
|
|
# $sk - value corresponding to openssl's STACK_OF(X509_NAME) structure
|
|
#
|
|
# returns: number of items
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="503">•<DD>
|
|
sk_X509_NAME_value
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns X509_NAME from position <TT>$index</TT> in <FONT SIZE="-1">STACK_OF</FONT>(X509_NAME)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::sk_X509_NAME_value($sk, $i);
|
|
# $sk - value corresponding to openssl's STACK_OF(X509_NAME) structure
|
|
# $i - (integer) index/position
|
|
#
|
|
# returns: value corresponding to openssl's X509_NAME structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="504">•<DD>
|
|
add_file_cert_subjects_to_stack
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Add a file of certs to a stack. All certs in <TT>$file</TT> that are not already in the <TT>$stackCAs</TT> will be added.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::add_file_cert_subjects_to_stack($stackCAs, $file);
|
|
# $stackCAs - value corresponding to openssl's STACK_OF(X509_NAME) structure
|
|
# $file - (string) filename
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="505">•<DD>
|
|
add_dir_cert_subjects_to_stack
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Add a directory of certs to a stack. All certs in <TT>$dir</TT> that are not already in the <TT>$stackCAs</TT> will be added.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::add_dir_cert_subjects_to_stack($stackCAs, $dir);
|
|
# $stackCAs - value corresponding to openssl's STACK_OF(X509_NAME) structure
|
|
# $dir - (string) the directory to append from. All files in this directory will be examined as potential certs. Any that are acceptable to SSL_add_dir_cert_subjects_to_stack() that are not already in the stack will be included.
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
</DL>
|
|
<P>
|
|
|
|
<I>Low level </I><FONT SIZE="-1"><I>API:</I></FONT><I> X509_STORE_* related functions</I>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="506">•<DD>
|
|
X509_STORE_CTX_new
|
|
|
|
|
|
<P>
|
|
|
|
|
|
returns a newly initialised X509_STORE_CTX structure.
|
|
<DT id="507">•<DD>
|
|
X509_STORE_CTX_init
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B>X509_STORE_CTX_init()</B> sets up an X509_STORE_CTX for a subsequent verification operation.
|
|
It must be called before each call to <B>X509_verify_cert()</B>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Net::SSLeay::X509_STORE_CTX_init($x509_store_ctx, <TT>$x509_store</TT>, <TT>$x509</TT>, <TT>$chain</TT>);
|
|
|
|
|
|
<P>
|
|
|
|
|
|
# <TT>$x509_store_ctx</TT> - value corresponding to openssl's X509_STORE_CTX structure (required)
|
|
# <TT>$x509_store</TT> - value corresponding to openssl's X509_STORE structure (optional)
|
|
# <TT>$x509</TT> - value corresponding to openssl's X509 structure (optional)
|
|
# <TT>$chain</TT> - value corresponding to openssl's <FONT SIZE="-1">STACK_OF</FONT>(X509) structure (optional)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/man1.0.2/crypto/X509_STORE_CTX_init.html">https://www.openssl.org/docs/man1.0.2/crypto/X509_STORE_CTX_init.html</A>>
|
|
<DT id="508">•<DD>
|
|
X509_STORE_CTX_free
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Frees an X509_STORE_CTX structure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Net::SSLeay::X509_STORE_CTX_free($x509_store_ctx);
|
|
|
|
|
|
<P>
|
|
|
|
|
|
# <TT>$x509_store_ctx</TT> - value corresponding to openssl's X509_STORE_CTX structure
|
|
<DT id="509">•<DD>
|
|
X509_verify_cert
|
|
|
|
|
|
<P>
|
|
|
|
|
|
The <B>X509_verify_cert()</B> function attempts to discover and validate a
|
|
certificate chain based on parameters in ctx. A complete description
|
|
of the process is contained in the <B><A HREF="/cgi-bin/man/man2html?1+verify">verify</A></B>(1) manual page.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
If this function returns 0, use X509_STORE_CTX_get_error to get additional error
|
|
information.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
my <TT>$rv</TT> = Net::SSLeay::X509_verify_cert($x509_store_ctx);
|
|
# <TT>$x509_store_ctx</TT> - value corresponding to openssl's X509_STORE_CTX structure
|
|
#
|
|
# returns: 1 if a complete chain can be built and validated, otherwise 0
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/manmaster/man3/X509_verify_cert.html">https://www.openssl.org/docs/manmaster/man3/X509_verify_cert.html</A>>
|
|
<DT id="510">•<DD>
|
|
X509_STORE_CTX_get_current_cert
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the certificate in ctx which caused the error or 0 if no certificate is relevant.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_STORE_CTX_get_current_cert($x509_store_ctx);
|
|
# $x509_store_ctx - value corresponding to openssl's X509_STORE_CTX structure
|
|
#
|
|
# returns: value corresponding to openssl's X509 structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/X509_STORE_CTX_get_error.html">http://www.openssl.org/docs/crypto/X509_STORE_CTX_get_error.html</A>>
|
|
<DT id="511">•<DD>
|
|
X509_STORE_CTX_get_error
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the error code of <TT>$ctx</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_STORE_CTX_get_error($x509_store_ctx);
|
|
# $x509_store_ctx - value corresponding to openssl's X509_STORE_CTX structure
|
|
#
|
|
# returns: (integer) error code
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
For more info about erro code values check function ``get_verify_result''.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/X509_STORE_CTX_get_error.html">http://www.openssl.org/docs/crypto/X509_STORE_CTX_get_error.html</A>>
|
|
<DT id="512">•<DD>
|
|
X509_STORE_CTX_get_error_depth
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the depth of the error. This is a non-negative integer representing
|
|
where in the certificate chain the error occurred. If it is zero it occurred
|
|
in the end entity certificate, one if it is the certificate which signed
|
|
the end entity certificate and so on.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_STORE_CTX_get_error_depth($x509_store_ctx);
|
|
# $x509_store_ctx - value corresponding to openssl's X509_STORE_CTX structure
|
|
#
|
|
# returns: (integer) depth
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/X509_STORE_CTX_get_error.html">http://www.openssl.org/docs/crypto/X509_STORE_CTX_get_error.html</A>>
|
|
<DT id="513">•<DD>
|
|
X509_STORE_CTX_get_ex_data
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Is used to retrieve the information for <TT>$idx</TT> from <TT>$x509_store_ctx</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_STORE_CTX_get_ex_data($x509_store_ctx, $idx);
|
|
# $x509_store_ctx - value corresponding to openssl's X509_STORE_CTX structure
|
|
# $idx - (integer) index for application specific data
|
|
#
|
|
# returns: pointer to ???
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="514">•<DD>
|
|
X509_STORE_CTX_set_ex_data
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Is used to store application data at arg for idx into <TT>$x509_store_ctx</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_STORE_CTX_set_ex_data($x509_store_ctx, $idx, $data);
|
|
# $x509_store_ctx - value corresponding to openssl's X509_STORE_CTX structure
|
|
# $idx - (integer) ???
|
|
# $data - (pointer) ???
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="515">•<DD>
|
|
X509_STORE_CTX_set_cert
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the certificate to be verified in <TT>$x509_store_ctx</TT> to <TT>$x</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::X509_STORE_CTX_set_cert($x509_store_ctx, $x);
|
|
# $x509_store_ctx - value corresponding to openssl's X509_STORE_CTX structure
|
|
# $x - value corresponding to openssl's X509 structure
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/X509_STORE_CTX_new.html">http://www.openssl.org/docs/crypto/X509_STORE_CTX_new.html</A>>
|
|
<DT id="516">•<DD>
|
|
X509_STORE_new
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns a newly initialized X509_STORE structure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
my <TT>$rv</TT> = <B>Net::SSLeay::X509_STORE_new()</B>;
|
|
#
|
|
# returns: value corresponding to openssl's X509_STORE structure (0 on failure)
|
|
<DT id="517">•<DD>
|
|
X509_STORE_free
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Frees an X509_STORE structure
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Net::SSLeay::X509_STORE_free($x509_store);
|
|
# <TT>$x509_store</TT> - value corresponding to openssl's X509_STORE structure
|
|
<DT id="518">•<DD>
|
|
X509_STORE_add_lookup
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Adds a lookup to an X509_STORE for a given lookup method.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
my <TT>$method</TT> = &Net::SSLeay::X509_LOOKUP_hash_dir;
|
|
my <TT>$rv</TT> = Net::SSLeay::X509_STORE_add_lookup($x509_store, <TT>$method</TT>);
|
|
# <TT>$method</TT> - value corresponding to openssl's X509_LOOKUP_METHOD structure
|
|
# <TT>$x509_store</TT> - value corresponding to openssl's X509_STORE structure
|
|
#
|
|
# returns: value corresponding to openssl's X509_LOOKUP structure
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/man1.1.1/man3/X509_load_crl_file.html">https://www.openssl.org/docs/man1.1.1/man3/X509_load_crl_file.html</A>>
|
|
<DT id="519">•<DD>
|
|
X509_STORE_CTX_set_error
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the error code of <TT>$ctx</TT> to <TT>$s</TT>. For example it might be used in a verification callback to set an error based on additional checks.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::X509_STORE_CTX_set_error($x509_store_ctx, $s);
|
|
# $x509_store_ctx - value corresponding to openssl's X509_STORE_CTX structure
|
|
# $s - (integer) error id
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/X509_STORE_CTX_get_error.html">http://www.openssl.org/docs/crypto/X509_STORE_CTX_get_error.html</A>>
|
|
<DT id="520">•<DD>
|
|
X509_STORE_add_cert
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Adds X509 certificate <TT>$x</TT> into the X509_STORE <TT>$store</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_STORE_add_cert($store, $x);
|
|
# $store - value corresponding to openssl's X509_STORE structure
|
|
# $x - value corresponding to openssl's X509 structure
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="521">•<DD>
|
|
X509_STORE_add_crl
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Adds X509 <FONT SIZE="-1">CRL</FONT> <TT>$x</TT> into the X509_STORE <TT>$store</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_STORE_add_crl($store, $x);
|
|
# $store - value corresponding to openssl's X509_STORE structure
|
|
# $x - value corresponding to openssl's X509_CRL structure
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="522">•<DD>
|
|
X509_STORE_set1_param
|
|
|
|
|
|
<P>
|
|
|
|
|
|
??? (more info needed)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_STORE_set1_param($store, $pm);
|
|
# $store - value corresponding to openssl's X509_STORE structure
|
|
# $pm - value corresponding to openssl's X509_VERIFY_PARAM structure
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="523">•<DD>
|
|
X509_LOOKUP_hash_dir
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns an X509_LOOKUP structure that instructs an X509_STORE to
|
|
load files from a directory containing certificates with filenames
|
|
in the format <I>hash.N</I> or crls with filenames in the format <I>hash.</I><B>r</B><I>N</I>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
my <TT>$rv</TT> = <B>Net::SSLeay::X509_LOOKUP_hash_dir()</B>;
|
|
#
|
|
# returns: value corresponding to openssl's X509_LOOKUP_METHOD structure, with the hashed directory method
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/man1.1.1/man3/X509_load_crl_file.html">https://www.openssl.org/docs/man1.1.1/man3/X509_load_crl_file.html</A>>
|
|
<DT id="524">•<DD>
|
|
X509_LOOKUP_add_dir
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Add a directory to an X509_LOOKUP structure, usually obtained from
|
|
X509_STORE_add_lookup.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
my <TT>$method</TT> = &Net::SSLeay::X509_LOOKUP_hash_dir;
|
|
my <TT>$lookup</TT> = Net::SSLeay::X509_STORE_add_lookup($x509_store, <TT>$method</TT>);
|
|
my <TT>$type</TT> = &Net::SSLeay::X509_FILETYPE_PEM;
|
|
Net::SSLeay::X509_LOOKUP_add_dir($lookup, <TT>$dir</TT>, <TT>$type</TT>);
|
|
# <TT>$lookup</TT> - value corresponding to openssl's X509_LOOKUP structure
|
|
# <TT>$dir</TT> - string path to a directory
|
|
s# <TT>$type</TT> - constant corresponding to the type of file in the directory - can be X509_FILETYPE_PEM, X509_FILETYPE_DEFAULT, or X509_FILETYPE_ASN1
|
|
<DT id="525">•<DD>
|
|
X509_STORE_set_flags
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::X509_STORE_set_flags($ctx, $flags);
|
|
# $ctx - value corresponding to openssl's X509_STORE structure
|
|
# $flags - (unsigned long) flags to be set (bitmask)
|
|
#
|
|
# returns: no return value
|
|
|
|
#to create $flags value use corresponding constants like
|
|
$flags = Net::SSLeay::X509_V_FLAG_CRL_CHECK();
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
For more details about <TT>$flags</TT> bitmask see ``X509_VERIFY_PARAM_set_flags''.
|
|
<DT id="526">•<DD>
|
|
X509_STORE_set_purpose
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::X509_STORE_set_purpose($ctx, $purpose);
|
|
# $ctx - value corresponding to openssl's X509_STORE structure
|
|
# $purpose - (integer) purpose identifier
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
For more details about <TT>$purpose</TT> identifier check ``CTX_set_purpose''.
|
|
<DT id="527">•<DD>
|
|
X509_STORE_set_trust
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::X509_STORE_set_trust($ctx, $trust);
|
|
# $ctx - value corresponding to openssl's X509_STORE structure
|
|
# $trust - (integer) trust identifier
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
For more details about <TT>$trust</TT> identifier check ``CTX_set_trust''.
|
|
</DL>
|
|
<P>
|
|
|
|
<I>Low Level </I><FONT SIZE="-1"><I>API: X509_INFO</I></FONT><I> related functions</I>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="528">•<DD>
|
|
sk_X509_INFO_num
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the number of values in a <FONT SIZE="-1">STACK_OF</FONT>(X509_INFO) structure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::sk_X509_INFO_num($sk_x509_info);
|
|
# $sk_x509_info - value corresponding to openssl's STACK_OF(X509_INFO) structure
|
|
#
|
|
# returns: number of values in $sk_X509_info
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="529">•<DD>
|
|
sk_X509_INFO_value
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the value of a <FONT SIZE="-1">STACK_OF</FONT>(X509_INFO) structure at a given index.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::sk_X509_INFO_value($sk_x509_info, $index);
|
|
# $sk_x509_info - value corresponding to openssl's STACK_OF(X509_INFO) structure
|
|
# $index - index into the stack
|
|
#
|
|
# returns: value corresponding to openssl's X509_INFO structure at the given index
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="530">•<DD>
|
|
P_X509_INFO_get_x509
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the X509 structure stored in an X509_INFO structure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::P_X509_INFO_get_x509($x509_info);
|
|
# $x509_info - value corresponding to openssl's X509_INFO structure
|
|
#
|
|
# returns: value corresponding to openssl's X509 structure
|
|
|
|
</PRE>
|
|
|
|
|
|
</DL>
|
|
<P>
|
|
|
|
<I>Low level </I><FONT SIZE="-1"><I>API:</I></FONT><I> X509_VERIFY_PARAM_* related functions</I>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="531">•<DD>
|
|
X509_VERIFY_PARAM_add0_policy
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Enables policy checking (it is disabled by default) and adds <TT>$policy</TT> to the acceptable policy set.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_VERIFY_PARAM_add0_policy($param, $policy);
|
|
# $param - value corresponding to openssl's X509_VERIFY_PARAM structure
|
|
# $policy - value corresponding to openssl's ASN1_OBJECT structure
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/X509_VERIFY_PARAM_set_flags.html">http://www.openssl.org/docs/crypto/X509_VERIFY_PARAM_set_flags.html</A>>
|
|
<DT id="532">•<DD>
|
|
X509_VERIFY_PARAM_add0_table
|
|
|
|
|
|
<P>
|
|
|
|
|
|
??? (more info needed)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_VERIFY_PARAM_add0_table($param);
|
|
# $param - value corresponding to openssl's X509_VERIFY_PARAM structure
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="533">•<DD>
|
|
X509_VERIFY_PARAM_add1_host
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.82 and before; requires at least OpenSSL 1.0.2
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Adds an additional reference identifier that can match the peer's certificate.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_VERIFY_PARAM_add1_host($param, $name);
|
|
# $param - value corresponding to openssl's X509_VERIFY_PARAM structure
|
|
# $name - (string) name to be set
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
See also OpenSSL docs, ``X509_VERIFY_PARAM_set1_host'' and
|
|
``X509_VERIFY_PARAM_set_hostflags'' for more information, including
|
|
wildcard matching.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/crypto/X509_VERIFY_PARAM_set_flags.html">https://www.openssl.org/docs/crypto/X509_VERIFY_PARAM_set_flags.html</A>>
|
|
<DT id="534">•<DD>
|
|
X509_VERIFY_PARAM_clear_flags
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Clears the flags <TT>$flags</TT> in param.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_VERIFY_PARAM_clear_flags($param, $flags);
|
|
# $param - value corresponding to openssl's X509_VERIFY_PARAM structure
|
|
# $flags - (unsigned long) flags to be set (bitmask)
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
For more details about <TT>$flags</TT> bitmask see ``X509_VERIFY_PARAM_set_flags''.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/X509_VERIFY_PARAM_set_flags.html">http://www.openssl.org/docs/crypto/X509_VERIFY_PARAM_set_flags.html</A>>
|
|
<DT id="535">•<DD>
|
|
X509_VERIFY_PARAM_free
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Frees up the X509_VERIFY_PARAM structure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::X509_VERIFY_PARAM_free($param);
|
|
# $param - value corresponding to openssl's X509_VERIFY_PARAM structure
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="536">•<DD>
|
|
X509_VERIFY_PARAM_get0_peername
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.82 and before; requires at least OpenSSL 1.0.2
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the <FONT SIZE="-1">DNS</FONT> hostname or subject CommonName from the peer certificate that matched one of the reference identifiers.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_VERIFY_PARAM_get0_peername($param);
|
|
# $param - value corresponding to openssl's X509_VERIFY_PARAM structure
|
|
#
|
|
# returns: (string) name e.g. '*.example.com' or undef
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/crypto/X509_VERIFY_PARAM_set_flags.html">https://www.openssl.org/docs/crypto/X509_VERIFY_PARAM_set_flags.html</A>>
|
|
<DT id="537">•<DD>
|
|
X509_VERIFY_PARAM_get_depth
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the current verification depth.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_VERIFY_PARAM_get_depth($param);
|
|
# $param - value corresponding to openssl's X509_VERIFY_PARAM structure
|
|
#
|
|
# returns: (ineger) depth
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/X509_VERIFY_PARAM_set_flags.html">http://www.openssl.org/docs/crypto/X509_VERIFY_PARAM_set_flags.html</A>>
|
|
<DT id="538">•<DD>
|
|
X509_VERIFY_PARAM_get_flags
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the current verification flags.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_VERIFY_PARAM_get_flags($param);
|
|
# $param - value corresponding to openssl's X509_VERIFY_PARAM structure
|
|
#
|
|
# returns: (unsigned long) flags to be set (bitmask)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
For more details about returned flags bitmask see ``X509_VERIFY_PARAM_set_flags''.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/X509_VERIFY_PARAM_set_flags.html">http://www.openssl.org/docs/crypto/X509_VERIFY_PARAM_set_flags.html</A>>
|
|
<DT id="539">•<DD>
|
|
X509_VERIFY_PARAM_set_flags
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_VERIFY_PARAM_set_flags($param, $flags);
|
|
# $param - value corresponding to openssl's X509_VERIFY_PARAM structure
|
|
# $flags - (unsigned long) flags to be set (bitmask)
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
#to create $flags value use corresponding constants like
|
|
$flags = Net::SSLeay::X509_V_FLAG_CRL_CHECK();
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
For more details about <TT>$flags</TT> bitmask, see the OpenSSL docs below.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/X509_VERIFY_PARAM_set_flags.html">http://www.openssl.org/docs/crypto/X509_VERIFY_PARAM_set_flags.html</A>>
|
|
<DT id="540">•<DD>
|
|
X509_VERIFY_PARAM_inherit
|
|
|
|
|
|
<P>
|
|
|
|
|
|
??? (more info needed)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_VERIFY_PARAM_inherit($to, $from);
|
|
# $to - value corresponding to openssl's X509_VERIFY_PARAM structure
|
|
# $from - value corresponding to openssl's X509_VERIFY_PARAM structure
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="541">•<DD>
|
|
X509_VERIFY_PARAM_lookup
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Finds X509_VERIFY_PARAM by name.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_VERIFY_PARAM_lookup($name);
|
|
# $name - (string) name we want to find
|
|
#
|
|
# returns: value corresponding to openssl's X509_VERIFY_PARAM structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="542">•<DD>
|
|
X509_VERIFY_PARAM_new
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Creates a new X509_VERIFY_PARAM structure.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_VERIFY_PARAM_new();
|
|
#
|
|
# returns: value corresponding to openssl's X509_VERIFY_PARAM structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="543">•<DD>
|
|
X509_VERIFY_PARAM_set1
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the name of X509_VERIFY_PARAM structure <TT>$to</TT> to the same value
|
|
as the name of X509_VERIFY_PARAM structure <TT>$from</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_VERIFY_PARAM_set1($to, $from);
|
|
# $to - value corresponding to openssl's X509_VERIFY_PARAM structure
|
|
# $from - value corresponding to openssl's X509_VERIFY_PARAM structure
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="544">•<DD>
|
|
X509_VERIFY_PARAM_set1_email
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.82 and before; requires at least OpenSSL 1.0.2
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the expected <FONT SIZE="-1">RFC822</FONT> email address to email.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_VERIFY_PARAM_set1_email($param, $email);
|
|
# $param - value corresponding to openssl's X509_VERIFY_PARAM structure
|
|
# $email - (string) email to be set
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/crypto/X509_VERIFY_PARAM_set_flags.html">https://www.openssl.org/docs/crypto/X509_VERIFY_PARAM_set_flags.html</A>>
|
|
<DT id="545">•<DD>
|
|
X509_VERIFY_PARAM_set1_host
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.82 and before; requires at least OpenSSL 1.0.2
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the expected <FONT SIZE="-1">DNS</FONT> hostname to name clearing any previously specified host name or names.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_VERIFY_PARAM_set1_host($param, $name);
|
|
# $param - value corresponding to openssl's X509_VERIFY_PARAM structure
|
|
# $name - (string) name to be set
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
See also OpenSSL docs, ``X509_VERIFY_PARAM_add1_host'' and
|
|
``X509_VERIFY_PARAM_set_hostflags'' for more information, including
|
|
wildcard matching.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/crypto/X509_VERIFY_PARAM_set_flags.html">https://www.openssl.org/docs/crypto/X509_VERIFY_PARAM_set_flags.html</A>>
|
|
<DT id="546">•<DD>
|
|
X509_VERIFY_PARAM_set1_ip
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.82 and before; requires at least OpenSSL 1.0.2
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the expected <FONT SIZE="-1">IP</FONT> address to ip.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_VERIFY_PARAM_set1_ip($param, $ip);
|
|
# $param - value corresponding to openssl's X509_VERIFY_PARAM structure
|
|
# $ip - (binary) 4 octet IPv4 or 16 octet IPv6 address
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/crypto/X509_VERIFY_PARAM_set_flags.html">https://www.openssl.org/docs/crypto/X509_VERIFY_PARAM_set_flags.html</A>>
|
|
<DT id="547">•<DD>
|
|
X509_VERIFY_PARAM_set1_ip_asc
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.82 and before; requires at least OpenSSL 1.0.2
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the expected <FONT SIZE="-1">IP</FONT> address to ipasc.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_VERIFY_PARAM_set1_asc($param, $ipasc);
|
|
# $param - value corresponding to openssl's X509_VERIFY_PARAM structure
|
|
# $ip - (string) IPv4 or IPv6 address
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/crypto/X509_VERIFY_PARAM_set_flags.html">https://www.openssl.org/docs/crypto/X509_VERIFY_PARAM_set_flags.html</A>>
|
|
<DT id="548">•<DD>
|
|
X509_VERIFY_PARAM_set1_name
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the name of X509_VERIFY_PARAM structure <TT>$param</TT> to <TT>$name</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_VERIFY_PARAM_set1_name($param, $name);
|
|
# $param - value corresponding to openssl's X509_VERIFY_PARAM structure
|
|
# $name - (string) name to be set
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="549">•<DD>
|
|
X509_VERIFY_PARAM_set1_policies
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Enables policy checking (it is disabled by default) and sets the acceptable policy set to policies.
|
|
Any existing policy set is cleared. The policies parameter can be 0 to clear an existing policy set.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_VERIFY_PARAM_set1_policies($param, $policies);
|
|
# $param - value corresponding to openssl's X509_VERIFY_PARAM structure
|
|
# $policies - value corresponding to openssl's STACK_OF(ASN1_OBJECT) structure
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/X509_VERIFY_PARAM_set_flags.html">http://www.openssl.org/docs/crypto/X509_VERIFY_PARAM_set_flags.html</A>>
|
|
<DT id="550">•<DD>
|
|
X509_VERIFY_PARAM_set_depth
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the maximum verification depth to depth. That is the maximum number of untrusted <FONT SIZE="-1">CA</FONT> certificates that can appear in a chain.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::X509_VERIFY_PARAM_set_depth($param, $depth);
|
|
# $param - value corresponding to openssl's X509_VERIFY_PARAM structure
|
|
# $depth - (integer) depth to be set
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/X509_VERIFY_PARAM_set_flags.html">http://www.openssl.org/docs/crypto/X509_VERIFY_PARAM_set_flags.html</A>>
|
|
<DT id="551">•<DD>
|
|
X509_VERIFY_PARAM_set_hostflags
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::X509_VERIFY_PARAM_set_hostflags($param, $flags);
|
|
# $param - value corresponding to openssl's X509_VERIFY_PARAM structure
|
|
# $flags - (unsigned int) flags to be set (bitmask)
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
See also OpenSSL docs, ``X509_VERIFY_PARAM_add1_host'' and ``X509_VERIFY_PARAM_set1_host'' for more information.
|
|
The flags for controlling wildcard checks and other features are defined in OpenSSL docs.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="https://www.openssl.org/docs/crypto/X509_VERIFY_PARAM_set_flags.html">https://www.openssl.org/docs/crypto/X509_VERIFY_PARAM_set_flags.html</A>>
|
|
<DT id="552">•<DD>
|
|
X509_VERIFY_PARAM_set_purpose
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the verification purpose in <TT>$param</TT> to <TT>$purpose</TT>. This determines the acceptable purpose
|
|
of the certificate chain, for example <FONT SIZE="-1">SSL</FONT> client or <FONT SIZE="-1">SSL</FONT> server.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_VERIFY_PARAM_set_purpose($param, $purpose);
|
|
# $param - value corresponding to openssl's X509_VERIFY_PARAM structure
|
|
# $purpose - (integer) purpose identifier
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
For more details about <TT>$purpose</TT> identifier check ``CTX_set_purpose''.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/X509_VERIFY_PARAM_set_flags.html">http://www.openssl.org/docs/crypto/X509_VERIFY_PARAM_set_flags.html</A>>
|
|
<DT id="553">•<DD>
|
|
X509_VERIFY_PARAM_set_time
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the verification time in <TT>$param</TT> to <TT>$t</TT>. Normally the current time is used.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::X509_VERIFY_PARAM_set_time($param, $t);
|
|
# $param - value corresponding to openssl's X509_VERIFY_PARAM structure
|
|
# $t - (time_t) time in seconds since 1.1.1970
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/X509_VERIFY_PARAM_set_flags.html">http://www.openssl.org/docs/crypto/X509_VERIFY_PARAM_set_flags.html</A>>
|
|
<DT id="554">•<DD>
|
|
X509_VERIFY_PARAM_set_trust
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets the trust setting in <TT>$param</TT> to <TT>$trust</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::X509_VERIFY_PARAM_set_trust($param, $trust);
|
|
# $param - value corresponding to openssl's X509_VERIFY_PARAM structure
|
|
# $trust - (integer) trust identifier
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
For more details about <TT>$trust</TT> identifier check ``CTX_set_trust''.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/X509_VERIFY_PARAM_set_flags.html">http://www.openssl.org/docs/crypto/X509_VERIFY_PARAM_set_flags.html</A>>
|
|
<DT id="555">•<DD>
|
|
X509_VERIFY_PARAM_table_cleanup
|
|
|
|
|
|
<P>
|
|
|
|
|
|
??? (more info needed)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::X509_VERIFY_PARAM_table_cleanup();
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
</DL>
|
|
<P>
|
|
|
|
<I>Low level </I><FONT SIZE="-1"><I>API:</I></FONT><I> Cipher (EVP_CIPHER_*) related functions</I>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="556">•<DD>
|
|
EVP_get_cipherbyname
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns an <FONT SIZE="-1">EVP_CIPHER</FONT> structure when passed a cipher name.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::EVP_get_cipherbyname($name);
|
|
# $name - (string) cipher name e.g. 'aes-128-cbc', 'camellia-256-ecb', 'des-ede', ...
|
|
#
|
|
# returns: value corresponding to openssl's EVP_CIPHER structure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/EVP_EncryptInit.html">http://www.openssl.org/docs/crypto/EVP_EncryptInit.html</A>>
|
|
</DL>
|
|
<P>
|
|
|
|
<I>Low level </I><FONT SIZE="-1"><I>API:</I></FONT><I> Digest (EVP_MD_*) related functions</I>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="557">•<DD>
|
|
OpenSSL_add_all_digests
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.42 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::OpenSSL_add_all_digests();
|
|
# no args, no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<A HREF="http://www.openssl.org/docs/crypto/OpenSSL_add_all_algorithms.html">http://www.openssl.org/docs/crypto/OpenSSL_add_all_algorithms.html</A>
|
|
<DT id="558">•<DD>
|
|
P_EVP_MD_list_all
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.42 and before; requires at least openssl-1.0.0
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>NOTE:</B></FONT><B></B> Does not exactly correspond to any low level <FONT SIZE="-1">API</FONT> function
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::P_EVP_MD_list_all();
|
|
#
|
|
# returns: arrayref - list of available digest names
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
The returned digest names correspond to values expected by ``EVP_get_digestbyname''.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Note that some of the digests are available by default and some only after calling ``OpenSSL_add_all_digests''.
|
|
<DT id="559">•<DD>
|
|
EVP_get_digestbyname
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.42 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::EVP_get_digestbyname($name);
|
|
# $name - string with digest name
|
|
#
|
|
# returns: value corresponding to openssl's EVP_MD structure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
The <TT>$name</TT> param can be:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
md2
|
|
md4
|
|
md5
|
|
mdc2
|
|
ripemd160
|
|
sha
|
|
sha1
|
|
sha224
|
|
sha256
|
|
sha512
|
|
whirlpool
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Or better check the supported digests by calling ``P_EVP_MD_list_all''.
|
|
<DT id="560">•<DD>
|
|
EVP_MD_type
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.42 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::EVP_MD_type($md);
|
|
# $md - value corresponding to openssl's EVP_MD structure
|
|
#
|
|
# returns: the NID (integer) of the OBJECT IDENTIFIER representing the given message digest
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="561">•<DD>
|
|
EVP_MD_size
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.42 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::EVP_MD_size($md);
|
|
# $md - value corresponding to openssl's EVP_MD structure
|
|
#
|
|
# returns: the size of the message digest in bytes (e.g. 20 for SHA1)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="562">•<DD>
|
|
EVP_MD_CTX_md
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.42 and before; requires at least openssl-0.9.7
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::EVP_MD_CTX_md($ctx);
|
|
# $ctx - value corresponding to openssl's EVP_MD_CTX structure
|
|
#
|
|
# returns: value corresponding to openssl's EVP_MD structure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="563">•<DD>
|
|
EVP_MD_CTX_create
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.42 and before; requires at least openssl-0.9.7
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Allocates, initializes and returns a digest context.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::EVP_MD_CTX_create();
|
|
#
|
|
# returns: value corresponding to openssl's EVP_MD_CTX structure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
The complete idea behind <FONT SIZE="-1">EVP_MD_CTX</FONT> looks like this example:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::OpenSSL_add_all_digests();
|
|
|
|
my $md = Net::SSLeay::EVP_get_digestbyname("sha1");
|
|
my $ctx = Net::SSLeay::EVP_MD_CTX_create();
|
|
Net::SSLeay::EVP_DigestInit($ctx, $md);
|
|
|
|
while(my $chunk = get_piece_of_data()) {
|
|
Net::SSLeay::EVP_DigestUpdate($ctx,$chunk);
|
|
}
|
|
|
|
my $result = Net::SSLeay::EVP_DigestFinal($ctx);
|
|
Net::SSLeay::EVP_MD_CTX_destroy($ctx);
|
|
|
|
print "digest=", unpack('H*', $result), "\n"; #print hex value
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="564">•<DD>
|
|
EVP_DigestInit_ex
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.42 and before; requires at least openssl-0.9.7
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Sets up digest context <TT>$ctx</TT> to use a digest <TT>$type</TT> from <FONT SIZE="-1">ENGINE</FONT> <TT>$impl</TT>, <TT>$ctx</TT> must be
|
|
initialized before calling this function, type will typically be supplied by a function
|
|
such as ``EVP_get_digestbyname''. If <TT>$impl</TT> is 0 then the default implementation of digest <TT>$type</TT> is used.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::EVP_DigestInit_ex($ctx, $type, $impl);
|
|
# $ctx - value corresponding to openssl's EVP_MD_CTX structure
|
|
# $type - value corresponding to openssl's EVP_MD structure
|
|
# $impl - value corresponding to openssl's ENGINE structure
|
|
#
|
|
# returns: 1 for success and 0 for failure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="565">•<DD>
|
|
EVP_DigestInit
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.42 and before; requires at least openssl-0.9.7
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Behaves in the same way as ``EVP_DigestInit_ex'' except the passed context <TT>$ctx</TT> does not have
|
|
to be initialized, and it always uses the default digest implementation.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::EVP_DigestInit($ctx, $type);
|
|
# $ctx - value corresponding to openssl's EVP_MD_CTX structure
|
|
# $type - value corresponding to openssl's EVP_MD structure
|
|
#
|
|
# returns: 1 for success and 0 for failure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="566">•<DD>
|
|
EVP_MD_CTX_destroy
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.42 and before; requires at least openssl-0.9.7
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Cleans up digest context <TT>$ctx</TT> and frees up the space allocated to it, it should be
|
|
called only on a context created using ``EVP_MD_CTX_create''.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::EVP_MD_CTX_destroy($ctx);
|
|
# $ctx - value corresponding to openssl's EVP_MD_CTX structure
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="567">•<DD>
|
|
EVP_DigestUpdate
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.42 and before; requires at least openssl-0.9.7
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::EVP_DigestUpdate($ctx, $data);
|
|
# $ctx - value corresponding to openssl's EVP_MD_CTX structure
|
|
# $data - data to be hashed
|
|
#
|
|
# returns: 1 for success and 0 for failure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="568">•<DD>
|
|
EVP_DigestFinal_ex
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.42 and before; requires at least openssl-0.9.7
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Retrieves the digest value from <TT>$ctx</TT>. After calling ``EVP_DigestFinal_ex'' no
|
|
additional calls to ``EVP_DigestUpdate'' can be made, but
|
|
``EVP_DigestInit_ex'' can be called to initialize a new digest operation.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $digest_value = Net::SSLeay::EVP_DigestFinal_ex($ctx);
|
|
# $ctx - value corresponding to openssl's EVP_MD_CTX structure
|
|
#
|
|
# returns: hash value (binary)
|
|
|
|
#to get printable (hex) value of digest use:
|
|
print unpack('H*', $digest_value);
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="569">•<DD>
|
|
EVP_DigestFinal
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.42 and before; requires at least openssl-0.9.7
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Similar to ``EVP_DigestFinal_ex'' except the digest context ctx is automatically cleaned up.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::EVP_DigestFinal($ctx);
|
|
# $ctx - value corresponding to openssl's EVP_MD_CTX structure
|
|
#
|
|
# returns: hash value (binary)
|
|
|
|
#to get printable (hex) value of digest use:
|
|
print unpack('H*', $digest_value);
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="570">•<DD>
|
|
<FONT SIZE="-1">MD2</FONT>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> no supported by default in openssl-1.0.0
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Computes <FONT SIZE="-1">MD2</FONT> from given <TT>$data</TT> (all data needs to be loaded into memory)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $digest = Net::SSLeay::MD2($data);
|
|
print "digest(hexadecimal)=", unpack('H*', $digest);
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="571">•<DD>
|
|
<FONT SIZE="-1">MD4</FONT>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Computes <FONT SIZE="-1">MD4</FONT> from given <TT>$data</TT> (all data needs to be loaded into memory)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $digest = Net::SSLeay::MD4($data);
|
|
print "digest(hexadecimal)=", unpack('H*', $digest);
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="572">•<DD>
|
|
<FONT SIZE="-1">MD5</FONT>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Computes <FONT SIZE="-1">MD5</FONT> from given <TT>$data</TT> (all data needs to be loaded into memory)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $digest = Net::SSLeay::MD5($data);
|
|
print "digest(hexadecimal)=", unpack('H*', $digest);
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="573">•<DD>
|
|
<FONT SIZE="-1">RIPEMD160</FONT>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Computes <FONT SIZE="-1">RIPEMD160</FONT> from given <TT>$data</TT> (all data needs to be loaded into memory)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $digest = Net::SSLeay::RIPEMD160($data);
|
|
print "digest(hexadecimal)=", unpack('H*', $digest);
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="574">•<DD>
|
|
<FONT SIZE="-1">SHA1</FONT>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.42 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Computes <FONT SIZE="-1">SHA1</FONT> from given <TT>$data</TT> (all data needs to be loaded into memory)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $digest = Net::SSLeay::SHA1($data);
|
|
print "digest(hexadecimal)=", unpack('H*', $digest);
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="575">•<DD>
|
|
<FONT SIZE="-1">SHA256</FONT>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.42 and before; requires at least openssl-0.9.8
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Computes <FONT SIZE="-1">SHA256</FONT> from given <TT>$data</TT> (all data needs to be loaded into memory)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $digest = Net::SSLeay::SHA256($data);
|
|
print "digest(hexadecimal)=", unpack('H*', $digest);
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="576">•<DD>
|
|
<FONT SIZE="-1">SHA512</FONT>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.42 and before; requires at least openssl-0.9.8
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Computes <FONT SIZE="-1">SHA512</FONT> from given <TT>$data</TT> (all data needs to be loaded into memory)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $digest = Net::SSLeay::SHA512($data);
|
|
print "digest(hexadecimal)=", unpack('H*', $digest);
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="577">•<DD>
|
|
EVP_Digest
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.42 and before; requires at least openssl-0.9.7
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Computes ``any'' digest from given <TT>$data</TT> (all data needs to be loaded into memory)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $md = Net::SSLeay::EVP_get_digestbyname("sha1"); #or any other algorithm
|
|
my $digest = Net::SSLeay::EVP_Digest($data, $md);
|
|
print "digest(hexadecimal)=", unpack('H*', $digest);
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="578">•<DD>
|
|
EVP_sha1
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.42 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $md = Net::SSLeay::EVP_sha1();
|
|
#
|
|
# returns: value corresponding to openssl's EVP_MD structure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="579">•<DD>
|
|
EVP_sha256
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> requires at least openssl-0.9.8
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $md = Net::SSLeay::EVP_sha256();
|
|
#
|
|
# returns: value corresponding to openssl's EVP_MD structure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="580">•<DD>
|
|
EVP_sha512
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.42 and before; requires at least openssl-0.9.8
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $md = Net::SSLeay::EVP_sha512();
|
|
#
|
|
# returns: value corresponding to openssl's EVP_MD structure
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="581">•<DD>
|
|
EVP_add_digest
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::EVP_add_digest($digest);
|
|
# $digest - value corresponding to openssl's EVP_MD structure
|
|
#
|
|
# returns: 1 on success, 0 otherwise
|
|
|
|
</PRE>
|
|
|
|
|
|
</DL>
|
|
<P>
|
|
|
|
<I>Low level </I><FONT SIZE="-1"><I>API:</I></FONT><I> CIPHER_* related functions</I>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="582">•<DD>
|
|
CIPHER_get_name
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.42 and before
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns name of the cipher used.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::CIPHER_description($cipher);
|
|
# $cipher - value corresponding to openssl's SSL_CIPHER structure
|
|
#
|
|
# returns: (string) cipher name e.g. 'DHE-RSA-AES256-SHA'
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CIPHER_get_name.html">http://www.openssl.org/docs/ssl/SSL_CIPHER_get_name.html</A>>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Example:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $ssl_cipher = Net::SSLeay::get_current_cipher($ssl);
|
|
my $cipher_name = Net::SSLeay::CIPHER_get_name($ssl_cipher);
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="583">•<DD>
|
|
CIPHER_description
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns a textual description of the cipher used.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
??? (does this function really work?)
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::CIPHER_description($cipher, $buf, $size);
|
|
# $cipher - value corresponding to openssl's SSL_CIPHER structure
|
|
# $bufer - (string/buffer) ???
|
|
# $size - (integer) ???
|
|
#
|
|
# returns: (string) cipher description e.g. 'DHE-RSA-AES256-SHA SSLv3 Kx=DH Au=RSA Enc=AES(256) Mac=SHA1'
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CIPHER_get_name.html">http://www.openssl.org/docs/ssl/SSL_CIPHER_get_name.html</A>>
|
|
<DT id="584">•<DD>
|
|
CIPHER_get_bits
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the number of secret bits used for cipher.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::CIPHER_get_bits($c);
|
|
# $c - value corresponding to openssl's SSL_CIPHER structure
|
|
#
|
|
# returns: (integert) number of secret bits, 0 on error
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_CIPHER_get_name.html">http://www.openssl.org/docs/ssl/SSL_CIPHER_get_name.html</A>>
|
|
</DL>
|
|
<P>
|
|
|
|
<I>Low level </I><FONT SIZE="-1"><I>API:</I></FONT><I> RSA_* related functions</I>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="585">•<DD>
|
|
RSA_generate_key
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Generates a key pair and returns it in a newly allocated <FONT SIZE="-1">RSA</FONT> structure.
|
|
The pseudo-random number generator must be seeded prior to calling RSA_generate_key.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::RSA_generate_key($bits, $e, $perl_cb, $perl_cb_arg);
|
|
# $bits - (integer) modulus size in bits e.g. 512, 1024, 2048
|
|
# $e - (integer) public exponent, an odd number, typically 3, 17 or 65537
|
|
# $perl_cb - [optional] reference to perl callback function
|
|
# $perl_cb_arg - [optional] data that will be passed to callback function when invoked
|
|
#
|
|
# returns: value corresponding to openssl's RSA structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/RSA_generate_key.html">http://www.openssl.org/docs/crypto/RSA_generate_key.html</A>>
|
|
<DT id="586">•<DD>
|
|
RSA_free
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Frees the <FONT SIZE="-1">RSA</FONT> structure and its components. The key is erased before the memory is returned to the system.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::RSA_free($r);
|
|
# $r - value corresponding to openssl's RSA structure
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/RSA_new.html">http://www.openssl.org/docs/crypto/RSA_new.html</A>>
|
|
<DT id="587">•<DD>
|
|
RSA_get_key_parameters
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns a list of pointers to BIGNUMs representing the parameters of the key in
|
|
this order:
|
|
(n, e, d, p, q, dmp1, dmq1, iqmp)
|
|
Caution: returned list consists of <FONT SIZE="-1">SV</FONT> pointers to BIGNUMs, which would need to be blessed as Crypt::OpenSSL::Bignum for further use
|
|
|
|
|
|
<P>
|
|
|
|
|
|
my (@params) = RSA_get_key_parameters($r);
|
|
</DL>
|
|
<P>
|
|
|
|
<I>Low level </I><FONT SIZE="-1"><I>API:</I></FONT><I> BIO_* related functions</I>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="588">•<DD>
|
|
BIO_eof
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns 1 if the <FONT SIZE="-1">BIO</FONT> has read <FONT SIZE="-1">EOF,</FONT> the precise meaning of '<FONT SIZE="-1">EOF</FONT>' varies according to the <FONT SIZE="-1">BIO</FONT> type.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::BIO_eof($s);
|
|
# $s - value corresponding to openssl's BIO structure
|
|
#
|
|
# returns: 1 if EOF has been reached 0 otherwise
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/BIO_ctrl.html">http://www.openssl.org/docs/crypto/BIO_ctrl.html</A>>
|
|
<DT id="589">•<DD>
|
|
BIO_f_ssl
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the <FONT SIZE="-1">SSL BIO</FONT> method. This is a filter <FONT SIZE="-1">BIO</FONT> which is a wrapper
|
|
round the OpenSSL <FONT SIZE="-1">SSL</FONT> routines adding a <FONT SIZE="-1">BIO</FONT> 'flavour' to <FONT SIZE="-1">SSL I/O.</FONT>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::BIO_f_ssl();
|
|
#
|
|
# returns: value corresponding to openssl's BIO_METHOD structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/BIO_f_ssl.html">http://www.openssl.org/docs/crypto/BIO_f_ssl.html</A>>
|
|
<DT id="590">•<DD>
|
|
BIO_free
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Frees up a single <FONT SIZE="-1">BIO.</FONT>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::BIO_free($bio;);
|
|
# $bio; - value corresponding to openssl's BIO structure
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/BIO_new.html">http://www.openssl.org/docs/crypto/BIO_new.html</A>>
|
|
<DT id="591">•<DD>
|
|
BIO_new
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns a new <FONT SIZE="-1">BIO</FONT> using method <TT>$type</TT>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::BIO_new($type);
|
|
# $type - value corresponding to openssl's BIO_METHOD structure
|
|
#
|
|
# returns: value corresponding to openssl's BIO structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/BIO_new.html">http://www.openssl.org/docs/crypto/BIO_new.html</A>>
|
|
<DT id="592">•<DD>
|
|
BIO_new_buffer_ssl_connect
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Creates a new <FONT SIZE="-1">BIO</FONT> chain consisting of a buffering <FONT SIZE="-1">BIO,</FONT> an <FONT SIZE="-1">SSL BIO</FONT> (using ctx) and a connect <FONT SIZE="-1">BIO.</FONT>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::BIO_new_buffer_ssl_connect($ctx);
|
|
# $ctx - value corresponding to openssl's SSL_CTX structure
|
|
#
|
|
# returns: value corresponding to openssl's BIO structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/BIO_f_ssl.html">http://www.openssl.org/docs/crypto/BIO_f_ssl.html</A>>
|
|
<DT id="593">•<DD>
|
|
BIO_new_file
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Creates a new file <FONT SIZE="-1">BIO</FONT> with mode <TT>$mode</TT> the meaning of mode is the same
|
|
as the stdio function <B>fopen()</B>. The <FONT SIZE="-1">BIO_CLOSE</FONT> flag is set on the returned <FONT SIZE="-1">BIO.</FONT>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::BIO_new_file($filename, $mode);
|
|
# $filename - (string) filename
|
|
# $mode - (string) opening mode (as mode by stdio function fopen)
|
|
#
|
|
# returns: value corresponding to openssl's BIO structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/BIO_s_file.html">http://www.openssl.org/docs/crypto/BIO_s_file.html</A>>
|
|
<DT id="594">•<DD>
|
|
BIO_new_ssl
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Allocates an <FONT SIZE="-1">SSL BIO</FONT> using <FONT SIZE="-1">SSL_CTX</FONT> ctx and using client mode if client is non zero.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::BIO_new_ssl($ctx, $client);
|
|
# $ctx - value corresponding to openssl's SSL_CTX structure
|
|
# $client - (integer) 0 or 1 - indicates ssl client mode
|
|
#
|
|
# returns: value corresponding to openssl's BIO structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/BIO_f_ssl.html">http://www.openssl.org/docs/crypto/BIO_f_ssl.html</A>>
|
|
<DT id="595">•<DD>
|
|
BIO_new_ssl_connect
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Creates a new <FONT SIZE="-1">BIO</FONT> chain consisting of an <FONT SIZE="-1">SSL BIO</FONT> (using ctx) followed by a connect <FONT SIZE="-1">BIO.</FONT>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::BIO_new_ssl_connect($ctx);
|
|
# $ctx - value corresponding to openssl's SSL_CTX structure
|
|
#
|
|
# returns: value corresponding to openssl's BIO structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/BIO_f_ssl.html">http://www.openssl.org/docs/crypto/BIO_f_ssl.html</A>>
|
|
<DT id="596">•<DD>
|
|
BIO_pending
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Return the number of pending characters in the BIOs read buffers.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::BIO_pending($s);
|
|
# $s - value corresponding to openssl's BIO structure
|
|
#
|
|
# returns: the amount of pending data
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/BIO_ctrl.html">http://www.openssl.org/docs/crypto/BIO_ctrl.html</A>>
|
|
<DT id="597">•<DD>
|
|
BIO_wpending
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Return the number of pending characters in the BIOs write buffers.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::BIO_wpending($s);
|
|
# $s - value corresponding to openssl's BIO structure
|
|
#
|
|
# returns: the amount of pending data
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/BIO_ctrl.html">http://www.openssl.org/docs/crypto/BIO_ctrl.html</A>>
|
|
<DT id="598">•<DD>
|
|
BIO_read
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Read the underlying descriptor.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::BIO_read($s, $max);
|
|
# $s - value corresponding to openssl's BIO structure
|
|
# $max - [optional] max. bytes to read (if not specified, the value 32768 is used)
|
|
#
|
|
# returns: data
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/BIO_read.html">http://www.openssl.org/docs/crypto/BIO_read.html</A>>
|
|
<DT id="599">•<DD>
|
|
BIO_write
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Attempts to write data from <TT>$buffer</TT> to <FONT SIZE="-1">BIO</FONT> <TT>$b</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::BIO_write($b, $buffer);
|
|
# $b - value corresponding to openssl's BIO structure
|
|
# $buffer - data
|
|
#
|
|
# returns: amount of data successfully written
|
|
# or that no data was successfully read or written if the result is 0 or -1
|
|
# or -2 when the operation is not implemented in the specific BIO type
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/BIO_read.html">http://www.openssl.org/docs/crypto/BIO_read.html</A>>
|
|
<DT id="600">•<DD>
|
|
BIO_s_mem
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Return the memory <FONT SIZE="-1">BIO</FONT> method function.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::BIO_s_mem();
|
|
#
|
|
# returns: value corresponding to openssl's BIO_METHOD structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/BIO_s_mem.html">http://www.openssl.org/docs/crypto/BIO_s_mem.html</A>>
|
|
<DT id="601">•<DD>
|
|
BIO_ssl_copy_session_id
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Copies an <FONT SIZE="-1">SSL</FONT> session id between <FONT SIZE="-1">BIO</FONT> chains from and to. It does this by locating
|
|
the <FONT SIZE="-1">SSL</FONT> BIOs in each chain and calling <B>SSL_copy_session_id()</B> on the internal <FONT SIZE="-1">SSL</FONT> pointer.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::BIO_ssl_copy_session_id($to, $from);
|
|
# $to - value corresponding to openssl's BIO structure
|
|
# $from - value corresponding to openssl's BIO structure
|
|
#
|
|
# returns: 1 on success, 0 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/BIO_f_ssl.html">http://www.openssl.org/docs/crypto/BIO_f_ssl.html</A>>
|
|
<DT id="602">•<DD>
|
|
BIO_ssl_shutdown
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Closes down an <FONT SIZE="-1">SSL</FONT> connection on <FONT SIZE="-1">BIO</FONT> chain bio. It does this by locating the
|
|
<FONT SIZE="-1">SSL BIO</FONT> in the chain and calling <B>SSL_shutdown()</B> on its internal <FONT SIZE="-1">SSL</FONT> pointer.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::BIO_ssl_shutdown($ssl_bio);
|
|
# $ssl_bio - value corresponding to openssl's BIO structure
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/BIO_f_ssl.html">http://www.openssl.org/docs/crypto/BIO_f_ssl.html</A>>
|
|
</DL>
|
|
<P>
|
|
|
|
<I>Low level </I><FONT SIZE="-1"><I>API:</I></FONT><I> Server side Server Name Indication (</I><FONT SIZE="-1"><I>SNI</I></FONT><I>) support</I>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="603">•<DD>
|
|
set_tlsext_host_name
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<FONT SIZE="-1">TBA</FONT>
|
|
<DT id="604">•<DD>
|
|
get_servername
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<FONT SIZE="-1">TBA</FONT>
|
|
<DT id="605">•<DD>
|
|
get_servername_type
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<FONT SIZE="-1">TBA</FONT>
|
|
<DT id="606">•<DD>
|
|
CTX_set_tlsext_servername_callback
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> requires at least OpenSSL 0.9.8f
|
|
|
|
|
|
<P>
|
|
|
|
|
|
This function is used in a server to support Server side Server Name Indication (<FONT SIZE="-1">SNI</FONT>).
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::CTX_set_tlsext_servername_callback($ctx, $code)
|
|
# $ctx - SSL context
|
|
# $code - reference to a subroutine that will be called when a new connection is being initiated
|
|
#
|
|
# returns: no return value
|
|
On the client side:
|
|
use set_tlsext_host_name($ssl, $servername) before initiating the SSL connection.
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
On the server side:
|
|
Set up an additional <FONT SIZE="-1"><B>SSL_CTX</B></FONT><B>()</B> for each different certificate;
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Add a servername callback to each <FONT SIZE="-1"><B>SSL_CTX</B></FONT><B>()</B> using <B>CTX_set_tlsext_servername_callback()</B>;
|
|
|
|
|
|
<P>
|
|
|
|
|
|
The callback function is required to retrieve the client-supplied servername
|
|
with get_servername(ssl). Figure out the right
|
|
<FONT SIZE="-1">SSL_CTX</FONT> to go with that host name, then switch the <FONT SIZE="-1">SSL</FONT> object to that <FONT SIZE="-1">SSL_CTX</FONT>
|
|
with <B>set_SSL_CTX()</B>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Example:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
# set callback
|
|
Net::SSLeay::CTX_set_tlsext_servername_callback($ctx,
|
|
sub {
|
|
my $ssl = shift;
|
|
my $h = Net::SSLeay::get_servername($ssl);
|
|
Net::SSLeay::set_SSL_CTX($ssl, $hostnames{$h}->{ctx}) if exists $hostnames{$h};
|
|
} );
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
More complete example:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
# ... initialize Net::SSLeay
|
|
|
|
my %hostnames = (
|
|
'sni1' => { cert=>'sni1.pem', key=>'sni1.key' },
|
|
'sni2' => { cert=>'sni2.pem', key=>'sni2.key' },
|
|
);
|
|
|
|
# create a new context for each certificate/key pair
|
|
for my $name (keys %hostnames) {
|
|
$hostnames{$name}->{ctx} = Net::SSLeay::CTX_new or die;
|
|
Net::SSLeay::CTX_set_cipher_list($hostnames{$name}->{ctx}, 'ALL');
|
|
Net::SSLeay::set_cert_and_key($hostnames{$name}->{ctx},
|
|
$hostnames{$name}->{cert}, $hostnames{$name}->{key}) or die;
|
|
}
|
|
|
|
# create default context
|
|
my $ctx = Net::SSLeay::CTX_new or die;
|
|
Net::SSLeay::CTX_set_cipher_list($ctx, 'ALL');
|
|
Net::SSLeay::set_cert_and_key($ctx, 'cert.pem','key.pem') or die;
|
|
|
|
# set callback
|
|
Net::SSLeay::CTX_set_tlsext_servername_callback($ctx, sub {
|
|
my $ssl = shift;
|
|
my $h = Net::SSLeay::get_servername($ssl);
|
|
Net::SSLeay::set_SSL_CTX($ssl, $hostnames{$h}->{ctx}) if exists $hostnames{$h};
|
|
} );
|
|
|
|
# ... later
|
|
|
|
$s = Net::SSLeay::new($ctx);
|
|
Net::SSLeay::set_fd($s, fileno($accepted_socket));
|
|
Net::SSLeay::accept($s);
|
|
|
|
</PRE>
|
|
|
|
|
|
</DL>
|
|
<P>
|
|
|
|
<I>Low level </I><FONT SIZE="-1"><I>API: NPN</I></FONT><I> (next protocol negotiation) related functions</I>
|
|
|
|
|
|
<P>
|
|
|
|
<FONT SIZE="-1">NPN</FONT> is being replaced with <FONT SIZE="-1">ALPN,</FONT> a more recent <FONT SIZE="-1">TLS</FONT> extension for application
|
|
protocol negotiation that's in process of being adopted by <FONT SIZE="-1">IETF.</FONT> Please look
|
|
below for <FONT SIZE="-1">APLN API</FONT> description.
|
|
<P>
|
|
|
|
Simple approach for using <FONT SIZE="-1">NPN</FONT> support looks like this:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
### client side
|
|
use Net::SSLeay;
|
|
use IO::Socket::INET;
|
|
|
|
Net::SSLeay::initialize();
|
|
my $sock = IO::Socket::INET->new(PeerAddr=>'encrypted.google.com:443') or die;
|
|
my $ctx = Net::SSLeay::CTX_tlsv1_new() or die;
|
|
Net::SSLeay::CTX_set_options($ctx, &Net::SSLeay::OP_ALL);
|
|
Net::SSLeay::CTX_set_next_proto_select_cb($ctx, ['http1.1','spdy/2']);
|
|
my $ssl = Net::SSLeay::new($ctx) or die;
|
|
Net::SSLeay::set_fd($ssl, fileno($sock)) or die;
|
|
Net::SSLeay::connect($ssl);
|
|
|
|
warn "client:negotiated=",Net::SSLeay::P_next_proto_negotiated($ssl), "\n";
|
|
warn "client:last_status=", Net::SSLeay::P_next_proto_last_status($ssl), "\n";
|
|
|
|
### server side
|
|
use Net::SSLeay;
|
|
use IO::Socket::INET;
|
|
|
|
Net::SSLeay::initialize();
|
|
my $ctx = Net::SSLeay::CTX_tlsv1_new() or die;
|
|
Net::SSLeay::CTX_set_options($ctx, &Net::SSLeay::OP_ALL);
|
|
Net::SSLeay::set_cert_and_key($ctx, "cert.pem", "key.pem");
|
|
Net::SSLeay::CTX_set_next_protos_advertised_cb($ctx, ['spdy/2','http1.1']);
|
|
my $sock = IO::Socket::INET->new(LocalAddr=>'localhost', LocalPort=>5443, Proto=>'tcp', Listen=>20) or die;
|
|
|
|
while (1) {
|
|
my $ssl = Net::SSLeay::new($ctx);
|
|
warn("server:waiting for incoming connection...\n");
|
|
my $fd = $sock->accept();
|
|
Net::SSLeay::set_fd($ssl, $fd->fileno);
|
|
Net::SSLeay::accept($ssl);
|
|
warn "server:negotiated=",Net::SSLeay::P_next_proto_negotiated($ssl),"\n";
|
|
my $got = Net::SSLeay::read($ssl);
|
|
Net::SSLeay::ssl_write_all($ssl, "length=".length($got));
|
|
Net::SSLeay::free($ssl);
|
|
$fd->close();
|
|
}
|
|
# check with: openssl s_client -connect localhost:5443 -nextprotoneg http/1.1,spdy/2
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
Please note that the selection (negotiation) is performed by client side, the server side simply advertise the list of supported protocols.
|
|
<P>
|
|
|
|
Advanced approach allows you to implement your own negotiation algorithm.
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
#see below documentation for:
|
|
Net::SSleay::CTX_set_next_proto_select_cb($ctx, $perl_callback_function, $callback_data);
|
|
Net::SSleay::CTX_set_next_protos_advertised_cb($ctx, $perl_callback_function, $callback_data);
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
Detection of <FONT SIZE="-1">NPN</FONT> support (works even in older Net::SSLeay versions):
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
use Net::SSLeay;
|
|
|
|
if (exists &Net::SSLeay::P_next_proto_negotiated) {
|
|
# do NPN stuff
|
|
}
|
|
|
|
</PRE>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="607">•<DD>
|
|
CTX_set_next_proto_select_cb
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before; requires at least openssl-1.0.1
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>NOTE:</B></FONT><B></B> You need CTX_set_next_proto_select_cb on <B>client side</B> of <FONT SIZE="-1">SSL</FONT> connection.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Simple usage - in this case a ``common'' negotiation algorithm (as implemented by openssl's function SSL_select_next_proto) is used.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
$rv = Net::SSleay::CTX_set_next_proto_select_cb($ctx, $arrayref);
|
|
# $ctx - value corresponding to openssl's SSL_CTX structure
|
|
# $arrayref - list of accepted protocols - e.g. ['http1.0', 'http1.1']
|
|
#
|
|
# returns: 0 on success, 1 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Advanced usage (you probably do not need this):
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
$rv = Net::SSleay::CTX_set_next_proto_select_cb($ctx, $perl_callback_function, $callback_data);
|
|
# $ctx - value corresponding to openssl's SSL_CTX structure
|
|
# $perl_callback_function - reference to perl function
|
|
# $callback_data - [optional] data to passed to callback function when invoked
|
|
#
|
|
# returns: 0 on success, 1 on failure
|
|
|
|
# where callback function looks like
|
|
sub npn_advertised_cb_invoke {
|
|
my ($ssl, $arrayref_proto_list_advertised_by_server, $callback_data) = @_;
|
|
my $status;
|
|
# ...
|
|
$status = 1; #status can be:
|
|
# 0 - OPENSSL_NPN_UNSUPPORTED
|
|
# 1 - OPENSSL_NPN_NEGOTIATED
|
|
# 2 - OPENSSL_NPN_NO_OVERLAP
|
|
return $status, ['http1.1','spdy/2']; # the callback has to return 2 values
|
|
}
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
To undefine/clear this callback use:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSleay::CTX_set_next_proto_select_cb($ctx, undef);
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="608">•<DD>
|
|
CTX_set_next_protos_advertised_cb
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before; requires at least openssl-1.0.1
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>NOTE:</B></FONT><B></B> You need CTX_set_next_proto_select_cb on <B>server side</B> of <FONT SIZE="-1">SSL</FONT> connection.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Simple usage:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
$rv = Net::SSleay::CTX_set_next_protos_advertised_cb($ctx, $arrayref);
|
|
# $ctx - value corresponding to openssl's SSL_CTX structure
|
|
# $arrayref - list of advertised protocols - e.g. ['http1.0', 'http1.1']
|
|
#
|
|
# returns: 0 on success, 1 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Advanced usage (you probably do not need this):
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
$rv = Net::SSleay::CTX_set_next_protos_advertised_cb($ctx, $perl_callback_function, $callback_data);
|
|
# $ctx - value corresponding to openssl's SSL_CTX structure
|
|
# $perl_callback_function - reference to perl function
|
|
# $callback_data - [optional] data to passed to callback function when invoked
|
|
#
|
|
# returns: 0 on success, 1 on failure
|
|
|
|
# where callback function looks like
|
|
sub npn_advertised_cb_invoke {
|
|
my ($ssl, $callback_data) = @_;
|
|
# ...
|
|
return ['http1.1','spdy/2']; # the callback has to return arrayref
|
|
}
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
To undefine/clear this callback use:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSleay::CTX_set_next_protos_advertised_cb($ctx, undef);
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="609">•<DD>
|
|
P_next_proto_negotiated
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before; requires at least openssl-1.0.1
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the name of negotiated protocol for given <FONT SIZE="-1">SSL</FONT> connection <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
$rv = Net::SSLeay::P_next_proto_negotiated($ssl)
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: (string) negotiated protocol name (or undef if no negotiation was done or failed with fatal error)
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="610">•<DD>
|
|
P_next_proto_last_status
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.45 and before; requires at least openssl-1.0.1
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the result of the last negotiation for given <FONT SIZE="-1">SSL</FONT> connection <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
$rv = Net::SSLeay::P_next_proto_last_status($ssl)
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: (integer) negotiation status
|
|
# 0 - OPENSSL_NPN_UNSUPPORTED
|
|
# 1 - OPENSSL_NPN_NEGOTIATED
|
|
# 2 - OPENSSL_NPN_NO_OVERLAP
|
|
|
|
</PRE>
|
|
|
|
|
|
</DL>
|
|
<P>
|
|
|
|
<I>Low level </I><FONT SIZE="-1"><I>API: ALPN</I></FONT><I> (application layer protocol negotiation) related functions</I>
|
|
|
|
|
|
<P>
|
|
|
|
Application protocol can be negotiated via two different mechanisms employing
|
|
two different <FONT SIZE="-1">TLS</FONT> extensions: <FONT SIZE="-1">NPN</FONT> (obsolete) and <FONT SIZE="-1">ALPN</FONT> (recommended).
|
|
<P>
|
|
|
|
The <FONT SIZE="-1">API</FONT> is rather similar, with slight differences reflecting protocol
|
|
specifics. In particular, with <FONT SIZE="-1">ALPN</FONT> the protocol negotiation takes place on
|
|
server, while with <FONT SIZE="-1">NPN</FONT> the client implements the protocol negotiation logic.
|
|
<P>
|
|
|
|
With <FONT SIZE="-1">ALPN,</FONT> the most basic implementation looks like this:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
### client side
|
|
use Net::SSLeay;
|
|
use IO::Socket::INET;
|
|
|
|
Net::SSLeay::initialize();
|
|
my $sock = IO::Socket::INET->new(PeerAddr=>'encrypted.google.com:443') or die;
|
|
my $ctx = Net::SSLeay::CTX_tlsv1_new() or die;
|
|
Net::SSLeay::CTX_set_options($ctx, &Net::SSLeay::OP_ALL);
|
|
Net::SSLeay::CTX_set_alpn_protos($ctx, ['http/1.1', 'http/2.0', 'spdy/3]);
|
|
my $ssl = Net::SSLeay::new($ctx) or die;
|
|
Net::SSLeay::set_fd($ssl, fileno($sock)) or die;
|
|
Net::SSLeay::connect($ssl);
|
|
|
|
warn "client:selected=",Net::SSLeay::P_alpn_selected($ssl), "\n";
|
|
|
|
### server side
|
|
use Net::SSLeay;
|
|
use IO::Socket::INET;
|
|
|
|
Net::SSLeay::initialize();
|
|
my $ctx = Net::SSLeay::CTX_tlsv1_new() or die;
|
|
Net::SSLeay::CTX_set_options($ctx, &Net::SSLeay::OP_ALL);
|
|
Net::SSLeay::set_cert_and_key($ctx, "cert.pem", "key.pem");
|
|
Net::SSLeay::CTX_set_alpn_select_cb($ctx, ['http/1.1', 'http/2.0', 'spdy/3]);
|
|
my $sock = IO::Socket::INET->new(LocalAddr=>'localhost', LocalPort=>5443, Proto=>'tcp', Listen=>20) or die;
|
|
|
|
while (1) {
|
|
my $ssl = Net::SSLeay::new($ctx);
|
|
warn("server:waiting for incoming connection...\n");
|
|
my $fd = $sock->accept();
|
|
Net::SSLeay::set_fd($ssl, $fd->fileno);
|
|
Net::SSLeay::accept($ssl);
|
|
warn "server:selected=",Net::SSLeay::P_alpn_selected($ssl),"\n";
|
|
my $got = Net::SSLeay::read($ssl);
|
|
Net::SSLeay::ssl_write_all($ssl, "length=".length($got));
|
|
Net::SSLeay::free($ssl);
|
|
$fd->close();
|
|
}
|
|
# check with: openssl s_client -connect localhost:5443 -alpn spdy/3,http/1.1
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
Advanced approach allows you to implement your own negotiation algorithm.
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
#see below documentation for:
|
|
Net::SSleay::CTX_set_alpn_select_cb($ctx, $perl_callback_function, $callback_data);
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
Detection of <FONT SIZE="-1">ALPN</FONT> support (works even in older Net::SSLeay versions):
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
use Net::SSLeay;
|
|
|
|
if (exists &Net::SSLeay::P_alpn_selected) {
|
|
# do ALPN stuff
|
|
}
|
|
|
|
</PRE>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="611">•<DD>
|
|
CTX_set_alpn_select_cb
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.55 and before; requires at least openssl-1.0.2
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>NOTE:</B></FONT><B></B> You need CTX_set_alpn_select_cb on <B>server side</B> of <FONT SIZE="-1">TLS</FONT> connection.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Simple usage - in this case a ``common'' negotiation algorithm (as implemented by openssl's function SSL_select_next_proto) is used.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
$rv = Net::SSleay::CTX_set_alpn_select_cb($ctx, $arrayref);
|
|
# $ctx - value corresponding to openssl's SSL_CTX structure
|
|
# $arrayref - list of accepted protocols - e.g. ['http/2.0', 'http/1.1', 'spdy/3']
|
|
#
|
|
# returns: 0 on success, 1 on failure
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Advanced usage (you probably do not need this):
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
$rv = Net::SSleay::CTX_set_alpn_select_cb($ctx, $perl_callback_function, $callback_data);
|
|
# $ctx - value corresponding to openssl's SSL_CTX structure
|
|
# $perl_callback_function - reference to perl function
|
|
# $callback_data - [optional] data to passed to callback function when invoked
|
|
#
|
|
# returns: 0 on success, 1 on failure
|
|
|
|
# where callback function looks like
|
|
sub alpn_select_cb_invoke {
|
|
my ($ssl, $arrayref_proto_list_advertised_by_client, $callback_data) = @_;
|
|
# ...
|
|
if ($negotiated) {
|
|
return 'http/2.0';
|
|
} else {
|
|
return undef;
|
|
}
|
|
}
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
To undefine/clear this callback use:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSleay::CTX_set_alpn_select_cb($ctx, undef);
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="612">•<DD>
|
|
set_alpn_protos
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.55 and before; requires at least openssl-1.0.2
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>NOTE:</B></FONT><B></B> You need set_alpn_protos on <B>client side</B> of <FONT SIZE="-1">TLS</FONT> connection.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
This adds list of supported application layer protocols to ClientHello message sent by a client.
|
|
It advertises the enumeration of supported protocols:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::set_alpn_protos($ssl, ['http/1.1', 'http/2.0', 'spdy/3]);
|
|
# returns 0 on success
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="613">•<DD>
|
|
CTX_set_alpn_protos
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.55 and before; requires at least openssl-1.0.2
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>NOTE:</B></FONT><B></B> You need CTX_set_alpn_protos on <B>client side</B> of <FONT SIZE="-1">TLS</FONT> connection.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
This adds list of supported application layer protocols to ClientHello message sent by a client.
|
|
It advertises the enumeration of supported protocols:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::CTX_set_alpn_protos($ctx, ['http/1.1', 'http/2.0', 'spdy/3]);
|
|
# returns 0 on success
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="614">•<DD>
|
|
P_alpn_selected
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> not available in Net-SSLeay-1.55 and before; requires at least openssl-1.0.2
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the name of negotiated protocol for given <FONT SIZE="-1">TLS</FONT> connection <TT>$ssl</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
$rv = Net::SSLeay::P_alpn_selected($ssl)
|
|
# $ssl - value corresponding to openssl's SSL structure
|
|
#
|
|
# returns: (string) negotiated protocol name (or undef if no negotiation was done or failed with fatal error)
|
|
|
|
</PRE>
|
|
|
|
|
|
</DL>
|
|
<P>
|
|
|
|
<I>Low level </I><FONT SIZE="-1"><I>API: DANE</I></FONT><I> Support</I>
|
|
|
|
|
|
<P>
|
|
|
|
OpenSSL version 1.0.2 adds preliminary support <FONT SIZE="-1">RFC6698</FONT> Domain Authentication of
|
|
Named Entities (<FONT SIZE="-1">DANE</FONT>) Transport Layer Association within OpenSSL
|
|
<DL COMPACT>
|
|
<DT id="615">•<DD>
|
|
SSL_get_tlsa_record_byname
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B></B><FONT SIZE="-1"><B>COMPATIBILITY:</B></FONT><B></B> <FONT SIZE="-1">DELETED</FONT> from net-ssleay, since it is not supported by OpenSSL
|
|
|
|
|
|
<P>
|
|
|
|
|
|
In order to facilitate <FONT SIZE="-1">DANE</FONT> there is additional interface,
|
|
SSL_get_tlsa_record_byname, accepting hostname, port and socket type
|
|
that returns packed <FONT SIZE="-1">TLSA</FONT> record. In order to make it even easier there
|
|
is additional SSL_ctrl function that calls SSL_get_tlsa_record_byname
|
|
for you. Latter is recommended for programmers that wish to maintain
|
|
broader binary compatibility, e.g. make application work with both 1.0.2
|
|
and prior version (in which case call to SSL_ctrl with new code
|
|
returning error would have to be ignored when running with prior version).
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Net::SSLeay::get_tlsa_record_byname($name, <TT>$port</TT>, <TT>$type</TT>);
|
|
</DL>
|
|
<P>
|
|
|
|
<I>Low level </I><FONT SIZE="-1"><I>API:</I></FONT><I> Other functions</I>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="616">•<DD>
|
|
COMP_add_compression_method
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Adds the compression method cm with the identifier id to the list of available compression methods.
|
|
This list is globally maintained for all <FONT SIZE="-1">SSL</FONT> operations within this application.
|
|
It cannot be set for specific <FONT SIZE="-1">SSL_CTX</FONT> or <FONT SIZE="-1">SSL</FONT> objects.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $rv = Net::SSLeay::COMP_add_compression_method($id, $cm);
|
|
# $id - (integer) compression method id
|
|
# 0 to 63: methods defined by the IETF
|
|
# 64 to 192: external party methods assigned by IANA
|
|
# 193 to 255: reserved for private use
|
|
#
|
|
# $cm - value corresponding to openssl's COMP_METHOD structure
|
|
#
|
|
# returns: 0 on success, 1 on failure (check the error queue to find out the reason)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/ssl/SSL_COMP_add_compression_method.html">http://www.openssl.org/docs/ssl/SSL_COMP_add_compression_method.html</A>>
|
|
<DT id="617">•<DD>
|
|
DH_free
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Frees the <FONT SIZE="-1">DH</FONT> structure and its components. The values are erased before the memory is returned to the system.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::DH_free($dh);
|
|
# $dh - value corresponding to openssl's DH structure
|
|
#
|
|
# returns: no return value
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Check openssl doc <<A HREF="http://www.openssl.org/docs/crypto/DH_new.html">http://www.openssl.org/docs/crypto/DH_new.html</A>>
|
|
<DT id="618">•<DD>
|
|
FIPS_mode_set
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Enable or disable <FONT SIZE="-1">FIPS</FONT> mode in a <FONT SIZE="-1">FIPS</FONT> capable OpenSSL.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay:: FIPS_mode_set($enable);
|
|
# $enable - (integer) 1 to enable, 0 to disable
|
|
|
|
</PRE>
|
|
|
|
|
|
</DL>
|
|
<P>
|
|
|
|
<I>Low level </I><FONT SIZE="-1"><I>API: EC</I></FONT><I> related functions</I>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="619">•<DD>
|
|
CTX_set_tmp_ecdh
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<FONT SIZE="-1">TBA</FONT>
|
|
<DT id="620">•<DD>
|
|
EC_KEY_free
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<FONT SIZE="-1">TBA</FONT>
|
|
<DT id="621">•<DD>
|
|
EC_KEY_new_by_curve_name
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<FONT SIZE="-1">TBA</FONT>
|
|
<DT id="622">•<DD>
|
|
EC_KEY_generate_key
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Generates a <FONT SIZE="-1">EC</FONT> key and returns it in a newly allocated <FONT SIZE="-1">EC_KEY</FONT> structure.
|
|
The <FONT SIZE="-1">EC</FONT> key then can be used to create a <FONT SIZE="-1">PKEY</FONT> which can be used in calls
|
|
like X509_set_pubkey.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $key = Net::SSLeay::EVP_PKEY_new();
|
|
my $ec = Net::SSLeay::EC_KEY_generate_key($curve);
|
|
Net::SSLeay::EVP_PKEY_assign_EC_KEY($key,$ec);
|
|
|
|
# $curve - curve name like 'secp521r1' or the matching Id (integer) of the curve
|
|
#
|
|
# returns: value corresponding to openssl's EC_KEY structure (0 on failure)
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
This function has no equivalent in OpenSSL but combines multiple OpenSSL
|
|
functions for an easier interface.
|
|
<DT id="623">•<DD>
|
|
CTX_set_ecdh_auto, set_ecdh_auto
|
|
|
|
|
|
<P>
|
|
|
|
|
|
These functions enable or disable the automatic curve selection on the server
|
|
side by calling SSL_CTX_set_ecdh_auto or SSL_set_ecdh_auto respectively.
|
|
If enabled the highest preference curve is automatically used for <FONT SIZE="-1">ECDH</FONT> temporary
|
|
keys used during key exchange.
|
|
This function is no longer available for OpenSSL 1.1.0 or higher.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::CTX_set_ecdh_auto($ctx,1);
|
|
Net::SSLeay::set_ecdh_auto($ssl,1);
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="624">•<DD>
|
|
CTX_set1_curves_list, set1_curves_list
|
|
|
|
|
|
<P>
|
|
|
|
|
|
These functions set the supported curves (in order of preference) by calling
|
|
SSL_CTX_set1_curves_list or SSL_set1_curves_list respectively.
|
|
For a <FONT SIZE="-1">TLS</FONT> client these curves are offered to the server in the supported curves
|
|
extension while on the server side these are used to determine the shared
|
|
curve.
|
|
These functions are only available since OpenSSL 1.1.0.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::CTX_set1_curves_list($ctx,"P-521:P-384:P-256");
|
|
Net::SSLeay::set1_curves_list($ssl,"P-521:P-384:P-256");
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="625">•<DD>
|
|
CTX_set1_groups_list, set1_groups_list
|
|
|
|
|
|
<P>
|
|
|
|
|
|
These functions set the supported groups (in order of preference) by calling
|
|
SSL_CTX_set1_groups_list or SSL_set1_groups_list respectively.
|
|
This is practically the same as CTX_set1_curves_list and set1_curves_list except
|
|
that all <FONT SIZE="-1">DH</FONT> groups can be given as supported by <FONT SIZE="-1">TLS 1.3.</FONT>
|
|
These functions are only available since OpenSSL 1.1.1.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::CTX_set1_groups_list($ctx,"P-521:P-384:P-256");
|
|
Net::SSLeay::set1_groups_list($ssl,"P-521:P-384:P-256");
|
|
|
|
</PRE>
|
|
|
|
|
|
</DL>
|
|
<A NAME="lbAO"> </A>
|
|
<H3>Constants</H3>
|
|
|
|
|
|
|
|
There are many openssl constants available in Net::SSLeay. You can use them like this:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
use Net::SSLeay;
|
|
print &Net::SSLeay::NID_commonName;
|
|
#or
|
|
print Net::SSLeay::NID_commonName();
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
Or you can import them and use:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
use Net::SSLeay qw/NID_commonName/;
|
|
print &NID_commonName;
|
|
#or
|
|
print NID_commonName();
|
|
#or
|
|
print NID_commonName;
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
The constants names are derived from openssl constants, however constants starting with <TT>"SSL_"</TT> prefix
|
|
have name with <TT>"SSL_"</TT> part stripped - e.g. openssl's constant <TT>"SSL_OP_ALL"</TT> is available as <TT>"Net::SSleay::OP_ALL"</TT>
|
|
<P>
|
|
|
|
The list of all available constant names:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
ASN1_STRFLGS_ESC_CTRL NID_netscape R_UNKNOWN_REMOTE_ERROR_TYPE
|
|
ASN1_STRFLGS_ESC_MSB NID_netscape_base_url R_UNKNOWN_STATE
|
|
ASN1_STRFLGS_ESC_QUOTE NID_netscape_ca_policy_url R_X509_LIB
|
|
ASN1_STRFLGS_RFC2253 NID_netscape_ca_revocation_url SENT_SHUTDOWN
|
|
CB_ACCEPT_EXIT NID_netscape_cert_extension SESSION_ASN1_VERSION
|
|
CB_ACCEPT_LOOP NID_netscape_cert_sequence SESS_CACHE_BOTH
|
|
CB_ALERT NID_netscape_cert_type SESS_CACHE_CLIENT
|
|
CB_CONNECT_EXIT NID_netscape_comment SESS_CACHE_NO_AUTO_CLEAR
|
|
CB_CONNECT_LOOP NID_netscape_data_type SESS_CACHE_NO_INTERNAL
|
|
CB_EXIT NID_netscape_renewal_url SESS_CACHE_NO_INTERNAL_LOOKUP
|
|
CB_HANDSHAKE_DONE NID_netscape_revocation_url SESS_CACHE_NO_INTERNAL_STORE
|
|
CB_HANDSHAKE_START NID_netscape_ssl_server_name SESS_CACHE_OFF
|
|
CB_LOOP NID_ns_sgc SESS_CACHE_SERVER
|
|
CB_READ NID_organizationName SSL3_VERSION
|
|
CB_READ_ALERT NID_organizationalUnitName SSLEAY_BUILT_ON
|
|
CB_WRITE NID_pbeWithMD2AndDES_CBC SSLEAY_CFLAGS
|
|
CB_WRITE_ALERT NID_pbeWithMD2AndRC2_CBC SSLEAY_DIR
|
|
ERROR_NONE NID_pbeWithMD5AndCast5_CBC SSLEAY_PLATFORM
|
|
ERROR_SSL NID_pbeWithMD5AndDES_CBC SSLEAY_VERSION
|
|
ERROR_SYSCALL NID_pbeWithMD5AndRC2_CBC ST_ACCEPT
|
|
ERROR_WANT_ACCEPT NID_pbeWithSHA1AndDES_CBC ST_BEFORE
|
|
ERROR_WANT_CONNECT NID_pbeWithSHA1AndRC2_CBC ST_CONNECT
|
|
ERROR_WANT_READ NID_pbe_WithSHA1And128BitRC2_CBC ST_INIT
|
|
ERROR_WANT_WRITE NID_pbe_WithSHA1And128BitRC4 ST_OK
|
|
ERROR_WANT_X509_LOOKUP NID_pbe_WithSHA1And2_Key_TripleDES_CBC ST_READ_BODY
|
|
ERROR_ZERO_RETURN NID_pbe_WithSHA1And3_Key_TripleDES_CBC ST_READ_HEADER
|
|
EVP_PKS_DSA NID_pbe_WithSHA1And40BitRC2_CBC TLS1_1_VERSION
|
|
EVP_PKS_EC NID_pbe_WithSHA1And40BitRC4 TLS1_2_VERSION
|
|
EVP_PKS_RSA NID_pbes2 TLS1_3_VERSION
|
|
EVP_PKT_ENC NID_pbmac1 TLS1_VERSION
|
|
EVP_PKT_EXCH NID_pkcs TLSEXT_STATUSTYPE_ocsp
|
|
EVP_PKT_EXP NID_pkcs3 VERIFY_CLIENT_ONCE
|
|
EVP_PKT_SIGN NID_pkcs7 VERIFY_FAIL_IF_NO_PEER_CERT
|
|
EVP_PK_DH NID_pkcs7_data VERIFY_NONE
|
|
EVP_PK_DSA NID_pkcs7_digest VERIFY_PEER
|
|
EVP_PK_EC NID_pkcs7_encrypted VERIFY_POST_HANDSHAKE
|
|
EVP_PK_RSA NID_pkcs7_enveloped V_OCSP_CERTSTATUS_GOOD
|
|
FILETYPE_ASN1 NID_pkcs7_signed V_OCSP_CERTSTATUS_REVOKED
|
|
FILETYPE_PEM NID_pkcs7_signedAndEnveloped V_OCSP_CERTSTATUS_UNKNOWN
|
|
F_CLIENT_CERTIFICATE NID_pkcs8ShroudedKeyBag WRITING
|
|
F_CLIENT_HELLO NID_pkcs9 X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT
|
|
F_CLIENT_MASTER_KEY NID_pkcs9_challengePassword X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS
|
|
F_D2I_SSL_SESSION NID_pkcs9_contentType X509_CHECK_FLAG_NEVER_CHECK_SUBJECT
|
|
F_GET_CLIENT_FINISHED NID_pkcs9_countersignature X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS
|
|
F_GET_CLIENT_HELLO NID_pkcs9_emailAddress X509_CHECK_FLAG_NO_WILDCARDS
|
|
F_GET_CLIENT_MASTER_KEY NID_pkcs9_extCertAttributes X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS
|
|
F_GET_SERVER_FINISHED NID_pkcs9_messageDigest X509_FILETYPE_ASN1
|
|
F_GET_SERVER_HELLO NID_pkcs9_signingTime X509_FILETYPE_DEFAULT
|
|
F_GET_SERVER_VERIFY NID_pkcs9_unstructuredAddress X509_FILETYPE_PEM
|
|
F_I2D_SSL_SESSION NID_pkcs9_unstructuredName X509_LOOKUP
|
|
F_READ_N NID_private_key_usage_period X509_PURPOSE_ANY
|
|
F_REQUEST_CERTIFICATE NID_rc2_40_cbc X509_PURPOSE_CRL_SIGN
|
|
F_SERVER_HELLO NID_rc2_64_cbc X509_PURPOSE_NS_SSL_SERVER
|
|
F_SSL_CERT_NEW NID_rc2_cbc X509_PURPOSE_OCSP_HELPER
|
|
F_SSL_GET_NEW_SESSION NID_rc2_cfb64 X509_PURPOSE_SMIME_ENCRYPT
|
|
F_SSL_NEW NID_rc2_ecb X509_PURPOSE_SMIME_SIGN
|
|
F_SSL_READ NID_rc2_ofb64 X509_PURPOSE_SSL_CLIENT
|
|
F_SSL_RSA_PRIVATE_DECRYPT NID_rc4 X509_PURPOSE_SSL_SERVER
|
|
F_SSL_RSA_PUBLIC_ENCRYPT NID_rc4_40 X509_PURPOSE_TIMESTAMP_SIGN
|
|
F_SSL_SESSION_NEW NID_rc5_cbc X509_TRUST_COMPAT
|
|
F_SSL_SESSION_PRINT_FP NID_rc5_cfb64 X509_TRUST_EMAIL
|
|
F_SSL_SET_FD NID_rc5_ecb X509_TRUST_OBJECT_SIGN
|
|
F_SSL_SET_RFD NID_rc5_ofb64 X509_TRUST_OCSP_REQUEST
|
|
F_SSL_SET_WFD NID_ripemd160 X509_TRUST_OCSP_SIGN
|
|
F_SSL_USE_CERTIFICATE NID_ripemd160WithRSA X509_TRUST_SSL_CLIENT
|
|
F_SSL_USE_CERTIFICATE_ASN1 NID_rle_compression X509_TRUST_SSL_SERVER
|
|
F_SSL_USE_CERTIFICATE_FILE NID_rsa X509_TRUST_TSA
|
|
F_SSL_USE_PRIVATEKEY NID_rsaEncryption X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH
|
|
F_SSL_USE_PRIVATEKEY_ASN1 NID_rsadsi X509_V_ERR_AKID_SKID_MISMATCH
|
|
F_SSL_USE_PRIVATEKEY_FILE NID_safeContentsBag X509_V_ERR_APPLICATION_VERIFICATION
|
|
F_SSL_USE_RSAPRIVATEKEY NID_sdsiCertificate X509_V_ERR_CA_KEY_TOO_SMALL
|
|
F_SSL_USE_RSAPRIVATEKEY_ASN1 NID_secretBag X509_V_ERR_CA_MD_TOO_WEAK
|
|
F_SSL_USE_RSAPRIVATEKEY_FILE NID_serialNumber X509_V_ERR_CERT_CHAIN_TOO_LONG
|
|
F_WRITE_PENDING NID_server_auth X509_V_ERR_CERT_HAS_EXPIRED
|
|
GEN_DIRNAME NID_sha X509_V_ERR_CERT_NOT_YET_VALID
|
|
GEN_DNS NID_sha1 X509_V_ERR_CERT_REJECTED
|
|
GEN_EDIPARTY NID_sha1WithRSA X509_V_ERR_CERT_REVOKED
|
|
GEN_EMAIL NID_sha1WithRSAEncryption X509_V_ERR_CERT_SIGNATURE_FAILURE
|
|
GEN_IPADD NID_shaWithRSAEncryption X509_V_ERR_CERT_UNTRUSTED
|
|
GEN_OTHERNAME NID_stateOrProvinceName X509_V_ERR_CRL_HAS_EXPIRED
|
|
GEN_RID NID_subject_alt_name X509_V_ERR_CRL_NOT_YET_VALID
|
|
GEN_URI NID_subject_key_identifier X509_V_ERR_CRL_PATH_VALIDATION_ERROR
|
|
GEN_X400 NID_surname X509_V_ERR_CRL_SIGNATURE_FAILURE
|
|
LIBRESSL_VERSION_NUMBER NID_sxnet X509_V_ERR_DANE_NO_MATCH
|
|
MBSTRING_ASC NID_time_stamp X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT
|
|
MBSTRING_BMP NID_title X509_V_ERR_DIFFERENT_CRL_SCOPE
|
|
MBSTRING_FLAG NID_undef X509_V_ERR_EE_KEY_TOO_SMALL
|
|
MBSTRING_UNIV NID_uniqueIdentifier X509_V_ERR_EMAIL_MISMATCH
|
|
MBSTRING_UTF8 NID_x509Certificate X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD
|
|
MIN_RSA_MODULUS_LENGTH_IN_BYTES NID_x509Crl X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD
|
|
MODE_ACCEPT_MOVING_WRITE_BUFFER NID_zlib_compression X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD
|
|
MODE_AUTO_RETRY NOTHING X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD
|
|
MODE_ENABLE_PARTIAL_WRITE OCSP_RESPONSE_STATUS_INTERNALERROR X509_V_ERR_EXCLUDED_VIOLATION
|
|
MODE_RELEASE_BUFFERS OCSP_RESPONSE_STATUS_MALFORMEDREQUEST X509_V_ERR_HOSTNAME_MISMATCH
|
|
NID_OCSP_sign OCSP_RESPONSE_STATUS_SIGREQUIRED X509_V_ERR_INVALID_CA
|
|
NID_SMIMECapabilities OCSP_RESPONSE_STATUS_SUCCESSFUL X509_V_ERR_INVALID_CALL
|
|
NID_X500 OCSP_RESPONSE_STATUS_TRYLATER X509_V_ERR_INVALID_EXTENSION
|
|
NID_X509 OCSP_RESPONSE_STATUS_UNAUTHORIZED X509_V_ERR_INVALID_NON_CA
|
|
NID_ad_OCSP OPENSSL_BUILT_ON X509_V_ERR_INVALID_POLICY_EXTENSION
|
|
NID_ad_ca_issuers OPENSSL_CFLAGS X509_V_ERR_INVALID_PURPOSE
|
|
NID_algorithm OPENSSL_DIR X509_V_ERR_IP_ADDRESS_MISMATCH
|
|
NID_authority_key_identifier OPENSSL_ENGINES_DIR X509_V_ERR_KEYUSAGE_NO_CERTSIGN
|
|
NID_basic_constraints OPENSSL_PLATFORM X509_V_ERR_KEYUSAGE_NO_CRL_SIGN
|
|
NID_bf_cbc OPENSSL_VERSION X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE
|
|
NID_bf_cfb64 OPENSSL_VERSION_NUMBER X509_V_ERR_NO_EXPLICIT_POLICY
|
|
NID_bf_ecb OP_ALL X509_V_ERR_NO_VALID_SCTS
|
|
NID_bf_ofb64 OP_ALLOW_NO_DHE_KEX X509_V_ERR_OCSP_CERT_UNKNOWN
|
|
NID_cast5_cbc OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION X509_V_ERR_OCSP_VERIFY_FAILED
|
|
NID_cast5_cfb64 OP_CIPHER_SERVER_PREFERENCE X509_V_ERR_OCSP_VERIFY_NEEDED
|
|
NID_cast5_ecb OP_CISCO_ANYCONNECT X509_V_ERR_OUT_OF_MEM
|
|
NID_cast5_ofb64 OP_COOKIE_EXCHANGE X509_V_ERR_PATH_LENGTH_EXCEEDED
|
|
NID_certBag OP_CRYPTOPRO_TLSEXT_BUG X509_V_ERR_PATH_LOOP
|
|
NID_certificate_policies OP_DONT_INSERT_EMPTY_FRAGMENTS X509_V_ERR_PERMITTED_VIOLATION
|
|
NID_client_auth OP_ENABLE_MIDDLEBOX_COMPAT X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED
|
|
NID_code_sign OP_EPHEMERAL_RSA X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED
|
|
NID_commonName OP_LEGACY_SERVER_CONNECT X509_V_ERR_PROXY_SUBJECT_NAME_VIOLATION
|
|
NID_countryName OP_MICROSOFT_BIG_SSLV3_BUFFER X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN
|
|
NID_crlBag OP_MICROSOFT_SESS_ID_BUG X509_V_ERR_STORE_LOOKUP
|
|
NID_crl_distribution_points OP_MSIE_SSLV2_RSA_PADDING X509_V_ERR_SUBJECT_ISSUER_MISMATCH
|
|
NID_crl_number OP_NETSCAPE_CA_DN_BUG X509_V_ERR_SUBTREE_MINMAX
|
|
NID_crl_reason OP_NETSCAPE_CHALLENGE_BUG X509_V_ERR_SUITE_B_CANNOT_SIGN_P_384_WITH_P_256
|
|
NID_delta_crl OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG X509_V_ERR_SUITE_B_INVALID_ALGORITHM
|
|
NID_des_cbc OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG X509_V_ERR_SUITE_B_INVALID_CURVE
|
|
NID_des_cfb64 OP_NON_EXPORT_FIRST X509_V_ERR_SUITE_B_INVALID_SIGNATURE_ALGORITHM
|
|
NID_des_ecb OP_NO_ANTI_REPLAY X509_V_ERR_SUITE_B_INVALID_VERSION
|
|
NID_des_ede OP_NO_CLIENT_RENEGOTIATION X509_V_ERR_SUITE_B_LOS_NOT_ALLOWED
|
|
NID_des_ede3 OP_NO_COMPRESSION X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY
|
|
NID_des_ede3_cbc OP_NO_ENCRYPT_THEN_MAC X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE
|
|
NID_des_ede3_cfb64 OP_NO_QUERY_MTU X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE
|
|
NID_des_ede3_ofb64 OP_NO_RENEGOTIATION X509_V_ERR_UNABLE_TO_GET_CRL
|
|
NID_des_ede_cbc OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER
|
|
NID_des_ede_cfb64 OP_NO_SSL_MASK X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT
|
|
NID_des_ede_ofb64 OP_NO_SSLv2 X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY
|
|
NID_des_ofb64 OP_NO_SSLv3 X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE
|
|
NID_description OP_NO_TICKET X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION
|
|
NID_desx_cbc OP_NO_TLSv1 X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION
|
|
NID_dhKeyAgreement OP_NO_TLSv1_1 X509_V_ERR_UNNESTED_RESOURCE
|
|
NID_dnQualifier OP_NO_TLSv1_2 X509_V_ERR_UNSPECIFIED
|
|
NID_dsa OP_NO_TLSv1_3 X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX
|
|
NID_dsaWithSHA OP_PKCS1_CHECK_1 X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE
|
|
NID_dsaWithSHA1 OP_PKCS1_CHECK_2 X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE
|
|
NID_dsaWithSHA1_2 OP_PRIORITIZE_CHACHA X509_V_ERR_UNSUPPORTED_NAME_SYNTAX
|
|
NID_dsa_2 OP_SAFARI_ECDHE_ECDSA_BUG X509_V_FLAG_ALLOW_PROXY_CERTS
|
|
NID_email_protect OP_SINGLE_DH_USE X509_V_FLAG_CB_ISSUER_CHECK
|
|
NID_ext_key_usage OP_SINGLE_ECDH_USE X509_V_FLAG_CHECK_SS_SIGNATURE
|
|
NID_ext_req OP_SSLEAY_080_CLIENT_DH_BUG X509_V_FLAG_CRL_CHECK
|
|
NID_friendlyName OP_SSLREF2_REUSE_CERT_TYPE_BUG X509_V_FLAG_CRL_CHECK_ALL
|
|
NID_givenName OP_TLSEXT_PADDING X509_V_FLAG_EXPLICIT_POLICY
|
|
NID_hmacWithSHA1 OP_TLS_BLOCK_PADDING_BUG X509_V_FLAG_EXTENDED_CRL_SUPPORT
|
|
NID_id_ad OP_TLS_D5_BUG X509_V_FLAG_IGNORE_CRITICAL
|
|
NID_id_ce OP_TLS_ROLLBACK_BUG X509_V_FLAG_INHIBIT_ANY
|
|
NID_id_kp READING X509_V_FLAG_INHIBIT_MAP
|
|
NID_id_pbkdf2 RECEIVED_SHUTDOWN X509_V_FLAG_NOTIFY_POLICY
|
|
NID_id_pe RSA_3 X509_V_FLAG_NO_ALT_CHAINS
|
|
NID_id_pkix RSA_F4 X509_V_FLAG_NO_CHECK_TIME
|
|
NID_id_qt_cps R_BAD_AUTHENTICATION_TYPE X509_V_FLAG_PARTIAL_CHAIN
|
|
NID_id_qt_unotice R_BAD_CHECKSUM X509_V_FLAG_POLICY_CHECK
|
|
NID_idea_cbc R_BAD_MAC_DECODE X509_V_FLAG_POLICY_MASK
|
|
NID_idea_cfb64 R_BAD_RESPONSE_ARGUMENT X509_V_FLAG_SUITEB_128_LOS
|
|
NID_idea_ecb R_BAD_SSL_FILETYPE X509_V_FLAG_SUITEB_128_LOS_ONLY
|
|
NID_idea_ofb64 R_BAD_SSL_SESSION_ID_LENGTH X509_V_FLAG_SUITEB_192_LOS
|
|
NID_info_access R_BAD_STATE X509_V_FLAG_TRUSTED_FIRST
|
|
NID_initials R_BAD_WRITE_RETRY X509_V_FLAG_USE_CHECK_TIME
|
|
NID_invalidity_date R_CHALLENGE_IS_DIFFERENT X509_V_FLAG_USE_DELTAS
|
|
NID_issuer_alt_name R_CIPHER_TABLE_SRC_ERROR X509_V_FLAG_X509_STRICT
|
|
NID_keyBag R_INVALID_CHALLENGE_LENGTH X509_V_OK
|
|
NID_key_usage R_NO_CERTIFICATE_SET XN_FLAG_COMPAT
|
|
NID_localKeyID R_NO_CERTIFICATE_SPECIFIED XN_FLAG_DN_REV
|
|
NID_localityName R_NO_CIPHER_LIST XN_FLAG_DUMP_UNKNOWN_FIELDS
|
|
NID_md2 R_NO_CIPHER_MATCH XN_FLAG_FN_ALIGN
|
|
NID_md2WithRSAEncryption R_NO_PRIVATEKEY XN_FLAG_FN_LN
|
|
NID_md5 R_NO_PUBLICKEY XN_FLAG_FN_MASK
|
|
NID_md5WithRSA R_NULL_SSL_CTX XN_FLAG_FN_NONE
|
|
NID_md5WithRSAEncryption R_PEER_DID_NOT_RETURN_A_CERTIFICATE XN_FLAG_FN_OID
|
|
NID_md5_sha1 R_PEER_ERROR XN_FLAG_FN_SN
|
|
NID_mdc2 R_PEER_ERROR_CERTIFICATE XN_FLAG_MULTILINE
|
|
NID_mdc2WithRSA R_PEER_ERROR_NO_CIPHER XN_FLAG_ONELINE
|
|
NID_ms_code_com R_PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE XN_FLAG_RFC2253
|
|
NID_ms_code_ind R_PUBLIC_KEY_ENCRYPT_ERROR XN_FLAG_SEP_COMMA_PLUS
|
|
NID_ms_ctl_sign R_PUBLIC_KEY_IS_NOT_RSA XN_FLAG_SEP_CPLUS_SPC
|
|
NID_ms_efs R_READ_WRONG_PACKET_TYPE XN_FLAG_SEP_MASK
|
|
NID_ms_ext_req R_SHORT_READ XN_FLAG_SEP_MULTILINE
|
|
NID_ms_sgc R_SSL_SESSION_ID_IS_DIFFERENT XN_FLAG_SEP_SPLUS_SPC
|
|
NID_name R_UNABLE_TO_EXTRACT_PUBLIC_KEY XN_FLAG_SPC_EQ
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAP"> </A>
|
|
<H3><FONT SIZE="-1">INTERNAL ONLY</FONT> functions (do not use these)</H3>
|
|
|
|
|
|
|
|
The following functions are not intended for use from outside of Net::SSLeay module.
|
|
They might be removed, renamed or changed without prior notice in future version.
|
|
<P>
|
|
|
|
Simply <B></B><FONT SIZE="-1"><B>DO NOT USE THEM</B></FONT><B></B>!
|
|
<DL COMPACT>
|
|
<DT id="626">•<DD>
|
|
hello
|
|
<DT id="627">•<DD>
|
|
blength
|
|
<DT id="628">•<DD>
|
|
constant
|
|
</DL>
|
|
<A NAME="lbAQ"> </A>
|
|
<H2>EXAMPLES</H2>
|
|
|
|
|
|
|
|
One very good example to look at is the implementation of <TT>"sslcat()"</TT> in the
|
|
<TT>"SSLeay.pm"</TT> file.
|
|
<P>
|
|
|
|
The following is a simple SSLeay client (with too little error checking :-(
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
#!/usr/bin/perl
|
|
use Socket;
|
|
use Net::SSLeay qw(die_now die_if_ssl_error) ;
|
|
Net::SSLeay::load_error_strings();
|
|
Net::SSLeay::SSLeay_add_ssl_algorithms();
|
|
Net::SSLeay::randomize();
|
|
|
|
($dest_serv, $port, $msg) = @ARGV; # Read command line
|
|
$port = getservbyname ($port, 'tcp') unless $port =~ /^\d+$/;
|
|
$dest_ip = gethostbyname ($dest_serv);
|
|
$dest_serv_params = sockaddr_in($port, $dest_ip);
|
|
|
|
socket (S, &AF_INET, &SOCK_STREAM, 0) or die "socket: $!";
|
|
connect (S, $dest_serv_params) or die "connect: $!";
|
|
select (S); $| = 1; select (STDOUT); # Eliminate STDIO buffering
|
|
|
|
# The network connection is now open, lets fire up SSL
|
|
|
|
$ctx = Net::SSLeay::CTX_new() or die_now("Failed to create SSL_CTX $!");
|
|
Net::SSLeay::CTX_set_options($ctx, &Net::SSLeay::OP_ALL)
|
|
or die_if_ssl_error("ssl ctx set options");
|
|
$ssl = Net::SSLeay::new($ctx) or die_now("Failed to create SSL $!");
|
|
Net::SSLeay::set_fd($ssl, fileno(S)); # Must use fileno
|
|
$res = Net::SSLeay::connect($ssl) and die_if_ssl_error("ssl connect");
|
|
print "Cipher `" . Net::SSLeay::get_cipher($ssl) . "'\n";
|
|
|
|
# Exchange data
|
|
|
|
$res = Net::SSLeay::write($ssl, $msg); # Perl knows how long $msg is
|
|
die_if_ssl_error("ssl write");
|
|
CORE::shutdown S, 1; # Half close --> No more output, sends EOF to server
|
|
$got = Net::SSLeay::read($ssl); # Perl returns undef on failure
|
|
die_if_ssl_error("ssl read");
|
|
print $got;
|
|
|
|
Net::SSLeay::free ($ssl); # Tear down connection
|
|
Net::SSLeay::CTX_free ($ctx);
|
|
close S;
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
The following is a simple SSLeay echo server (non forking):
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
#!/usr/bin/perl -w
|
|
use Socket;
|
|
use Net::SSLeay qw(die_now die_if_ssl_error);
|
|
Net::SSLeay::load_error_strings();
|
|
Net::SSLeay::SSLeay_add_ssl_algorithms();
|
|
Net::SSLeay::randomize();
|
|
|
|
$our_ip = "\0\0\0\0"; # Bind to all interfaces
|
|
$port = 1235;
|
|
$sockaddr_template = 'S n a4 x8';
|
|
$our_serv_params = pack ($sockaddr_template, &AF_INET, $port, $our_ip);
|
|
|
|
socket (S, &AF_INET, &SOCK_STREAM, 0) or die "socket: $!";
|
|
bind (S, $our_serv_params) or die "bind: $!";
|
|
listen (S, 5) or die "listen: $!";
|
|
$ctx = Net::SSLeay::CTX_new () or die_now("CTX_new ($ctx): $!");
|
|
Net::SSLeay::CTX_set_options($ctx, &Net::SSLeay::OP_ALL)
|
|
or die_if_ssl_error("ssl ctx set options");
|
|
|
|
# Following will ask password unless private key is not encrypted
|
|
Net::SSLeay::CTX_use_RSAPrivateKey_file ($ctx, 'plain-rsa.pem',
|
|
&Net::SSLeay::FILETYPE_PEM);
|
|
die_if_ssl_error("private key");
|
|
Net::SSLeay::CTX_use_certificate_file ($ctx, 'plain-cert.pem',
|
|
&Net::SSLeay::FILETYPE_PEM);
|
|
die_if_ssl_error("certificate");
|
|
|
|
while (1) {
|
|
print "Accepting connections...\n";
|
|
($addr = accept (NS, S)) or die "accept: $!";
|
|
select (NS); $| = 1; select (STDOUT); # Piping hot!
|
|
|
|
($af,$client_port,$client_ip) = unpack($sockaddr_template,$addr);
|
|
@inetaddr = unpack('C4',$client_ip);
|
|
print "$af connection from " .
|
|
join ('.', @inetaddr) . ":$client_port\n";
|
|
|
|
# We now have a network connection, lets fire up SSLeay...
|
|
|
|
$ssl = Net::SSLeay::new($ctx) or die_now("SSL_new ($ssl): $!");
|
|
Net::SSLeay::set_fd($ssl, fileno(NS));
|
|
|
|
$err = Net::SSLeay::accept($ssl) and die_if_ssl_error('ssl accept');
|
|
print "Cipher `" . Net::SSLeay::get_cipher($ssl) . "'\n";
|
|
|
|
# Connected. Exchange some data.
|
|
|
|
$got = Net::SSLeay::read($ssl); # Returns undef on fail
|
|
die_if_ssl_error("ssl read");
|
|
print "Got `$got' (" . length ($got) . " chars)\n";
|
|
|
|
Net::SSLeay::write ($ssl, uc ($got)) or die "write: $!";
|
|
die_if_ssl_error("ssl write");
|
|
|
|
Net::SSLeay::free ($ssl); # Tear down connection
|
|
close NS;
|
|
}
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
Yet another echo server. This one runs from <TT>"/etc/inetd.conf"</TT> so it avoids
|
|
all the socket code overhead. Only caveat is opening an rsa key file -
|
|
it had better be without any encryption or else it will not know where
|
|
to ask for the password. Note how <TT>"STDIN"</TT> and <TT>"STDOUT"</TT> are wired to <FONT SIZE="-1">SSL.</FONT>
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
#!/usr/bin/perl
|
|
# /etc/inetd.conf
|
|
# ssltst stream tcp nowait root /path/to/server.pl server.pl
|
|
# /etc/services
|
|
# ssltst 1234/tcp
|
|
|
|
use Net::SSLeay qw(die_now die_if_ssl_error);
|
|
Net::SSLeay::load_error_strings();
|
|
Net::SSLeay::SSLeay_add_ssl_algorithms();
|
|
Net::SSLeay::randomize();
|
|
|
|
chdir '/key/dir' or die "chdir: $!";
|
|
$| = 1; # Piping hot!
|
|
open LOG, ">>/dev/console" or die "Can't open log file $!";
|
|
select LOG; print "server.pl started\n";
|
|
|
|
$ctx = Net::SSLeay::CTX_new() or die_now "CTX_new ($ctx) ($!)";
|
|
$ssl = Net::SSLeay::new($ctx) or die_now "new ($ssl) ($!)";
|
|
Net::SSLeay::set_options($ssl, &Net::SSLeay::OP_ALL)
|
|
and die_if_ssl_error("ssl set options");
|
|
|
|
# We get already open network connection from inetd, now we just
|
|
# need to attach SSLeay to STDIN and STDOUT
|
|
Net::SSLeay::set_rfd($ssl, fileno(STDIN));
|
|
Net::SSLeay::set_wfd($ssl, fileno(STDOUT));
|
|
|
|
Net::SSLeay::use_RSAPrivateKey_file ($ssl, 'plain-rsa.pem',
|
|
Net::SSLeay::FILETYPE_PEM);
|
|
die_if_ssl_error("private key");
|
|
Net::SSLeay::use_certificate_file ($ssl, 'plain-cert.pem',
|
|
Net::SSLeay::FILETYPE_PEM);
|
|
die_if_ssl_error("certificate");
|
|
|
|
Net::SSLeay::accept($ssl) and die_if_ssl_err("ssl accept: $!");
|
|
print "Cipher `" . Net::SSLeay::get_cipher($ssl) . "'\n";
|
|
|
|
$got = Net::SSLeay::read($ssl);
|
|
die_if_ssl_error("ssl read");
|
|
print "Got `$got' (" . length ($got) . " chars)\n";
|
|
|
|
Net::SSLeay::write ($ssl, uc($got)) or die "write: $!";
|
|
die_if_ssl_error("ssl write");
|
|
|
|
Net::SSLeay::free ($ssl); # Tear down the connection
|
|
Net::SSLeay::CTX_free ($ctx);
|
|
close LOG;
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
There are also a number of example/test programs in the examples directory:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
sslecho.pl - A simple server, not unlike the one above
|
|
minicli.pl - Implements a client using low level SSLeay routines
|
|
sslcat.pl - Demonstrates using high level sslcat utility function
|
|
get_page.pl - Is a utility for getting html pages from secure servers
|
|
callback.pl - Demonstrates certificate verification and callback usage
|
|
stdio_bulk.pl - Does SSL over Unix pipes
|
|
ssl-inetd-serv.pl - SSL server that can be invoked from inetd.conf
|
|
httpd-proxy-snif.pl - Utility that allows you to see how a browser
|
|
sends https request to given server and what reply
|
|
it gets back (very educative :-)
|
|
makecert.pl - Creates a self signed cert (does not use this module)
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAR"> </A>
|
|
<H2>INSTALLATION</H2>
|
|
|
|
|
|
|
|
See <FONT SIZE="-1">README</FONT> and <FONT SIZE="-1">README</FONT>.* in the distribution directory for installation guidance on a variety of platforms.
|
|
<A NAME="lbAS"> </A>
|
|
<H2>LIMITATIONS</H2>
|
|
|
|
|
|
|
|
<TT>"Net::SSLeay::read()"</TT> uses an internal buffer of 32KB, thus no single read
|
|
will return more. In practice one read returns much less, usually
|
|
as much as fits in one network packet. To work around this,
|
|
you should use a loop like this:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
$reply = '';
|
|
while ($got = Net::SSLeay::read($ssl)) {
|
|
last if print_errs('SSL_read');
|
|
$reply .= $got;
|
|
}
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
Although there is no built-in limit in <TT>"Net::SSLeay::write()"</TT>, the network
|
|
packet size limitation applies here as well, thus use:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
$written = 0;
|
|
|
|
while ($written < length($message)) {
|
|
$written += Net::SSLeay::write($ssl, substr($message, $written));
|
|
last if print_errs('SSL_write');
|
|
}
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
Or alternatively you can just use the following convenience functions:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::ssl_write_all($ssl, $message) or die "ssl write failure";
|
|
$got = Net::SSLeay::ssl_read_all($ssl) or die "ssl read failure";
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAT"> </A>
|
|
<H2>KNOWN BUGS AND CAVEATS</H2>
|
|
|
|
|
|
|
|
An OpenSSL bug <FONT SIZE="-1">CVE-2015-0290</FONT> ``OpenSSL Multiblock Corrupted Pointer Issue''
|
|
can cause <FONT SIZE="-1">POST</FONT> requests of over 90kB to fail or crash. This bug is reported to be fixed in
|
|
OpenSSL 1.0.2a.
|
|
<P>
|
|
|
|
Autoloader emits a
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
Argument "xxx" isn't numeric in entersub at blib/lib/Net/SSLeay.pm'
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
warning if die_if_ssl_error is made autoloadable. If you figure out why,
|
|
drop me a line.
|
|
<P>
|
|
|
|
Callback set using <TT>"SSL_set_verify()"</TT> does not appear to work. This may
|
|
well be an openssl problem (e.g. see <TT>"ssl/ssl_lib.c"</TT> line 1029). Try using
|
|
<TT>"SSL_CTX_set_verify()"</TT> instead and do not be surprised if even this stops
|
|
working in future versions.
|
|
<P>
|
|
|
|
Callback and certificate verification stuff is generally too little tested.
|
|
<P>
|
|
|
|
Random numbers are not initialized randomly enough, especially if you
|
|
do not have <TT>"/dev/random"</TT> and/or <TT>"/dev/urandom"</TT> (such as in Solaris
|
|
platforms - but it's been suggested that cryptorand daemon from the SUNski
|
|
package solves this). In this case you should investigate third party
|
|
software that can emulate these devices, e.g. by way of a named pipe
|
|
to some program.
|
|
<P>
|
|
|
|
Another gotcha with random number initialization is randomness
|
|
depletion. This phenomenon, which has been extensively discussed in
|
|
OpenSSL, Apache-SSL, and Apache-mod_ssl forums, can cause your
|
|
script to block if you use <TT>"/dev/random"</TT> or to operate insecurely
|
|
if you use <TT>"/dev/urandom"</TT>. What happens is that when too much
|
|
randomness is drawn from the operating system's randomness pool
|
|
then randomness can temporarily be unavailable. <TT>"/dev/random"</TT> solves
|
|
this problem by waiting until enough randomness can be gathered - and
|
|
this can take a long time since blocking reduces activity in the
|
|
machine and less activity provides less random events: a vicious circle.
|
|
<TT>"/dev/urandom"</TT> solves this dilemma more pragmatically by simply returning
|
|
predictable ``random'' numbers. Some<TT>" /dev/urandom"</TT> emulation software
|
|
however actually seems to implement <TT>"/dev/random"</TT> semantics. Caveat emptor.
|
|
<P>
|
|
|
|
I've been pointed to two such daemons by Mik Firestone <mik@@speed.stdio._com>
|
|
who has used them on Solaris 8:
|
|
<DL COMPACT>
|
|
<DT id="629">1.<DD>
|
|
Entropy Gathering Daemon (<FONT SIZE="-1">EGD</FONT>) at <<A HREF="http://www.lothar.com/tech/crypto/">http://www.lothar.com/tech/crypto/</A>>
|
|
<DT id="630">2.<DD>
|
|
Pseudo-random number generating daemon (<FONT SIZE="-1">PRNGD</FONT>) at
|
|
<<A HREF="http://www.aet.tu-cottbus.de/personen/jaenicke/postfix_tls/prngd.html">http://www.aet.tu-cottbus.de/personen/jaenicke/postfix_tls/prngd.html</A>>
|
|
</DL>
|
|
<P>
|
|
|
|
If you are using the low level <FONT SIZE="-1">API</FONT> functions to communicate with other
|
|
<FONT SIZE="-1">SSL</FONT> implementations, you would do well to call
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::CTX_set_options($ctx, &Net::SSLeay::OP_ALL)
|
|
or die_if_ssl_error("ssl ctx set options");
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
to cope with some well know bugs in some other <FONT SIZE="-1">SSL</FONT>
|
|
implementations. The high level <FONT SIZE="-1">API</FONT> functions always set all known
|
|
compatibility options.
|
|
<P>
|
|
|
|
Sometimes <TT>"sslcat()"</TT> (and the high level <FONT SIZE="-1">HTTPS</FONT> functions that build on it)
|
|
is too fast in signaling the <FONT SIZE="-1">EOF</FONT> to legacy <FONT SIZE="-1">HTTPS</FONT> servers. This causes
|
|
the server to return empty page. To work around this problem you can
|
|
set the global variable
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
$Net::SSLeay::slowly = 1; # Add sleep so broken servers can keep up
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
<FONT SIZE="-1">HTTP/1.1</FONT> is not supported. Specifically this module does not know to
|
|
issue or serve multiple http requests per connection. This is a serious
|
|
shortcoming, but using the <FONT SIZE="-1">SSL</FONT> session cache on your server helps to
|
|
alleviate the <FONT SIZE="-1">CPU</FONT> load somewhat.
|
|
<P>
|
|
|
|
As of version 1.09 many newer OpenSSL auxiliary functions were
|
|
added (from <TT>"REM_AUTOMATICALLY_GENERATED_1_09"</TT> onwards in <TT>"SSLeay.xs"</TT>).
|
|
Unfortunately I have not had any opportunity to test these. Some of
|
|
them are trivial enough that I believe they ``just work'', but others
|
|
have rather complex interfaces with function pointers and all. In these
|
|
cases you should proceed wit great caution.
|
|
<P>
|
|
|
|
This module defaults to using OpenSSL automatic protocol negotiation
|
|
code for automatically detecting the version of the <FONT SIZE="-1">SSL/TLS</FONT> protocol
|
|
that the other end talks. With most web servers this works just
|
|
fine, but once in a while I get complaints from people that the module
|
|
does not work with some web servers. Usually this can be solved
|
|
by explicitly setting the protocol version, e.g.
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
$Net::SSLeay::ssl_version = 2; # Insist on SSLv2
|
|
$Net::SSLeay::ssl_version = 3; # Insist on SSLv3
|
|
$Net::SSLeay::ssl_version = 10; # Insist on TLSv1
|
|
$Net::SSLeay::ssl_version = 11; # Insist on TLSv1.1
|
|
$Net::SSLeay::ssl_version = 12; # Insist on TLSv1.2
|
|
$Net::SSLeay::ssl_version = 13; # Insist on TLSv1.3
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
Although the autonegotiation is nice to have, the <FONT SIZE="-1">SSL</FONT> standards
|
|
do not formally specify any such mechanism. Most of the world has
|
|
accepted the SSLeay/OpenSSL way of doing it as the de facto standard. But
|
|
for the few that think differently, you have to explicitly speak
|
|
the correct version. This is not really a bug, but rather a deficiency
|
|
in the standards. If a site refuses to respond or sends back some
|
|
nonsensical error codes (at the <FONT SIZE="-1">SSL</FONT> handshake level), try this option
|
|
before mailing me.
|
|
<P>
|
|
|
|
On some systems, OpenSSL may be compiled without support for SSLv2.
|
|
If this is the case, Net::SSLeay will warn if ssl_version has been set
|
|
to 2.
|
|
<P>
|
|
|
|
The high level <FONT SIZE="-1">API</FONT> returns the certificate of the peer, thus allowing
|
|
one to check what certificate was supplied. However, you will only be
|
|
able to check the certificate after the fact, i.e. you already sent
|
|
your form data by the time you find out that you did not trust them,
|
|
oops.
|
|
<P>
|
|
|
|
So, while being able to know the certificate after the fact is surely
|
|
useful, the security minded would still choose to do the connection
|
|
and certificate verification first and only then exchange data
|
|
with the site. Currently none of the high level <FONT SIZE="-1">API</FONT> functions do
|
|
this, thus you would have to program it using the low level <FONT SIZE="-1">API. A</FONT>
|
|
good place to start is to see how the <TT>"Net::SSLeay::http_cat()"</TT> function
|
|
is implemented.
|
|
<P>
|
|
|
|
The high level <FONT SIZE="-1">API</FONT> functions use a global file handle <TT>"SSLCAT_S"</TT>
|
|
internally. This really should not be a problem because there is no
|
|
way to interleave the high level <FONT SIZE="-1">API</FONT> functions, unless you use threads
|
|
(but threads are not very well supported in perl anyway). However, you
|
|
may run into problems if you call undocumented internal functions in an
|
|
interleaved fashion. The best solution is to ``require Net::SSLeay'' in
|
|
one thread after all the threads have been created.
|
|
<A NAME="lbAU"> </A>
|
|
<H2>DIAGNOSTICS</H2>
|
|
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="631">Random number generator not seeded!!!<DD>
|
|
|
|
|
|
<B>(W)</B> This warning indicates that <TT>"randomize()"</TT> was not able to read
|
|
<TT>"/dev/random"</TT> or <TT>"/dev/urandom"</TT>, possibly because your system does not
|
|
have them or they are differently named. You can still use <FONT SIZE="-1">SSL,</FONT> but
|
|
the encryption will not be as strong.
|
|
<DT id="632">open_tcp_connection: destination host not found:`server' (port 123) ($!)<DD>
|
|
|
|
|
|
Name lookup for host named <TT>"server"</TT> failed.
|
|
<DT id="633">open_tcp_connection: failed `server', 123 ($!)<DD>
|
|
|
|
|
|
The name was resolved, but establishing the <FONT SIZE="-1">TCP</FONT> connection failed.
|
|
<DT id="634">msg 123: 1 - error:140770F8:SSL routines:SSL23_GET_SERVER_HELLO:unknown proto<DD>
|
|
|
|
|
|
SSLeay error string. The first number (123) is the <FONT SIZE="-1">PID,</FONT> the second number
|
|
(1) indicates the position of the error message in SSLeay error stack.
|
|
You often see a pile of these messages as errors cascade.
|
|
<DT id="635">msg 123: 1 - <B><A HREF="/cgi-bin/man/man2html?2+error:02001002::lib">error:02001002::lib</A></B>(2) :<B><A HREF="/cgi-bin/man/man2html?1+func">func</A></B>(1) :<B><A HREF="/cgi-bin/man/man2html?2+reason">reason</A></B>(2)<DD>
|
|
|
|
|
|
The same as above, but you didn't call <B>load_error_strings()</B> so SSLeay
|
|
couldn't verbosely explain the error. You can still find out what it
|
|
means with this command:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
/usr/local/ssl/bin/ssleay errstr 02001002
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="636">Password is being asked for private key<DD>
|
|
|
|
|
|
This is normal behaviour if your private key is encrypted. Either
|
|
you have to supply the password or you have to use an unencrypted
|
|
private key. Scan OpenSSL.org for the <FONT SIZE="-1">FAQ</FONT> that explains how to
|
|
do this (or just study examples/makecert.pl which is used
|
|
during <TT>"make test"</TT> to do just that).
|
|
</DL>
|
|
<A NAME="lbAV"> </A>
|
|
<H2>SECURITY</H2>
|
|
|
|
|
|
|
|
You can mitigate some of the security vulnerabilities that might be present in your <FONT SIZE="-1">SSL/TLS</FONT> application:
|
|
<A NAME="lbAW"> </A>
|
|
<H3><FONT SIZE="-1">BEAST</FONT> Attack</H3>
|
|
|
|
|
|
|
|
<A HREF="http://blogs.cisco.com/security/beat-the-beast-with-tls/">http://blogs.cisco.com/security/beat-the-beast-with-tls/</A>
|
|
<A HREF="https://community.qualys.com/blogs/securitylabs/2011/10/17/mitigating-the-beast-attack-on-tls">https://community.qualys.com/blogs/securitylabs/2011/10/17/mitigating-the-beast-attack-on-tls</A>
|
|
<A HREF="http://blog.zoller.lu/2011/09/beast-summary-tls-cbc-countermeasures.html">http://blog.zoller.lu/2011/09/beast-summary-tls-cbc-countermeasures.html</A>
|
|
<P>
|
|
|
|
The <FONT SIZE="-1">BEAST</FONT> attack relies on a weakness in the way <FONT SIZE="-1">CBC</FONT> mode is used in <FONT SIZE="-1">SSL/TLS.</FONT>
|
|
In OpenSSL versions 0.9.6d and later, the protocol-level mitigation is enabled by default,
|
|
thus making it not vulnerable to the <FONT SIZE="-1">BEAST</FONT> attack.
|
|
<P>
|
|
|
|
Solutions:
|
|
<DL COMPACT>
|
|
<DT id="637">•<DD>
|
|
Compile with OpenSSL versions 0.9.6d or later, which enables <FONT SIZE="-1">SSL_OP_ALL</FONT> by default
|
|
<DT id="638">•<DD>
|
|
Ensure <FONT SIZE="-1">SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS</FONT> is not enabled (its not enabled by default)
|
|
<DT id="639">•<DD>
|
|
Don't support SSLv2, SSLv3
|
|
<DT id="640">•<DD>
|
|
Actively control the ciphers your server supports with set_cipher_list:
|
|
</DL>
|
|
<P>
|
|
|
|
Net::SSLeay::set_cipher_list($ssl, '<FONT SIZE="-1">RC4-SHA:HIGH:</FONT>!ADH');
|
|
<A NAME="lbAX"> </A>
|
|
<H3>Session Resumption</H3>
|
|
|
|
|
|
|
|
<A HREF="http://www.openssl.org/docs/ssl/SSL_CTX_set_options.html">http://www.openssl.org/docs/ssl/SSL_CTX_set_options.html</A>
|
|
<P>
|
|
|
|
The <FONT SIZE="-1">SSL</FONT> Labs vulnerability test on your <FONT SIZE="-1">SSL</FONT> server might report in red:
|
|
<P>
|
|
|
|
Session resumption No (IDs assigned but not accepted)
|
|
<P>
|
|
|
|
This report is not really bug or a vulnerability, since the server will not
|
|
accept session resumption requests.
|
|
However, you can prevent this noise in the report by disabling the session cache altogether:
|
|
Net::SSLeay::CTX_set_session_cache_mode($ssl_ctx, <B>Net::SSLeay::SESS_CACHE_OFF()</B>);
|
|
Use 0 if you don't have <FONT SIZE="-1">SESS_CACHE_OFF</FONT> constant.
|
|
<A NAME="lbAY"> </A>
|
|
<H3>Secure Renegotiation and DoS Attack</H3>
|
|
|
|
|
|
|
|
<A HREF="https://community.qualys.com/blogs/securitylabs/2011/10/31/tls-renegotiation-and-denial-of-service-attacks">https://community.qualys.com/blogs/securitylabs/2011/10/31/tls-renegotiation-and-denial-of-service-attacks</A>
|
|
<P>
|
|
|
|
This is not a ``security flaw,'' it is more of a DoS vulnerability.
|
|
<P>
|
|
|
|
Solutions:
|
|
<DL COMPACT>
|
|
<DT id="641">•<DD>
|
|
Do not support SSLv2
|
|
<DT id="642">•<DD>
|
|
Do not set the <FONT SIZE="-1">SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION</FONT> option
|
|
<DT id="643">•<DD>
|
|
Compile with OpenSSL 0.9.8m or later
|
|
</DL>
|
|
<A NAME="lbAZ"> </A>
|
|
<H2>BUGS</H2>
|
|
|
|
|
|
|
|
If you encounter a problem with this module that you believe is a bug,
|
|
please report it in one of the following ways:
|
|
<DL COMPACT>
|
|
<DT id="644">•<DD>
|
|
create a new issue <<A HREF="https://github.com/radiator-software/p5-net-ssleay/issues/new">https://github.com/radiator-software/p5-net-ssleay/issues/new</A>>
|
|
under the Net-SSLeay GitHub project at
|
|
<<A HREF="https://github.com/radiator-software/p5-net-ssleay">https://github.com/radiator-software/p5-net-ssleay</A>>;
|
|
<DT id="645">•<DD>
|
|
open a ticket <<A HREF="https://rt.cpan.org/Ticket/Create.html?Queue=Net-SSLeay">https://rt.cpan.org/Ticket/Create.html?Queue=Net-SSLeay</A>> using
|
|
the <FONT SIZE="-1">CPAN RT</FONT> bug tracker's web interface at
|
|
<<A HREF="https://rt.cpan.org/Dist/Display.html?Queue=Net-SSLeay">https://rt.cpan.org/Dist/Display.html?Queue=Net-SSLeay</A>>;
|
|
<DT id="646">•<DD>
|
|
send an email to the <FONT SIZE="-1">CPAN RT</FONT> bug tracker at
|
|
<A HREF="mailto:bug-Net-SSLeay@rt.cpan.org">bug-Net-SSLeay@rt.cpan.org</A> <mailto:<A HREF="mailto:bug-Net-SSLeay@rt.cpan.org">bug-Net-SSLeay@rt.cpan.org</A>>.
|
|
</DL>
|
|
<P>
|
|
|
|
Please make sure your bug report includes the following information:
|
|
<DL COMPACT>
|
|
<DT id="647">•<DD>
|
|
the code you are trying to run;
|
|
<DT id="648">•<DD>
|
|
your operating system name and version;
|
|
<DT id="649">•<DD>
|
|
the output of <TT>"perl -V"</TT>;
|
|
<DT id="650">•<DD>
|
|
the version of OpenSSL or LibreSSL you are using.
|
|
</DL>
|
|
<A NAME="lbBA"> </A>
|
|
<H2>AUTHOR</H2>
|
|
|
|
|
|
|
|
Originally written by Sampo Kellomäki.
|
|
<P>
|
|
|
|
Maintained by Florian Ragwitz between November 2005 and January 2010.
|
|
<P>
|
|
|
|
Maintained by Mike McCauley between November 2005 and June 2018.
|
|
<P>
|
|
|
|
Maintained by Chris Novakovic, Tuure Vartiainen and Heikki Vatiainen since June 2018.
|
|
<A NAME="lbBB"> </A>
|
|
<H2>COPYRIGHT</H2>
|
|
|
|
|
|
|
|
Copyright (c) 1996-2003 Sampo Kellomäki <<A HREF="mailto:sampo@iki.fi">sampo@iki.fi</A>>
|
|
<P>
|
|
|
|
Copyright (c) 2005-2010 Florian Ragwitz <<A HREF="mailto:rafl@debian.org">rafl@debian.org</A>>
|
|
<P>
|
|
|
|
Copyright (c) 2005-2018 Mike McCauley <<A HREF="mailto:mikem@airspayce.com">mikem@airspayce.com</A>>
|
|
<P>
|
|
|
|
Copyright (c) 2018- Chris Novakovic <<A HREF="mailto:chris@chrisn.me.uk">chris@chrisn.me.uk</A>>
|
|
<P>
|
|
|
|
Copyright (c) 2018- Tuure Vartiainen <<A HREF="mailto:vartiait@radiatorsoftware.com">vartiait@radiatorsoftware.com</A>>
|
|
<P>
|
|
|
|
Copyright (c) 2018- Heikki Vatiainen <<A HREF="mailto:hvn@radiatorsoftware.com">hvn@radiatorsoftware.com</A>>
|
|
<P>
|
|
|
|
All rights reserved.
|
|
<A NAME="lbBC"> </A>
|
|
<H2>LICENSE</H2>
|
|
|
|
|
|
|
|
This module is released under the terms of the Artistic License 2.0. For
|
|
details, see the <TT>"LICENSE"</TT> file distributed with Net-SSLeay's source code.
|
|
<A NAME="lbBD"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
Net::SSLeay::Handle - File handle interface
|
|
./examples - Example servers and a clients
|
|
<<A HREF="http://www.openssl.org/">http://www.openssl.org/</A>> - OpenSSL source, documentation, etc
|
|
<A HREF="mailto:openssl-users-request@openssl.org">openssl-users-request@openssl.org</A> - General OpenSSL mailing list
|
|
<<A HREF="http://www.ietf.org/rfc/rfc2246.txt">http://www.ietf.org/rfc/rfc2246.txt</A>> - TLS 1.0 specification
|
|
<<A HREF="http://www.w3c.org">http://www.w3c.org</A>> - HTTP specifications
|
|
<<A HREF="http://www.ietf.org/rfc/rfc2617.txt">http://www.ietf.org/rfc/rfc2617.txt</A>> - How to send password
|
|
<<A HREF="http://www.lothar.com/tech/crypto/">http://www.lothar.com/tech/crypto/</A>> - Entropy Gathering Daemon (EGD)
|
|
<<A HREF="http://www.aet.tu-cottbus.de/personen/jaenicke/postfix_tls/prngd.html">http://www.aet.tu-cottbus.de/personen/jaenicke/postfix_tls/prngd.html</A>>
|
|
- pseudo-random number generating daemon (PRNGD)
|
|
<A HREF="/cgi-bin/man/man2html?1+perl">perl</A>(1)
|
|
<A HREF="/cgi-bin/man/man2html?1+perlref">perlref</A>(1)
|
|
<A HREF="/cgi-bin/man/man2html?1+perllol">perllol</A>(1)
|
|
perldoc ~openssl/doc/ssl/SSL_CTX_set_verify.pod
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="651"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="652"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="653"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DL>
|
|
<DT id="654"><A HREF="#lbAE">High level functions for accessing web servers</A><DD>
|
|
<DT id="655"><A HREF="#lbAF">Certificate verification and Certificate Revocation Lists (CRLs)</A><DD>
|
|
<DT id="656"><A HREF="#lbAG">Certificate verification and Online Status Revocation Protocol (<FONT SIZE="-1">OCSP</FONT>)</A><DD>
|
|
<DT id="657"><A HREF="#lbAH">Using Net::SSLeay in multi-threaded applications</A><DD>
|
|
<DT id="658"><A HREF="#lbAI">Convenience routines</A><DD>
|
|
<DT id="659"><A HREF="#lbAJ">Initialization</A><DD>
|
|
<DT id="660"><A HREF="#lbAK">Error handling functions</A><DD>
|
|
<DT id="661"><A HREF="#lbAL">Sockets</A><DD>
|
|
<DT id="662"><A HREF="#lbAM">Callbacks</A><DD>
|
|
<DT id="663"><A HREF="#lbAN">Low level <FONT SIZE="-1">API</FONT></A><DD>
|
|
<DT id="664"><A HREF="#lbAO">Constants</A><DD>
|
|
<DT id="665"><A HREF="#lbAP"><FONT SIZE="-1">INTERNAL ONLY</FONT> functions (do not use these)</A><DD>
|
|
</DL>
|
|
<DT id="666"><A HREF="#lbAQ">EXAMPLES</A><DD>
|
|
<DT id="667"><A HREF="#lbAR">INSTALLATION</A><DD>
|
|
<DT id="668"><A HREF="#lbAS">LIMITATIONS</A><DD>
|
|
<DT id="669"><A HREF="#lbAT">KNOWN BUGS AND CAVEATS</A><DD>
|
|
<DT id="670"><A HREF="#lbAU">DIAGNOSTICS</A><DD>
|
|
<DT id="671"><A HREF="#lbAV">SECURITY</A><DD>
|
|
<DL>
|
|
<DT id="672"><A HREF="#lbAW"><FONT SIZE="-1">BEAST</FONT> Attack</A><DD>
|
|
<DT id="673"><A HREF="#lbAX">Session Resumption</A><DD>
|
|
<DT id="674"><A HREF="#lbAY">Secure Renegotiation and DoS Attack</A><DD>
|
|
</DL>
|
|
<DT id="675"><A HREF="#lbAZ">BUGS</A><DD>
|
|
<DT id="676"><A HREF="#lbBA">AUTHOR</A><DD>
|
|
<DT id="677"><A HREF="#lbBB">COPYRIGHT</A><DD>
|
|
<DT id="678"><A HREF="#lbBC">LICENSE</A><DD>
|
|
<DT id="679"><A HREF="#lbBD">SEE ALSO</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:49 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|