Hide Show 11282 lines of Pod
=encoding utf-8
=head1 NAME
Net::SSLeay - Perl bindings
for
OpenSSL and LibreSSL
=head1 SYNOPSIS
use
Net::SSLeay
qw(get_https post_https sslcat make_headers make_form)
;
(
$page
) = get_https(
'www.bacus.pt'
, 443,
'/'
);
(
$page
,
$response
,
%reply_headers
)
= get_https(
'www.bacus.pt'
, 443,
'/'
,
make_headers(User
-Agent
=>
'Cryptozilla/5.0b1'
,
);
(
$page
,
$result
,
%headers
)
= get_https(
'www.bacus.pt'
, 443,
'/protected.html'
,
make_headers(
Authorization
=>
'Basic '
. MIME::Base64::encode(
"$user:$pass"
,
''
))
);
(
$page
,
$response
,
%reply_headers
)
= post_https(
'www.bacus.pt'
, 443,
'/foo.cgi'
,
''
,
make_form(
OK
=>
'1'
,
name
=>
'Sampo'
)
);
$reply
= sslcat(
$host
,
$port
,
$request
);
(
$reply
,
$err
,
$server_cert
) = sslcat(
$host
,
$port
,
$request
);
$Net::SSLeay::trace
= 2;
Net::SSLeay::initialize();
=head1 DESCRIPTION
This module provides Perl bindings
for
libssl (an SSL/TLS API) and libcrypto (a
cryptography API).
=head1 COMPATIBILITY
Net::SSLeay supports the following libssl implementations:
=over
=item *
branches, except
for
OpenSSL 0.9.8 - 0.9.8b.
=item *
series, except
for
LibreSSL 3.2.2 and 3.2.3.
=back
Net::SSLeay may not function as expected
with
releases other than the ones
listed above due to libssl API incompatibilities, or, in the case of LibreSSL,
because of deviations from the libssl API.
Net::SSLeay is only as secure as the underlying libssl implementation you
use
.
Although Net::SSLeay maintains compatibility
with
old versions of OpenSSL and
LibreSSL, it is B<strongly recommended> that you
use
a version of OpenSSL or
LibreSSL that is supported by the OpenSSL/LibreSSL developers and/or your
operating
system
vendor. Many unsupported versions of OpenSSL and LibreSSL are
known to contain severe security vulnerabilities. Refer to the
information on which versions are currently supported.
The libssl API
has
changed significantly since OpenSSL 0.9.8: hundreds of
functions have been added, deprecated or removed in the intervening versions.
Although this documentation lists all of the functions and constants that
Net::SSLeay may expose, they will not be available
for
use
if
they are missing
from the underlying libssl implementation. Refer to the compatibility notes in
this documentation, as well as the OpenSSL/LibreSSL manual pages,
for
information on which OpenSSL/LibreSSL versions support
each
function or
constant. At run-
time
, you can check whether a function or constant is exposed
before
calling it using the following convention:
if
(
defined
&Net::SSLeay::libssl_function
) {
Net::SSLeay::libssl_function(...);
}
=head1 OVERVIEW
L<Net::SSLeay> module basically comprise of:
=over
=item * High level functions
for
accessing web servers (by using HTTP/HTTPS)
=item * Low level API (mostly mapped 1:1 to openssl's C functions)
=item * Convenience functions (related to low level API but
with
more perl friendly interface)
=back
There is also a related module called L<Net::SSLeay::Handle> included in this
distribution that you might want to
use
instead . It
has
its own pod
documentation.
=head2 High level functions
for
accessing web servers
This module offers some high level convenience functions
for
accessing
web pages on SSL servers (
for
symmetry, the same API is offered
for
accessing http servers, too), an C<sslcat()> function
for
writing your own
clients, and
finally
access to the SSL api of the SSLeay/OpenSSL
package
so you can
write
servers or clients
for
more complicated applications.
For high level functions it is most convenient to
import
them into your
main namespace as indicated in the synopsis.
=head3 Basic set of functions
=over
=item * get_https
=item * post_https
=item * put_https
=item * head_https
=item * do_https
=item * sslcat
=item * https_cat
=item * make_form
=item * make_headers
=back
B<Case 1 (in SYNOPSIS)> demonstrates the typical invocation of get_https() to fetch an HTML
page from secure server. The first argument provides the hostname or IP
in dotted decimal notation of the remote server to contact. The second
argument is the TCP port at the remote end (your own port is picked
arbitrarily from high numbered ports as usual
for
TCP). The third
argument is the URL of the page without the host name part. If in
B<Case 2 (in SYNOPSIS)> demonstrates full fledged
use
of C<get_https()>. As can be seen,
C<get_https()> parses the response and response headers and returns them as
a list, which can be captured in a hash
for
later reference. Also a
fourth argument to C<get_https()> is used to insert some additional headers
in the request. C<make_headers()> is a function that will convert a list or
hash to such headers. By
default
C<get_https()> supplies C<Host> (to make
virtual hosting easy) and C<Accept> (reportedly needed by IIS) headers.
B<Case 2b (in SYNOPSIS)> demonstrates how to get a password protected page. Refer to
the HTTP protocol specifications
for
further details (e.g. RFC-2617).
B<Case 3 (in SYNOPSIS)> invokes C<post_https()> to submit a HTML/CGI form to a secure
server. The first four arguments are equal to C<get_https()> (note that
the empty string (C<
''
>) is passed as header argument).
The fifth argument is the
contents of the form formatted according to CGI specification.
case the helper function C<make_https()> is used to
do
the formatting,
but you could pass any string. C<post_https()> automatically adds
C<Content-Type> and C<Content-Length> headers to the request.
B<Case 4 (in SYNOPSIS)> shows the fundamental C<sslcat()> function (inspired in spirit by
the C<netcat> utility :-). It's your swiss army knife that allows you to
easily contact servers,
send
some data, and then get the response. You
are responsible
for
formatting the data and parsing the response -
C<sslcat()> is just a transport.
B<Case 5 (in SYNOPSIS)> is a full invocation of C<sslcat()> which allows the
return
of errors
as well as the server (peer) certificate.
The C<
$trace
> global variable can be used to control the verbosity of the
high level functions. Level 0 guarantees silence, level 1 (the
default
)
only emits error messages.
=head3 Alternate versions of high-level API
=over
=item * get_https3
=item * post_https3
=item * put_https3
=item * get_https4
=item * post_https4
=item * put_https4
=back
The above mentioned functions actually
return
the response headers as
a list, which only gets converted to hash upon assignment (this
assignment looses information
if
the same header occurs twice, as may
be the case
with
cookies). There are also other variants of the
functions that
return
unprocessed headers and that
return
a reference
to a hash.
(
$page
,
$response
,
@headers
) = get_https(
'www.bacus.pt'
, 443,
'/'
);
for
(
$i
= 0;
$i
<
$#headers
;
$i
+=2) {
print
"$headers[$i] = "
.
$headers
[
$i
+1] .
"\n"
;
}
(
$page
,
$response
,
$headers
,
$server_cert
)
= get_https3(
'www.bacus.pt'
, 443,
'/'
);
print
"$headers\n"
;
(
$page
,
$response
,
$headers_ref
)
= get_https4(
'www.bacus.pt'
, 443,
'/'
);
for
$k
(
sort
keys
%{
$headers_ref
}) {
for
$v
(@{
$$headers_ref
{
$k
}}) {
print
"$k = $v\n"
;
}
}
All of the above code fragments accomplish the same thing: display all
values
of all headers. The API functions ending in
"3"
return
the
headers simply as a
scalar
string and it is up to the application to
split
them up. The functions ending in
"4"
return
a reference to
a hash of arrays (see L<perlref> and L<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
print
$$headers_ref
{COOKIE}[0];
Variants 3 and 4 also allow you to discover the server certificate
in case you would like to store or display it, e.g.
(
$p
,
$resp
,
$hdrs
,
$server_cert
) = get_https3(
'www.bacus.pt'
, 443,
'/'
);
if
(!
defined
(
$server_cert
) || (
$server_cert
== 0)) {
warn
"Subject Name: undefined, Issuer Name: undefined"
;
}
else
{
warn
sprintf
(
'Subject Name: %s Issuer Name: %s'
,
Net::SSLeay::X509_NAME_oneline(
Net::SSLeay::X509_get_subject_name(
$server_cert
)),
Net::SSLeay::X509_NAME_oneline(
Net::SSLeay::X509_get_issuer_name(
$server_cert
))
);
}
Beware that this method only allows
after
the fact verification of
the certificate: by the
time
C<get_https3()>
has
returned the https
request
has
already been sent to the server, whether you decide to
trust it or not. To
do
the verification correctly you must either
employ the OpenSSL certificate verification framework or
use
the lower level API to first
connect
and verify the certificate
and only then
send
the http data. See the implementation of C<ds_https3()>
for
guidance on how to
do
this.
=head3 Using client certificates
Secure web communications are encrypted using symmetric crypto
keys
exchanged using encryption based on the certificate of the
server. Therefore in all SSL connections the server must have a
certificate. This serves both to authenticate the server to the
clients and to perform the key exchange.
Sometimes it is necessary to authenticate the client as well. Two
options are available: HTTP basic authentication and a client side
certificate. The basic authentication over HTTPS is actually quite
safe because HTTPS guarantees that the password will not travel in
the clear. Never-the-less, problems like easily guessable passwords
remain. The client certificate method involves authentication of the
client at the SSL level using a certificate. For this to work, both the
client and the server have certificates (which typically are
different) and private
keys
.
The API functions outlined above
accept
additional arguments that
allow one to supply the client side certificate and key files. The
format
of these files is the same as used
for
server certificates and
the caveat about encrypting private
keys
applies.
(
$page
,
$result
,
%headers
)
= get_https(
'www.bacus.pt'
, 443,
'/protected.html'
,
make_headers(
Authorization
=>
'Basic '
. MIME::Base64::encode(
"$user:$pass"
,
''
)),
''
,
$mime_type6
,
$path_to_crt7
,
$path_to_key8
);
(
$page
,
$response
,
%reply_headers
)
= post_https(
'www.bacus.pt'
, 443,
'/foo.cgi'
,
make_headers(
'Authorization'
=>
'Basic '
. MIME::Base64::encode(
"$user:$pass"
,
''
)),
make_form(
OK
=>
'1'
,
name
=>
'Sampo'
),
$mime_type6
,
$path_to_crt7
,
$path_to_key8
);
B<Case 2c (in SYNOPSIS)> demonstrates getting a password protected page that also requires
a client certificate, i.e. it is possible to
use
both authentication
methods simultaneously.
B<Case 3b (in SYNOPSIS)> is a full blown POST to a secure server that requires both password
authentication and a client certificate, just like in case 2c.
Note: The client will not
send
a certificate
unless
the server requests one.
This is typically achieved by setting the verify mode to C<VERIFY_PEER> on the
server:
Net::SSLeay::set_verify(
$ssl
, Net::SSLeay::VERIFY_PEER, 0);
See C<perldoc ~openssl/doc/ssl/SSL_CTX_set_verify.pod>
for
a full description.
=head3 Working through a web proxy
=over
=item * set_proxy
=back
C<Net::SSLeay> can
use
a web proxy to make its connections. You need to
first set the proxy host and port using C<set_proxy()> and then just
use
the normal API functions, e.g:
Net::SSLeay::set_proxy(
'gateway.myorg.com'
, 8080);
(
$page
) = get_https(
'www.bacus.pt'
, 443,
'/'
);
If your proxy requires authentication, you can supply a username and
password as well
Net::SSLeay::set_proxy(
'gateway.myorg.com'
, 8080,
'joe'
,
'salainen'
);
(
$page
,
$result
,
%headers
)
= get_https(
'www.bacus.pt'
, 443,
'/protected.html'
,
make_headers(
Authorization
=>
'Basic '
. MIME::Base64::encode(
"susie:pass"
,
''
))
);
This example demonstrates the case where we authenticate to the proxy as
C<
"joe"
> and to the final web server as C<
"susie"
>. Proxy authentication
requires the C<MIME::Base64> module to work.
=head3 HTTP (without S) API
=over
=item * get_http
=item * post_http
=item * tcpcat
=item * get_httpx
=item * post_httpx
=item * tcpxcat
=back
Over the years it
has
become clear that it would be convenient to
use
the light-weight flavour API of C<Net::SSLeay>
for
normal HTTP as well (see
C<LWP>
for
the heavy-weight object-oriented approach). In fact it would be
nice to be able to flip https on and off on the fly. Thus regular HTTP
support was evolved.
get_httpx post_httpx tcpxcat
make_headers make_form)
;
(
$page
,
$result
,
%headers
)
= get_http(
'www.bacus.pt'
, 443,
'/protected.html'
,
make_headers(
Authorization
=>
'Basic '
. MIME::Base64::encode(
"$user:$pass"
,
''
))
);
(
$page
,
$response
,
%reply_headers
)
= post_http(
'www.bacus.pt'
, 443,
'/foo.cgi'
,
''
,
make_form(
OK
=>
'1'
,
name
=>
'Sampo'
)
);
(
$reply
,
$err
) = tcpcat(
$host
,
$port
,
$request
);
(
$page
,
$result
,
%headers
)
= get_httpx(
$usessl
,
'www.bacus.pt'
, 443,
'/protected.html'
,
make_headers(
Authorization
=>
'Basic '
. MIME::Base64::encode(
"$user:$pass"
,
''
))
);
(
$page
,
$response
,
%reply_headers
)
= post_httpx(
$usessl
,
'www.bacus.pt'
, 443,
'/foo.cgi'
,
''
,
make_form(
OK
=>
'1'
,
name
=>
'Sampo'
)
);
(
$reply
,
$err
,
$server_cert
) = tcpxcat(
$usessl
,
$host
,
$port
,
$request
);
As can be seen, the C<
"x"
> family of APIs takes as the first argument a flag
which indicates whether SSL is used or not.
=head2 Certificate verification and Certificate Revocation Lists (CRLs)
OpenSSL supports the ability to verify peer certificates. It can also
optionally check the peer certificate against a Certificate Revocation
List (CRL) from the certificates issuer. A CRL is a file, created by
the certificate issuer that lists all the certificates that it
previously signed, but which it now revokes. CRLs are in PEM
format
.
You can enable C<Net::SSLeay CRL> checking like this:
&Net::SSLeay::X509_STORE_set_flags
(
&Net::SSLeay::CTX_get_cert_store
(
$ssl
),
&Net::SSLeay::X509_V_FLAG_CRL_CHECK
);
After setting this flag,
if
OpenSSL checks a peer's certificate, then
it will attempt to find a CRL
for
the issuer. It does this by looking
for
a specially named file in the search directory specified by
CTX_load_verify_locations. CRL files are named
with
the hash of the
issuer's subject name, followed by C<.r0>, C<.r1> etc. For example
C<ab1331b2.r0>, C<ab1331b2.r1>. It will
read
all the .r files
for
the
issuer, and then check
for
a revocation of the peer certificate in all
of them. (You can also force it to look in a specific named CRL
file., see below). You can find out the hash of the issuer subject
name in a CRL
with
openssl crl -in crl.pem -hash -noout
If the peer certificate does not pass the revocation list, or
if
no
CRL is found, then the handshaking fails
with
an error.
You can also force OpenSSL to look
for
CRLs in one or more arbitrarily
named files.
my
$bio
= Net::SSLeay::BIO_new_file(
$crlfilename
,
'r'
);
my
$crl
= Net::SSLeay::PEM_read_bio_X509_CRL(
$bio
);
if
(
$crl
) {
Net::SSLeay::X509_STORE_add_crl(
Net::SSLeay::CTX_get_cert_store(
$ssl
,
$crl
)
);
}
else
{
}
Usually the URLs where you can download the CRLs is contained in the certificate
itself and you can extract them
with
my
@url
= Net::SSLeay::P_X509_get_crl_distribution_points(
$cert
);
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 DER
format
which you need to convert to PEM
before
openssl crl -in crl.der -inform der -out crl.pem
So as an alternative
for
faster and timely revocation checks you better
use
the Online Status Revocation Protocol (OCSP).
=head2 Certificate verification and Online Status Revocation Protocol (OCSP)
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.
A faster way is to ask the CA to check the revocation of just a single or a few
certificates using OCSP. Basically you generate
for
each
certificate an
OCSP_CERTID based on the certificate itself and its issuer, put the ids
together into an OCSP_REQUEST and
send
the request to the URL
given
in the
certificate.
As a result you get back an OCSP_RESPONSE and need to check the status of the
response, check that it is valid (e.g. signed by the CA) and
finally
extract the
information about
each
OCSP_CERTID to find out
if
the certificate is still valid
or got revoked.
With Net::SSLeay this can be done like this:
my
$cert
= Net::SSLeay::get_peer_certificate(
$ssl
);
my
$id
=
eval
{ Net::SSLeay::OCSP_cert2ids(
$ssl
,
$cert
) };
die
"failed to make OCSP_CERTID: $@"
if
$@;
my
$req
= Net::SSLeay::OCSP_ids2req(
$id
);
my
$uri
= Net::SSLeay::P_X509_get_ocsp_uri(
$cert
);
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"
;
my
$resp
=
eval
{ Net::SSLeay::d2i_OCSP_RESPONSE(
$content
) };
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
);
}
if
( !
eval
{ Net::SSLeay::OCSP_response_verify(
$ssl
,
$resp
,
$req
) }) {
die
"OCSP response verification failed"
;
}
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: $@"
;
}
my
@results
= Net::SSLeay::OCSP_response_results(
$resp
,
@ids
);
for
my
$r
(
@results
) {
print
Dumper(
$r
);
}
To further speed up certificate revocation checking one can
use
a TLS extension
to instruct the server to staple the OCSP response:
Net::SSLeay::set_tlsext_status_type(
$ssl
,
Net::SSLeay::TLSEXT_STATUSTYPE_ocsp());
my
$cert_valid
=
undef
;
Net::SSLeay::CTX_set_tlsext_status_cb(
$context
,
sub
{
my
(
$ssl
,
$resp
) =
@_
;
if
(!
$resp
) {
warn
"server did not return stapled OCSP response\n"
;
return
1;
}
my
$status
= Net::SSLeay::OCSP_response_status(
$resp
);
if
(
$status
!= Net::SSLeay::OCSP_RESPONSE_STATUS_SUCCESSFUL()) {
warn
"OCSP response failure: $status\n"
;
return
1;
}
if
(!
eval
{ Net::SSLeay::OCSP_response_verify(
$ssl
,
$resp
) }) {
warn
"OCSP response verify failed\n"
;
return
1;
}
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;
}
});
if
( !
defined
$cert_valid
) {
...
}
elsif
( !
$cert_valid
) {
die
"certificate not valid - closing SSL connection"
;
}
elsif
(
$cert_valid
<0 ) {
die
"cannot verify certificate revocation - self-signed ?"
;
}
else
{
...
}
=head2 Using Net::SSLeay in multi-threaded applications
B<IMPORTANT: versions 1.42 or earlier are not thread-safe!>
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
If you are about to
use
Net::SSLeay (or any other module based on Net::SSLeay) in multi-threaded
perl application it is recommended to follow this best-practice:
=head3 Initialization
Load and initialize Net::SSLeay module in the main thread:
Net::SSLeay::load_error_strings();
Net::SSLeay::SSLeay_add_ssl_algorithms();
Net::SSLeay::randomize();
sub
do_master_job {
}
sub
do_worker_job {
}
my
$master
= threads->new(\
&do_master_job
,
'param1'
,
'param2'
);
my
@workers
= threads->new(\
&do_worker_job
,
'arg1'
,
'arg2'
)
for
(1..10);
$_
->
join
()
for
(threads->list);
NOTE: Openssl's C<
int
SSL_library_init(void)> function (which is also aliased as
C<SSLeay_add_ssl_algorithms>, C<OpenSSL_add_ssl_algorithms> and C<add_ssl_algorithms>)
is not re-entrant and multiple calls can cause a crash in threaded application.
Net::SSLeay implements flags preventing repeated calls to this function,
therefore even multiple initialization via Net::SSLeay::SSLeay_add_ssl_algorithms()
should work without trouble.
=head3 Using callbacks
Do not
use
callbacks across threads (the module blocks cross-thread callback operations
and throws a warning). Always
do
the callback setup, callback
use
and callback destruction
within the same thread.
=head3 Using openssl elements
All openssl elements (X509, SSL_CTX, ...) can be directly passed between threads.
Net::SSLeay::load_error_strings();
Net::SSLeay::SSLeay_add_ssl_algorithms();
Net::SSLeay::randomize();
sub
do_job {
my
$context
=
shift
;
Net::SSLeay::CTX_set_default_passwd_cb(
$context
,
sub
{
"secret"
});
}
my
$c
= Net::SSLeay::CTX_new();
threads->create(\
&do_job
,
$c
);
Or:
my
$context
;
Net::SSLeay::load_error_strings();
Net::SSLeay::SSLeay_add_ssl_algorithms();
Net::SSLeay::randomize();
sub
do_job {
Net::SSLeay::CTX_set_default_passwd_cb(
$context
,
sub
{
"secret"
});
}
$context
= Net::SSLeay::CTX_new();
threads->create(\
&do_job
);
=head3 Using other perl modules based on Net::SSLeay
It should be fine to
use
any other module based on L<Net::SSLeay> (like L<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 C<< threads->new(..) >> or
C<< threads->create(..) >> but it might differ module by module.
To be safe you can load and init Net::SSLeay explicitly in the main thread:
Net::SSLeay::load_error_strings();
Net::SSLeay::SSLeay_add_ssl_algorithms();
Net::SSLeay::randomize();
Or even safer:
BEGIN {
Net::SSLeay::load_error_strings();
Net::SSLeay::SSLeay_add_ssl_algorithms();
Net::SSLeay::randomize();
}
=head3 Combining Net::SSLeay
with
other modules linked
with
openssl
B<BEWARE: This might be a big trouble! This is not guaranteed be thread-safe!>
There are many other (XS) modules linked directly to openssl library (like L<Crypt::SSLeay>).
As it is expected that also
"another"
module will call C<SSLeay_add_ssl_algorithms> at some point
we have again a trouble
with
multiple openssl initialization by Net::SSLeay and
"another"
module.
As you can expect Net::SSLeay is not able to avoid multiple initialization of openssl library
called by
"another"
module, thus you have to handle this on your own (in some cases it might
not be possible at all to avoid this).
=head3 Threading
with
get_https and friends
The convenience functions get_https, post_https etc all initialize the SSL library by calling
Net::SSLeay::initialize which does the conventional library initialization:
Net::SSLeay::load_error_strings();
Net::SSLeay::SSLeay_add_ssl_algorithms();
Net::SSLeay::randomize();
Net::SSLeay::initialize initializes the SSL library at most once.
You can
override
the Net::SSLeay::initialize function
if
you desire
some other type of initialization behaviour by get_https and friends.
You can call Net::SSLeay::initialize from your own code
if
you desire this conventional library initialization.
=head2 Convenience routines
To be used
with
Low level API
Net::SSLeay::randomize(
$rn_seed_file
,
$additional_seed
);
Net::SSLeay::set_cert_and_key(
$ctx
,
$cert_path
,
$key_path
);
$cert
= Net::SSLeay::dump_peer_certificate(
$ssl
);
Net::SSLeay::ssl_write_all(
$ssl
,
$message
) or
die
"ssl write failure"
;
$got
= Net::SSLeay::ssl_read_all(
$ssl
) or
die
"ssl read failure"
;
$got
= Net::SSLeay::ssl_read_CRLF(
$ssl
[,
$max_length
]);
$got
= Net::SSLeay::ssl_read_until(
$ssl
[,
$delimit
[,
$max_length
]]);
Net::SSLeay::ssl_write_CRLF(
$ssl
,
$message
);
=over
=item * randomize
seeds the openssl PRNG
with
C</dev/urandom> (see the top of C<SSLeay.pm>
for
how to change or configure this) and optionally
with
user provided
data. It is very important to properly seed your random numbers, so
do
not forget to call this. The high level API functions automatically
call C<randomize()> so it is not needed
with
them. See also caveats.
=item * set_cert_and_key
takes two file names as arguments and sets
the certificate and private key to those. This can be used to
set either server certificates or client certificates.
=item * dump_peer_certificate
allows you to get a plaintext description of the
certificate the peer (usually the server) presented to us.
=item * ssl_read_all
see ssl_write_all (below)
=item * ssl_write_all
C<ssl_read_all()> and C<ssl_write_all()> provide true blocking semantics
for
these operations (see limitation, below,
for
explanation). These are
much preferred to the low level API equivalents (which implement BSD
blocking semantics). The message argument to C<ssl_write_all()> can be
a reference. This is helpful to avoid unnecessary copying
when
writing
something big, e.g:
$data
=
'A'
x 1000000000;
Net::SSLeay::ssl_write_all(
$ssl
, \
$data
) or
die
"ssl write failed"
;
=item * ssl_read_CRLF
uses C<ssl_read_all()> to
read
in a line terminated
with
a
carriage
return
followed by a linefeed (CRLF). The CRLF is included in
the returned
scalar
.
=item * ssl_read_until
uses C<ssl_read_all()> to
read
from the SSL input
stream
until
it encounters a programmer specified delimiter.
If the delimiter is undefined, C<$/> is used. If C<$/> is undefined,
C<\n> is used. One can optionally set a maximum
length
of bytes to
read
from the SSL input stream.
=item * ssl_write_CRLF
writes C<
$message
> and appends CRLF to the SSL output stream.
=back
=head2 Initialization
In order to
use
the low level API you should start your programs
with
the following incantation:
Net::SSLeay::load_error_strings();
Net::SSLeay::SSLeay_add_ssl_algorithms();
Net::SSLeay::ENGINE_load_builtin_engines();
Net::SSLeay::ENGINE_register_all_complete();
Net::SSLeay::randomize();
=head2 Error handling functions
I can not emphasize the need to check
for
error enough. Use these
functions even in the most simple programs, they will reduce debugging
time
greatly. Do not ask questions on the mailing list without having
first sprinkled these in your code.
=over
=item * die_now
=item * die_if_ssl_error
C<die_now()> and C<die_if_ssl_error()> are used to conveniently
print
the SSLeay error
stack
when
something goes wrong:
Net::SSLeay::
connect
(
$ssl
) or die_now(
"Failed SSL connect ($!)"
);
Net::SSLeay::
write
(
$ssl
,
"foo"
) or die_if_ssl_error(
"SSL write ($!)"
);
=item * print_errs
You can also
use
C <Net::SSLeay::print_errs()> to
dump
the error stack without
exiting the program. As can be seen, your code becomes much more readable
if
you
import
the error reporting functions into your main name space.
=back
=head2 Sockets
Perl uses file handles
for
all I/O. While SSLeay
has
a quite flexible BIO
mechanism and perl
has
an evolved PerlIO mechanism, this module still
sticks to using file descriptors. Thus to attach SSLeay to a
socket
you
should
use
C <
fileno
()> to extract the underlying file descriptor:
Net::SSLeay::set_fd(
$ssl
,
fileno
(S));
You should also set C<$|> to 1 to eliminate STDIO buffering so you
do
not
get confused
if
you
use
perl I/O functions to manipulate your
socket
handle.
If you need to C<
select
(2)> on the
socket
, go right ahead, but be warned
that OpenSSL does some internal buffering so SSL_read does not always
return
data even
if
the
socket
selected
for
reading (just keep on
selecting and trying to
read
). C<Net::SSLeay> is
no
different from the
C language OpenSSL in this respect.
=head2 Callbacks
You can establish a per-context verify callback function something like this:
sub
verify {
my
(
$ok
,
$x509_store_ctx
) =
@_
;
print
"Verifying certificate...\n"
;
return
$ok
;
}
It is used like this:
Net::SSLeay::set_verify (
$ssl
, Net::SSLeay::VERIFY_PEER, \
&verify
);
Per-context callbacks
for
decrypting private
keys
are implemented.
Net::SSLeay::CTX_set_default_passwd_cb(
$ctx
,
sub
{
"top-secret"
});
Net::SSLeay::CTX_use_PrivateKey_file(
$ctx
,
"key.pem"
,
Net::SSLeay::FILETYPE_PEM)
or
die
"Error reading private key"
;
Net::SSLeay::CTX_set_default_passwd_cb(
$ctx
,
undef
);
If Hello Extensions are supported by your OpenSSL,
a session secret callback can be set up to be called
when
a session secret is set
by openssl.
Establish it like this:
Net::SSLeay::set_session_secret_cb(
$ssl
, \
&session_secret_cb
,
$somedata
);
It will be called like this:
sub
session_secret_cb {
my
(
$secret
, \
@cipherlist
, \
$preferredcipher
,
$somedata
) =
@_
;
}
No other callbacks are implemented. You
do
not need to
use
any
callback
for
simple (i.e. normal) cases where the SSLeay built-in
verify mechanism satisfies your needs.
It is required to
reset
these callbacks to
undef
immediately
after
use
to prevent
memory leaks, thread safety problems and crashes on
exit
that
can occur
if
different threads set different callbacks.
If you want to
use
callback stuff, see examples/callback.pl! It's the
only one I am able to make work reliably.
=head2 Low level API
In addition to the high level functions outlined above, this module
contains straight-forward access to CRYPTO and SSL parts of OpenSSL C API.
See the C<*.h> headers from OpenSSL C distribution
for
a list of low level
SSLeay functions to call (check SSLeay.xs to see
if
some function
has
been
implemented). The module strips the initial C<
"SSL_"
> off of the SSLeay names.
Generally you should
use
C <Net::SSLeay::> in its place.
Note that some functions are prefixed
with
C<
"P_"
> - these are very
close
to
the original API however contain some kind of a wrapper making its interface
more perl friendly.
For example:
In C:
err = SSL_set_verify (ssl, SSL_VERIFY_CLIENT_ONCE,
&your_call_back_here
);
In Perl:
$err
= Net::SSLeay::set_verify (
$ssl
,
Net::SSLeay::VERIFY_CLIENT_ONCE,
\
&your_call_back_here
);
If the function does not start
with
C<SSL_> you should
use
the full
function name, e.g.:
$err
= Net::SSLeay::ERR_get_error;
The following new functions behave in perlish way:
$got
= Net::SSLeay::
read
(
$ssl
);
Net::SSLeay::
write
(
$ssl
,
$foo
) ||
die
;
=head3 Low level API: Version and library information related functions
=over
=item * OpenSSL_version_num and SSLeay
B<COMPATIBILITY:> SSLeay() is not available in Net-SSLeay-1.42 and
before
. SSLeay() was made an alias of OpenSSL_version_num() in OpenSSL
1.1.0 and LibreSSL 2.7.0.
B<COMPATIBILITY:> OpenSSL_version_num() requires at least
Net-SSLeay-1.82
with
OpenSSL 1.1.0, or Net-SSLeay-1.88
with
LibreSSL
2.7.0.
Both functions
return
OPENSSL_VERSION_NUMBER constant (numeric) as
defined
by the underlying OpenSSL or LibreSSL library.
my
$ver_number
= Net::SSLeay::SSLeay();
my
$ver_number
= Net::SSLeay::OpenSSL_version_num();
You can
use
the version number like this
when
you know that the
underlying library is OpenSSL:
if
(Net::SSLeay::SSLeay() < 0x0090800f) {
die
"You need OpenSSL 0.9.8 or higher"
;
}
LibresSSL 2.2.2 and later define constant LIBRESSL_VERSION_NUMBER that
gives the LibreSSL version number. The
format
is the same that OpenSSL
uses
with
OPENSSL_VERSION_NUMBER. You can
do
this
if
you need to
check that the underlying library is LibreSSL and it's recent enough:
if
(Net::SSLeay::SSLeay() != 0x20000000 ||
Net::SSLeay::LIBRESSL_VERSION_NUMBER() < 0x3040200f) {
die
"You need LibreSSL. Version 3.4.2 or higher"
;
}
See OpenSSL 1.1.1 and earlier documentation
for
the details of status
nibble and the
format
interpretation.
=item * SSLeay_version
B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and
before
Returns different strings depending on
$type
.
my
$ver_string
= Net::SSLeay::SSLeay_version(
$type
);
Net::SSLeay::SSLeay_version();
Net::SSLeay::SSLeay_version(SSLEAY_VERSION);
OpenSSL 1.1.0 changed SSLeay_version() to an alias of
OpenSSL_version(). To ensure correct functionality
with
LibreSSL,
use
SSLEAY_* constants
with
SSLeay_version() and OPENSSL_* constants
with
OpenSSL_version().
OpenSSL website
no
longer
has
a manual page
for
SSLeay_version().
=item * OpenSSL_version
B<COMPATIBILITY:> requires at least Net-SSLeay-1.82
with
OpenSSL
1.1.0, or Net-SSLeay-1.88
with
LibreSSL 2.7.0.
Returns different strings depending on
$t
. Available
$t
constants
depend on the library version.
my
$ver_string
= Net::SSLeay::OpenSSL_version(
$t
);
Net::SSLeay::OpenSSL_version();
Net::SSLeay::OpenSSL_version(OPENSSL_VERSION);
=item * OPENSSL_info
B<COMPATIBILITY:> not available in Net-SSLeay-1.90 and
before
; requires at least OpenSSL 3.0.0-alpha1
Returns different strings depending on
$t
. Available
$t
constants
depend on the library version.
my
$info_string
= Net::SSLeay::OPENSSL_info(
$t
);
=item * OPENSSL_version_major, OPENSSL_version_minor and OPENSSL_version_patch
B<COMPATIBILITY:> not available in Net-SSLeay-1.90 and
before
; requires at least OpenSSL 3.0.0-alpha1, not in LibreSSL
Return constants OPENSSL_VERSION_MAJOR, OPENSSL_VERSION_MINOR and OPENSSL_VERSION_PATCH, respectively.
my
$major
= Net::SSLeay::OPENSSL_version_major();
my
$minor
= Net::SSLeay::OPENSSL_version_minor();
my
$patch
= Net::SSLeay::OPENSSL_version_patch();
For example
with
OpenSSL 3.0.1,
$major
is 3,
$minor
is 0 and
$patch
is 1.
Note: the constants record Net::SSLeay compile
time
values
whereas the
three functions
return
values
from the library. Typically these are
the same, but they can be different
if
the library version is updated
but Net::SSLeay is not re-compiled. See the OpenSSL and LibreSSL
API/ABI compatibility statements
for
more information.
=item * OPENSSL_version_pre_release
B<COMPATIBILITY:> not available in Net-SSLeay-1.90 and
before
; requires at least OpenSSL 3.0.0-alpha1, not in LibreSSL
Return constant string
defined
by C macro OPENSSL_VERSION_PRE_RELEASE.
my
$pre_release
= Net::SSLeay::OPENSSL_version_pre_release();
When the macro is not
defined
, an empty string is returned instead.
=item * OPENSSL_version_build_metadata
B<COMPATIBILITY:> not available in Net-SSLeay-1.90 and
before
; requires at least OpenSSL 3.0.0-alpha1, not in LibreSSL
Return constant string
defined
by C macro OPENSSL_VERSION_BUILD_METADATA.
my
$metadata
= Net::SSLeay::OPENSSL_version_build_metadata();
When the macro is not
defined
, an empty string is returned instead.
=back
=head3 Low level API: Initialization related functions
=over
=item * library_init
Initialize SSL library by registering algorithms.
my
$rv
= Net::SSLeay::library_init();
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
.
=item * add_ssl_algorithms
The alias
for
L</library_init>
Net::SSLeay::add_ssl_algorithms();
=item * OpenSSL_add_ssl_algorithms
The alias
for
L</library_init>
Net::SSLeay::OpenSSL_add_ssl_algorithms();
=item * SSLeay_add_ssl_algorithms
The alias
for
L</library_init>
Net::SSLeay::SSLeay_add_ssl_algorithms();
=item * load_error_strings
Registers the error strings
for
all libcrypto + libssl related functions.
Net::SSLeay::load_error_strings();
=item * ERR_load_crypto_strings
Registers the error strings
for
all libcrypto functions. No need to call this function
if
you have already called L</load_error_strings>.
Net::SSLeay::ERR_load_crypto_strings();
=item * ERR_load_RAND_strings
Registers the error strings
for
RAND related functions. No need to call this function
if
you have already called L</load_error_strings>.
Net::SSLeay::ERR_load_RAND_strings();
=item * ERR_load_SSL_strings
Registers the error strings
for
SSL related functions. No need to call this function
if
you have already called L</load_error_strings>.
Net::SSLeay::ERR_load_SSL_strings();
=item * OpenSSL_add_all_algorithms
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Add algorithms to internal table.
Net::SSLeay::OpenSSL_add_all_algorithms();
=item * OPENSSL_add_all_algorithms_conf
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Similar to L</OpenSSL_add_all_algorithms> - will ALWAYS load the config file
Net::SSLeay::OPENSSL_add_all_algorithms_conf();
=item * OPENSSL_add_all_algorithms_noconf
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Similar to L</OpenSSL_add_all_algorithms> - will NEVER load the config file
Net::SSLeay::OPENSSL_add_all_algorithms_noconf();
=item * OPENSSL_cleanup
B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and
before
;
requires at least OpenSSL 1.1.0-pre3 or LibreSSL 3.6.0
Deinitialises OpenSSL libcrypto and libssl.
Net::SSLeay::OPENSSL_cleanup();
=item * OPENSSL_init_crypto
B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and
before
;
requires at least OpenSSL 1.1.0-pre3 not enabled
for
LibreSSL. LibreSSL does not define C<OPENSSL_INIT_SETTINGS>.
Initialises OpenSSL C<libcrypto>
with
non-
default
settings.
my
$rv
= Net::SSLeay::OPENSSL_init_crypto(
$opts
,
$settings
);
=item * OPENSSL_init_ssl
B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and
before
;
requires at least OpenSSL 1.1.0-pre3 not enabled
for
LibreSSL. LibreSSL does not define C<OPENSSL_INIT_SETTINGS>.
Initialises OpenSSL C<libssl>
with
non-
default
settings.
my
$rv
= Net::SSLeay::OPENSSL_init_ssl(
$opts
,
$settings
);
=item * OPENSSL_INIT_new
B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and
before
;
requires at least OpenSSL 1.1.0-pre3, not in LibreSSL
Allocates an OpenSSL C<OPENSSL_INIT_SETTINGS> object.
my
$settings
= Net::SSLeay::OPENSSL_init_new()
=item * OPENSSL_INIT_free
B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and
before
;
requires at least OpenSSL 1.1.0-pre3, not in LibreSSL
Releases an OpenSSL C<OPENSSL_INIT_SETTINGS> object allocated
with
C<OPENSSL_INIT_new>.
Net::SSLeay::OPENSSL_init_free(
$settings
)
=item * OPENSSL_INIT_set_config_filename
B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and
before
;
requires at least OpenSSL 1.1.0-pre3, not in LibreSSL
Specify a nondefault filename to load as OpenSSL configuration file.
my
$rv
= Net::SSLeay::OPENSSL_INIT_set_config_filename(
$settings
,
$filename
);
=item * OPENSSL_INIT_set_config_appname
B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and
before
;
requires at least OpenSSL 1.1.0-pre3, not in LibreSSL
Specify a nondefault application name.
my
$rv
= Net::SSLeay::OPENSSL_INIT_set_config_appname(
$settings
,
$name
);
=item * OPENSSL_INIT_set_config_file_flags
B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and
before
;
requires at least OpenSSL 3.0.0-alpha1, not in LibreSSL
Specify nondefault flags
for
loading OpenSSL configuration file.
my
$rv
= Net::SSLeay::OPENSSL_INIT_set_config_file_flags(
$settings
,
$flags
);
=back
=head3 Low level API: ERR_* and SSL_alert_* related functions
B<NOTE:> Please note that SSL_alert_* function have
"SSL_"
part stripped from their names.
=over
=item * ERR_clear_error
Clear the error queue.
Net::SSLeay::ERR_clear_error();
=item * ERR_error_string
Generates a human-readable string representing the error code
$error
.
my
$rv
= Net::SSLeay::ERR_error_string(
$error
);
=item * ERR_get_error
Returns the earliest error code from the thread's error queue and removes the entry.
This function can be called repeatedly
until
there are
no
more error codes to
return
.
my
$rv
= Net::SSLeay::ERR_get_error();
=item * ERR_peek_error
Returns the earliest error code from the thread's error queue without modifying it.
my
$rv
= Net::SSLeay::ERR_peek_error();
=item * ERR_put_error
Adds an error code to the thread's error queue. It signals that the error of
$reason
code reason occurred in function
$func
of library
$lib
, in line number
$line
of
$file
.
Net::SSLeay::ERR_put_error(
$lib
,
$func
,
$reason
,
$file
,
$line
);
=item * alert_desc_string
Returns a two letter string as a short form describing the reason of the alert specified by value.
my
$rv
= Net::SSLeay::alert_desc_string(
$value
);
=item * alert_desc_string_long
Returns a string describing the reason of the alert specified by value.
my
$rv
= Net::SSLeay::alert_desc_string_long(
$value
);
=item * alert_type_string
Returns a one letter string indicating the type of the alert specified by value.
my
$rv
= Net::SSLeay::alert_type_string(
$value
);
=item * alert_type_string_long
Returns a string indicating the type of the alert specified by value.
my
$rv
= Net::SSLeay::alert_type_string_long(
$value
);
=back
=head3 Low level API: SSL_METHOD_* related functions
=over
=item * SSLv23_method, SSLv23_server_method and SSLv23_client_method
B<COMPATIBILITY:> not available in Net-SSLeay-1.82 and
before
.
Returns SSL_METHOD structure corresponding to general-purpose version-flexible TLS method, the
return
value can be later used as a param of L</CTX_new_with_method>.
B<NOTE:> Consider using TLS_method, TLS_server_method or TLS_client_method
with
new code.
my
$rv
= Net::SSLeay::SSLv2_method();
=item * SSLv2_method
Returns SSL_METHOD structure corresponding to SSLv2 method, the
return
value can be later used as a param of L</CTX_new_with_method>. Only available where supported by the underlying openssl.
my
$rv
= Net::SSLeay::SSLv2_method();
=item * SSLv3_method
Returns SSL_METHOD structure corresponding to SSLv3 method, the
return
value can be later used as a param of L</CTX_new_with_method>.
my
$rv
= Net::SSLeay::SSLv3_method();
=item * TLSv1_method, TLSv1_server_method and TLSv1_client_method
B<COMPATIBILITY:> Requires OpenSSL or LibreSSL built
with
support
for
TLSv1. Server and client methods not available in Net-SSLeay-1.82 and
before
.
Returns SSL_METHOD structure corresponding to TLSv1 method, the
return
value can be later used as a param of L</CTX_new_with_method>.
my
$rv
= Net::SSLeay::TLSv1_method();
=item * TLSv1_1_method, TLSv1_1_server_method and TLSv1_1_client_method
B<COMPATIBILITY:> Requires OpenSSL >= 1.0.1 or LibreSSL built
with
support
for
TLSv1.1. Server and client methods not available in Net-SSLeay-1.82 and
before
.
Returns SSL_METHOD structure corresponding to TLSv1_1 method, the
return
value can be later used as a param of L</CTX_new_with_method>.
my
$rv
= Net::SSLeay::TLSv1_1_method();
=item * TLSv1_2_method, TLSv1_2_server_method and TLSv1_2_client_method
B<COMPATIBILITY:> Requires OpenSSL >= 1.0.1 or LibreSSL built
with
support
for
TLSv1.2. Server and client methods not available in Net-SSLeay-1.82 and
before
.
Returns SSL_METHOD structure corresponding to TLSv1_2 method, the
return
value can be later used as a param of L</CTX_new_with_method>.
my
$rv
= Net::SSLeay::TLSv1_2_method();
=item * TLS_method, TLS_server_method and TLS_client_method
B<COMPATIBILITY:> Not available in Net-SSLeay-1.82 and
before
.
Returns SSL_METHOD structure corresponding to general-purpose version-flexible TLS method, the
return
value can be later used as a param of L</CTX_new_with_method>. Only available where supported by the underlying openssl.
my
$rv
= Net::SSLeay::TLS_method();
=back
=head3 Low level API: ENGINE_* related functions
=over
=item * ENGINE_load_builtin_engines
B<COMPATIBILITY:> Requires an OpenSSL build
with
dynamic engine loading support.
Load all bundled ENGINEs into memory and make them visible.
Net::SSLeay::ENGINE_load_builtin_engines();
=item * ENGINE_register_all_complete
B<COMPATIBILITY:> Requires an OpenSSL build
with
dynamic engine loading support.
Register all loaded ENGINEs
for
every algorithm they collectively implement.
Net::SSLeay::ENGINE_register_all_complete();
=item * ENGINE_set_default
B<COMPATIBILITY:> Requires an OpenSSL build
with
dynamic engine loading support.
Set
default
engine to
$e
+ set its flags to
$flags
.
my
$rv
= Net::SSLeay::ENGINE_set_default(
$e
,
$flags
);
=item * ENGINE_by_id
Get ENGINE by its identification
$id
.
B<COMPATIBILITY:> Requires an OpenSSL build
with
dynamic engine loading support.
my
$rv
= Net::SSLeay::ENGINE_by_id(
$id
);
=back
=head3 Low level API: EVP_PKEY_* related functions
=over
=item * EVP_PKEY_copy_parameters
Copies the parameters from key
$from
to key
$to
.
my
$rv
= Net::SSLeay::EVP_PKEY_copy_parameters(
$to
,
$from
);
=item * EVP_PKEY_new
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Creates a new EVP_PKEY structure.
my
$rv
= Net::SSLeay::EVP_PKEY_new();
=item * EVP_PKEY_free
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Free an allocated EVP_PKEY structure.
Net::SSLeay::EVP_PKEY_free(
$pkey
);
=item * EVP_PKEY_assign_RSA
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Set the key referenced by
$pkey
to
$key
B<NOTE:> No reference counter will be increased, i.e.
$key
will be freed
if
$pkey
is freed.
my
$rv
= Net::SSLeay::EVP_PKEY_assign_RSA(
$pkey
,
$key
);
=item * EVP_PKEY_assign_EC_KEY
B<COMPATIBILITY:> not available in Net-SSLeay-1.74 and
before
Set the key referenced by
$pkey
to
$key
B<NOTE:> No reference counter will be increased, i.e.
$key
will be freed
if
$pkey
is freed.
my
$rv
= Net::SSLeay::EVP_PKEY_assign_EC_KEY(
$pkey
,
$key
);
=item * EVP_PKEY_bits
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Returns the size of the key
$pkey
in bits.
my
$rv
= Net::SSLeay::EVP_PKEY_bits(
$pkey
);
=item * EVP_PKEY_security_bits
B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and
before
; requires at least OpenSSL 1.1.0 or at least LibreSSL 3.6.0 and Net-SSLeay-1.94
Returns the size of the key
$pkey
in bits.
my
$rv
= Net::SSLeay::EVP_PKEY_security_bits(
$pkey
);
=item * EVP_PKEY_size
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Returns the maximum size of a signature in bytes. The actual signature may be smaller.
my
$rv
= Net::SSLeay::EVP_PKEY_size(
$pkey
);
=item * EVP_PKEY_id
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
; requires at least OpenSSL 1.0.0
Returns
$pkey
type (integer value of corresponding NID).
my
$rv
= Net::SSLeay::EVP_PKEY_id(
$pkey
);
Example:
my
$pubkey
= Net::SSLeay::X509_get_pubkey(
$x509
);
my
$type
= Net::SSLeay::EVP_PKEY_id(
$pubkey
);
print
Net::SSLeay::OBJ_nid2sn(
$type
);
=back
=head3 Low level API: PEM_* related functions
=over
=item * PEM_read_bio_X509
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Loads PEM formatted X509 certificate via
given
BIO structure.
my
$rv
= Net::SSLeay::PEM_read_bio_X509(
$bio
);
Example:
my
$bio
= Net::SSLeay::BIO_new_file(
$filename
,
'r'
);
my
$x509
= Net::SSLeay::PEM_read_bio_X509(
$bio
);
Net::SSLeay::BIO_free(
$bio
);
=item * PEM_read_bio_X509_REQ
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Loads PEM formatted X509_REQ object via
given
BIO structure.
my
$rv
= Net::SSLeay::PEM_read_bio_X509_REQ(
$bio
,
$x
=NULL,
$cb
=NULL,
$u
=NULL);
Example:
my
$bio
= Net::SSLeay::BIO_new_file(
$filename
,
'r'
);
my
$x509_req
= Net::SSLeay::PEM_read_bio_X509_REQ(
$bio
);
Net::SSLeay::BIO_free(
$bio
);
=item * PEM_read_bio_DHparams
Reads DH structure from BIO.
my
$rv
= Net::SSLeay::PEM_read_bio_DHparams(
$bio
);
=item * PEM_read_bio_X509_CRL
Reads X509_CRL structure from BIO.
my
$rv
= Net::SSLeay::PEM_read_bio_X509_CRL(
$bio
);
=item * PEM_read_bio_PrivateKey
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Loads PEM formatted private key via
given
BIO structure.
my
$rv
= Net::SSLeay::PEM_read_bio_PrivateKey(
$bio
,
$cb
,
$data
);
Example:
my
$bio
= Net::SSLeay::BIO_new_file(
$filename
,
'r'
);
my
$privkey
= Net::SSLeay::PEM_read_bio_PrivateKey(
$bio
);
Net::SSLeay::BIO_free(
$bio
);
To
use
password you have the following options:
$privkey
= Net::SSLeay::PEM_read_bio_PrivateKey(
$bio
, \
&callback_func
);
$privkey
= Net::SSLeay::PEM_read_bio_PrivateKey(
$bio
, \
&callback_func
,
$data
);
$privkey
= Net::SSLeay::PEM_read_bio_PrivateKey(
$bio
,
undef
,
"secret"
);
$privkey
= Net::SSLeay::PEM_read_bio_PrivateKey(
$bio
,
undef
,
""
);
Callback function signature:
sub
callback_func {
my
(
$max_passwd_size
,
$rwflag
,
$data
) =
@_
;
return
"secret"
;
}
=item * PEM_X509_INFO_read_bio
Reads a BIO containing a PEM formatted file into a STACK_OF(X509_INFO) structure.
my
$rv
= Net::SSLeay::PEM_X509_INFO_read_bio(
$bio
);
Example:
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
);
=item * PEM_get_string_X509
B<NOTE:> Does not exactly correspond to any low level API function
Converts/exports X509 certificate to string (PEM
format
).
Net::SSLeay::PEM_get_string_X509(
$x509
);
=item * PEM_get_string_PrivateKey
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
. Requires legacy provider
with
OpenSSL 3.0 and later
if
the
default
value of C<
$enc_alg
> (C<DES_CBC>) is used.
Converts public key
$pk
into PEM formatted string (optionally protected
with
password).
my
$rv
= Net::SSLeay::PEM_get_string_PrivateKey(
$pk
,
$passwd
,
$enc_alg
);
Examples:
$pem_privkey
= Net::SSLeay::PEM_get_string_PrivateKey(
$pk
);
$pem_privkey
= Net::SSLeay::PEM_get_string_PrivateKey(
$pk
,
"secret"
);
$pem_privkey
= Net::SSLeay::PEM_get_string_PrivateKey(
$pk
,
"secret"
, Net::SSLeay::EVP_get_cipherbyname(
"DES-EDE3-CBC"
));
=item * PEM_get_string_X509_CRL
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Converts X509_CRL object
$x509_crl
into PEM formatted string.
Net::SSLeay::PEM_get_string_X509_CRL(
$x509_crl
);
=item * PEM_get_string_X509_REQ
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Converts X509_REQ object
$x509_crl
into PEM formatted string.
Net::SSLeay::PEM_get_string_X509_REQ(
$x509_req
);
=back
=head3 Low level API: d2i_* (DER
format
) related functions
=over
=item * d2i_X509_bio
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Loads DER formatted X509 certificate via
given
BIO structure.
my
$rv
= Net::SSLeay::d2i_X509_bio(
$bp
);
Example:
my
$bio
= Net::SSLeay::BIO_new_file(
$filename
,
'rb'
);
my
$x509
= Net::SSLeay::d2i_X509_bio(
$bio
);
Net::SSLeay::BIO_free(
$bio
);
=item * d2i_X509_CRL_bio
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Loads DER formatted X509_CRL object via
given
BIO structure.
my
$rv
= Net::SSLeay::d2i_X509_CRL_bio(
$bp
);
Example:
my
$bio
= Net::SSLeay::BIO_new_file(
$filename
,
'rb'
);
my
$x509_crl
= Net::SSLeay::d2i_X509_CRL_bio(
$bio
);
Net::SSLeay::BIO_free(
$bio
);
=item * d2i_X509_REQ_bio
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Loads DER formatted X509_REQ object via
given
BIO structure.
my
$rv
= Net::SSLeay::d2i_X509_REQ_bio(
$bp
);
Example:
my
$bio
= Net::SSLeay::BIO_new_file(
$filename
,
'rb'
);
my
$x509_req
= Net::SSLeay::d2i_X509_REQ_bio(
$bio
);
Net::SSLeay::BIO_free(
$bio
);
=back
=head3 Low level API: PKCS12 related functions
=over
=item * P_PKCS12_load_file
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Loads X509 certificate + private key + certificates of CA chain (
if
present in PKCS12 file).
my
(
$privkey
,
$cert
,
@cachain
) = Net::SSLeay::P_PKCS12_load_file(
$filename
,
$load_chain
,
$password
);
B<IMPORTANT NOTE:>
after
you
do
the job you need to call X509_free() on
$privkey
+ all members
of
@cachain
and EVP_PKEY_free() on
$privkey
.
Examples:
my
(
$privkey
,
$cert
) = Net::SSLeay::P_PKCS12_load_file(
$filename
);
my
(
$privkey
,
$cert
) = Net::SSLeay::P_PKCS12_load_file(
$filename
, 0,
$password
);
my
(
$privkey
,
$cert
,
@cachain
) = Net::SSLeay::P_PKCS12_load_file(
$filename
, 1);
my
(
$privkey
,
$cert
,
@cachain
) = Net::SSLeay::P_PKCS12_load_file(
$filename
, 1,
$password
);
my
(
$privkey
,
$cert
) = Net::SSLeay::P_PKCS12_load_file(
$filename
, 1,
$password
);
B<NOTE> Net::SSLeay 1.92_01 and earlier: 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 README.Win32
for
more details.
=back
=head3 Low level API: SESSION_* related functions
=over
=item * d2i_SSL_SESSION
B<COMPATIBILITY:> does not work in Net-SSLeay-1.85 and
before
Transforms the binary ASN1 representation string of an SSL/TLS session into an
SSL_SESSION object.
my
$ses
= Net::SSLeay::d2i_SSL_SESSION(
$data
);
=item * i2d_SSL_SESSION
B<COMPATIBILITY:> does not work in Net-SSLeay-1.85 and
before
Transforms the SSL_SESSION object in into the ASN1 representation and returns
it as string.
my
$data
= Net::SSLeay::i2d_SSL_SESSION(
$ses
);
=item * SESSION_new
Creates a new SSL_SESSION structure.
my
$rv
= Net::SSLeay::SESSION_new();
=item * SESSION_free
Free an allocated SSL_SESSION structure.
Net::SSLeay::SESSION_free(
$ses
);
=item * SESSION_up_ref
B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and
before
; requires at least OpenSSL 1.1.0-pre4 or LibreSSL 2.7.0
Increases the reference counter on a SSL_SESSION structure.
Net::SSLeay::SESSION_up_ref(
$ses
);
=item * SESSION_dup
B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and
before
; requires at least OpenSSL 1.1.1, not in LibreSSL
Duplicates a SSL_SESSION structure.
Net::SSLeay::SESSION_dup(
$ses
);
=item * SESSION_is_resumable
B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and
before
; requires at least OpenSSL 1.1.1, not in LibreSSL
Determine whether an SSL_SESSION object can be used
for
resumption.
Net::SSLeay::SESSION_is_resumable(
$ses
);
=item * SESSION_cmp
Compare two SSL_SESSION structures.
my
$rv
= Net::SSLeay::SESSION_cmp(
$sesa
,
$sesb
);
B<NOTE:> Not available in openssl 1.0 or later
=item * SESSION_get_app_data
Can be used to get application
defined
value/data.
my
$rv
= Net::SSLeay::SESSION_get_app_data(
$ses
);
=item * SESSION_set_app_data
Can be used to set some application
defined
value/data.
my
$rv
= Net::SSLeay::SESSION_set_app_data(
$s
,
$a
);
=item * SESSION_get_ex_data
Is used to retrieve the information
for
$idx
from session
$ses
.
my
$rv
= Net::SSLeay::SESSION_get_ex_data(
$ses
,
$idx
);
=item * SESSION_set_ex_data
Is used to store application data at arg
for
idx into the session object.
my
$rv
= Net::SSLeay::SESSION_set_ex_data(
$ss
,
$idx
,
$data
);
=item * SESSION_get_ex_new_index
Is used to register a new
index
for
application specific data.
my
$rv
= Net::SSLeay::SESSION_get_ex_new_index(
$argl
,
$argp
,
$new_func
,
$dup_func
,
$free_func
);
=item * SESSION_get_master_key
B<NOTE:> Does not exactly correspond to any low level API function
Returns
'master_key'
value from SSL_SESSION structure
$s
Net::SSLeay::SESSION_get_master_key(
$s
);
=item * SESSION_set1_master_key
B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and
before
; requires at least OpenSSL 1.1.1pre1, not in LibreSSL
Sets the master key value associated
with
a SSL_SESSION.
my
$ret
= Net::SSLeay::SESSION_set1_master_key(
$sess
,
$key
);
Example:
my
$key
=
pack
(
'H*'
,
'deadbeef'
);
my
$ret
= Net::SSLeay::SESSION_set1_master_key(
$sess
,
$key
);
=item * SESSION_set_master_key
Sets
'master_key'
value
for
SSL_SESSION structure
$s
Net::SSLeay::SESSION_set_master_key(
$s
,
$key
);
Not available
with
OpenSSL 1.1 and later.
Code that previously used SESSION_set_master_key must now set
$secret
in the session_secret callback set
with
SSL_set_session_secret_cb.
=item * SESSION_set_cipher
B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and
before
; requires at least OpenSSL 1.1.1pre1, not in LibreSSL
Set the ciphersuite associated
with
an SSL_SESSION.
my
$ret
= Net::SSLeay::SESSION_set_cipher(
$s
,
$cipher
);
=item * SESSION_set_protocol_version
B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and
before
; requires at least OpenSSL 1.1.1pre1, not in LibreSSL
Sets the protocol version associated
with
an SSL_SESSION.
my
$ret
= Net::SSLeay::SESSION_set_protocol_version(
$s
,
$version
);
=item * SESSION_get0_cipher
B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and
before
; requires at least OpenSSL 1.1.0 or LibreSSL 3.4.0
Returns the value corresponding to OpenSSL's SSL_CIPHER associated
with
an SSL_SESSION.
my
$ret
= Net::SSLeay::SESSION_get0_cipher(
$s
);
=item * SESSION_get_time
Returns the
time
at which the session s was established.
The
time
is
given
in seconds since 1.1.1970.
my
$rv
= Net::SSLeay::SESSION_get_time(
$s
);
=item * get_time
Technically the same functionality as L</SESSION_get_time>.
my
$rv
= Net::SSLeay::get_time(
$s
);
=item * SESSION_get_timeout
Returns the timeout value set
for
session
$s
in seconds.
my
$rv
= Net::SSLeay::SESSION_get_timeout(
$s
);
=item * get_timeout
Technically the same functionality as L</SESSION_get_timeout>.
my
$rv
= Net::SSLeay::get_timeout(
$s
);
=item * SESSION_print
B<NOTE:> Does not exactly correspond to any low level API function
Prints session details (e.g. protocol version, cipher, session-id ...) to BIO.
my
$rv
= Net::SSLeay::SESSION_print(
$fp
,
$ses
);
You have to
use
necessary BIO functions like this:
my
$ses
= Net::SSLeay::get_session(
$ssl
);
my
$bio
= Net::SSLeay::BIO_new(
&Net::SSLeay::BIO_s_mem
);
Net::SSLeay::SESSION_print(
$bio
,
$ses
);
print
Net::SSLeay::BIO_read(
$bio
);
=item * SESSION_print_fp
Prints session details (e.g. protocol version, cipher, session-id ...) to file handle.
B<NOTE> With some combinations of Windows, perl, compiler and compiler
options, you may see a runtime error
"no OPENSSL_Applink"
,
when
calling Net::SSLeay::SESSION_print_fp. See README.Win32
for
more
details.
my
$rv
= Net::SSLeay::SESSION_print_fp(
$fp
,
$ses
);
Example:
my
$ses
= Net::SSLeay::get_session(
$ssl
);
open
my
$fh
,
">"
,
"output.txt"
;
Net::SSLeay::SESSION_print_fp(
$fh
,
$ses
);
Similar functionality without Net::SSLeay::SESSION_print_fp
my
$ses
= Net::SSLeay::get_session(
$ssl
);
my
$bio
= Net::SSLeay::BIO_new_file(
'output.txt'
,
'w'
);
Net::SSLeay::SESSION_print(
$bio
,
$ses
);
=item * SESSION_set_time
Replaces the creation
time
of the session s
with
the chosen value
$t
(seconds since 1.1.1970).
my
$rv
= Net::SSLeay::SESSION_set_time(
$ses
,
$t
);
=item * set_time
Technically the same functionality as L</SESSION_set_time>.
my
$rv
= Net::SSLeay::set_time(
$ses
,
$t
);
=item * SESSION_set_timeout
Sets the timeout value
for
session s in seconds to
$t
.
my
$rv
= Net::SSLeay::SESSION_set_timeout(
$s
,
$t
);
=item * set_timeout
Technically the same functionality as L</SESSION_set_timeout>.
my
$rv
= Net::SSLeay::set_timeout(
$ses
,
$t
);
=back
=head3 Low level API: SSL_CTX_* related functions
B<NOTE:> Please note that the function described in this chapter have
"SSL_"
part stripped from their original openssl names.
=over
=item * CTX_add_client_CA
Adds the CA name extracted from
$cacert
to the list of CAs sent to the client
when
requesting a client certificate
for
$ctx
.
my
$rv
= Net::SSLeay::CTX_add_client_CA(
$ctx
,
$cacert
);
=item * CTX_add_extra_chain_cert
Adds the certificate
$x509
to the certificate chain presented together
with
the certificate. Several certificates can be added one
after
the other.
my
$rv
= Net::SSLeay::CTX_add_extra_chain_cert(
$ctx
,
$x509
);
=item * CTX_add_session
Adds the session
$ses
to the context
$ctx
.
my
$rv
= Net::SSLeay::CTX_add_session(
$ctx
,
$ses
);
=item * CTX_callback_ctrl
??? (more info needed)
my
$rv
= Net::SSLeay::CTX_callback_ctrl(
$ctx
,
$cmd
,
$fp
);
=item * CTX_check_private_key
Checks the consistency of a private key
with
the corresponding certificate loaded into
$ctx
.
my
$rv
= Net::SSLeay::CTX_check_private_key(
$ctx
);
=item * CTX_ctrl
Internal handling function
for
SSL_CTX objects.
B<BEWARE:> openssl doc says: This function should never be called directly!
my
$rv
= Net::SSLeay::CTX_ctrl(
$ctx
,
$cmd
,
$larg
,
$parg
);
=item * CTX_flush_sessions
Causes a run through the session cache of
$ctx
to remove sessions expired at
time
$tm
.
Net::SSLeay::CTX_flush_sessions(
$ctx
,
$tm
);
=item * CTX_free
Free an allocated SSL_CTX object.
Net::SSLeay::CTX_free(
$ctx
);
=item * CTX_get_app_data
Can be used to get application
defined
value/data.
my
$rv
= Net::SSLeay::CTX_get_app_data(
$ctx
);
=item * CTX_set_app_data
Can be used to set some application
defined
value/data.
my
$rv
= Net::SSLeay::CTX_set_app_data(
$ctx
,
$arg
);
=item * CTX_get0_param
B<COMPATIBILITY:> not available in Net-SSLeay-1.82 and
before
; requires at least OpenSSL 1.0.2-beta1 or LibreSSL 2.7.0
Returns the current verification parameters.
my
$vpm
= Net::SSLeay::CTX_get0_param(
$ctx
);
=item * CTX_get_cert_store
Returns the current certificate verification storage.
my
$rv
= Net::SSLeay::CTX_get_cert_store(
$ctx
);
=item * CTX_get_client_CA_list
Returns the list of client CAs explicitly set
for
$ctx
using L</CTX_set_client_CA_list>.
my
$rv
= Net::SSLeay::CTX_get_client_CA_list(
$ctx
);
=item * CTX_get_ex_data
Is used to retrieve the information
for
index
$idx
from
$ctx
.
my
$rv
= Net::SSLeay::CTX_get_ex_data(
$ssl
,
$idx
);
=item * CTX_get_ex_new_index
Is used to register a new
index
for
application specific data.
my
$rv
= Net::SSLeay::CTX_get_ex_new_index(
$argl
,
$argp
,
$new_func
,
$dup_func
,
$free_func
);
=item * CTX_get_mode
Returns the mode set
for
ctx.
my
$rv
= Net::SSLeay::CTX_get_mode(
$ctx
);
=item * CTX_set_mode
Adds the mode set via bitmask in
$mode
to
$ctx
. Options already set
before
are not cleared.
my
$rv
= Net::SSLeay::CTX_set_mode(
$ctx
,
$mode
);
For bitmask details see L</CTX_get_mode> (above).
=item * CTX_get_options
Returns the options (bitmask) set
for
$ctx
.
my
$rv
= Net::SSLeay::CTX_get_options(
$ctx
);
B<BEWARE:> The available constants and their
values
in bitmask depend
on the TLS library. For example, SSL_OP_NO_TLSv1_3 became available
much later than SSL_OP_NO_COMPRESS 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.
You are strongly encouraged to B<check your TLS library>
if
you need
to
use
numeric
values
directly. The following is a sample of historic
values
. It may not be correct anymore.
=item * CTX_set_options
Adds the options set via bitmask in
$options
to ctx. Options already set
before
are not cleared.
Net::SSLeay::CTX_set_options(
$ctx
,
$options
);
For bitmask details see L</CTX_get_options> (above).
=item * CTX_get_quiet_shutdown
Returns the
'quiet shutdown'
setting of
$ctx
.
my
$rv
= Net::SSLeay::CTX_get_quiet_shutdown(
$ctx
);
=item * CTX_get_read_ahead
my
$rv
= Net::SSLeay::CTX_get_read_ahead(
$ctx
);
=item * CTX_get_session_cache_mode
Returns the currently used cache mode (bitmask).
my
$rv
= Net::SSLeay::CTX_get_session_cache_mode(
$ctx
);
B<BEWARE:> SESS_CACHE_OFF 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 TLS library>
for
the current
values
.
=item * CTX_set_session_cache_mode
Enables/disables session caching by setting the operational mode
for
$ctx
to
$mode
.
my
$rv
= Net::SSLeay::CTX_set_session_cache_mode(
$ctx
,
$mode
);
For bitmask details see L</CTX_get_session_cache_mode> (above).
=item * CTX_get_timeout
Returns the currently set timeout value
for
$ctx
.
my
$rv
= Net::SSLeay::CTX_get_timeout(
$ctx
);
=item * CTX_get_verify_depth
Returns the verification depth limit currently set in
$ctx
. If
no
limit
has
been explicitly set, -1 is returned and the
default
value will be used.
my
$rv
= Net::SSLeay::CTX_get_verify_depth(
$ctx
);
=item * CTX_get_verify_mode
Returns the verification mode (bitmask) currently set in
$ctx
.
my
$rv
= Net::SSLeay::CTX_get_verify_mode(
$ctx
);
For bitmask details see L</
"CTX_set_verify"
>.
=item * CTX_set_verify
Sets the verification flags
for
$ctx
to be
$mode
and specifies the verify_callback function to be used.
Net::SSLeay::CTX_set_verify(
$ctx
,
$mode
,
$callback
);
=item * CTX_set_post_handshake_auth
B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and
before
; requires at least OpenSSL 1.1.1, not in LibreSSL
Enable the Post-Handshake Authentication extension to be added to the ClientHello such that post-handshake authentication can be requested by the server.
Net::SSLeay::CTX_set_posthandshake_auth(
$ctx
,
$val
);
=item * CTX_load_verify_locations
Specifies the locations
for
$ctx
, at which CA certificates
for
verification purposes are located. The certificates available via
$CAfile
and
$CApath
are trusted.
my
$rv
= Net::SSLeay::CTX_load_verify_locations(
$ctx
,
$CAfile
,
$CApath
);
=item * CTX_need_tmp_RSA
Return the result of C<SSL_CTX_ctrl(ctx,SSL_CTRL_NEED_TMP_RSA,0,NULL)>
my
$rv
= Net::SSLeay::CTX_need_tmp_RSA(
$ctx
);
Not available
with
OpenSSL 1.1 and later.
=item * CTX_new
The same as L</CTX_v23_new>
my
$rv
= Net::SSLeay::CTX_new();
Not available
with
OpenSSL 1.1 and later.
=item * CTX_v2_new
Creates a new SSL_CTX object - based on SSLv2_method() - as framework to establish TLS/SSL enabled connections.
my
$rv
= Net::SSLeay::CTX_v2_new();
=item * CTX_v23_new
Creates a new SSL_CTX object - based on SSLv23_method() - as framework to establish TLS/SSL enabled connections.
my
$rv
= Net::SSLeay::CTX_v23_new();
=item * CTX_v3_new
Creates a new SSL_CTX object - based on SSLv3_method() - as framework to establish TLS/SSL enabled connections.
my
$rv
= Net::SSLeay::CTX_v3_new();
=item * CTX_tlsv1_new
B<COMPATIBILITY:> Requires OpenSSL or LibreSSL built
with
support
for
TLSv1.
Creates a new SSL_CTX object - based on C<TLSv1_method()> - as a framework
for
establishing connections using TLSv1.
my
$rv
= Net::SSLeay::CTX_tlsv1_new();
=item * CTX_tlsv1_1_new
B<COMPATIBILITY:> Requires OpenSSL >= 1.0.1 or LibreSSL built
with
support
for
TLSv1.1.
Creates a new SSL_CTX object - based on C<TLSv1_1_method()> - as a framework
for
establishing connections using TLSv1.1.
my
$rv
= Net::SSLeay::CTX_tlsv1_1_new();
=item * CTX_tlsv1_2_new
B<COMPATIBILITY:> Requires OpenSSL >= 1.0.1 or LibreSSL built
with
support
for
TLSv1.2.
Creates a new SSL_CTX object - based on C<TLSv1_2_method()> - as a framework
for
establishing connections using TLSv1.2.
my
$rv
= Net::SSLeay::CTX_tlsv1_2_new();
=item * CTX_new_with_method
Creates a new SSL_CTX object based on
$meth
method
my
$rv
= Net::SSLeay::CTX_new_with_method(
$meth
);
my
$ctx
= Net::SSLeay::CTX_new_with_method(
&Net::SSLeay::TLSv1_method
);
=item * CTX_set_min_proto_version, CTX_set_max_proto_version, set_min_proto_version and set_max_proto_version,
B<COMPATIBILITY:> not available in Net-SSLeay-1.82 and
before
; requires at least OpenSSL 1.1.0-pre2 or LibreSSL 2.6.0
Set the minimum and maximum supported protocol
for
$ctx
or
$ssl
.
my
$rv
= Net::SSLeay::CTX_set_min_proto_version(
$ctx
,
$version
);
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());
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());
=item * CTX_get_min_proto_version, CTX_get_max_proto_version, get_min_proto_version and get_max_proto_version,
B<COMPATIBILITY:> not available in Net-SSLeay-1.82 and
before
; requires at least OpenSSL 1.1.0g
Get the minimum and maximum supported protocol
for
$ctx
or
$ssl
.
my
$version
= Net::SSLeay::CTX_get_min_proto_version(
$ctx
);
=item * CTX_remove_session
Removes the session
$ses
from the context
$ctx
.
my
$rv
= Net::SSLeay::CTX_remove_session(
$ctx
,
$ses
);
=item * CTX_sess_accept
my
$rv
= Net::SSLeay::CTX_sess_accept(
$ctx
);
=item * CTX_sess_accept_good
my
$rv
= Net::SSLeay::CTX_sess_accept_good(
$ctx
);
=item * CTX_sess_accept_renegotiate
my
$rv
= Net::SSLeay::CTX_sess_accept_renegotiate(
$ctx
);
=item * CTX_sess_cache_full
my
$rv
= Net::SSLeay::CTX_sess_cache_full(
$ctx
);
=item * CTX_sess_cb_hits
my
$rv
= Net::SSLeay::CTX_sess_cb_hits(
$ctx
);
=item * CTX_sess_connect
my
$rv
= Net::SSLeay::CTX_sess_connect(
$ctx
);
=item * CTX_sess_connect_good
my
$rv
= Net::SSLeay::CTX_sess_connect_good(
$ctx
);
=item * CTX_sess_connect_renegotiate
my
$rv
= Net::SSLeay::CTX_sess_connect_renegotiate(
$ctx
);
=item * CTX_sess_get_cache_size
Returns the currently valid session cache size.
my
$rv
= Net::SSLeay::CTX_sess_get_cache_size(
$ctx
);
=item * CTX_sess_hits
my
$rv
= Net::SSLeay::CTX_sess_hits(
$ctx
);
=item * CTX_sess_misses
my
$rv
= Net::SSLeay::CTX_sess_misses(
$ctx
);
=item * CTX_sess_number
my
$rv
= Net::SSLeay::CTX_sess_number(
$ctx
);
=item * CTX_sess_set_cache_size
Sets the size of the internal session cache of context
$ctx
to
$size
.
Net::SSLeay::CTX_sess_set_cache_size(
$ctx
,
$size
);
=item * CTX_sess_timeouts
Returns the number of sessions proposed by clients and either found in the internal or external session cache in
server mode, but that were invalid due to timeout. These sessions are not included in the SSL_CTX_sess_hits count.
my
$rv
= Net::SSLeay::CTX_sess_timeouts(
$ctx
);
=item * CTX_sess_set_new_cb
B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and
before
Sets the callback function, which is automatically called whenever a new session was negotiated.
Net::SSLeay::CTX_sess_set_new_cb(
$ctx
,
$func
);
=item * CTX_sess_set_remove_cb
B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and
before
Sets the callback function, which is automatically called whenever a session is removed by the SSL engine.
Net::SSLeay::CTX_sess_set_remove_cb(
$ctx
,
$func
);
=item * CTX_sessions
Returns a pointer to the lhash databases containing the internal session cache
for
ctx.
my
$rv
= Net::SSLeay::CTX_sessions(
$ctx
);
=item * CTX_set1_param
B<COMPATIBILITY:> requires at least OpenSSL 1.0.0-beta3
Applies X509 verification parameters
$vpm
on
$ctx
my
$rv
= Net::SSLeay::CTX_set1_param(
$ctx
,
$vpm
);
=item * CTX_set_cert_store
Sets/replaces the certificate verification storage of
$ctx
to/
with
$store
.
Net::SSLeay::CTX_set_cert_store(
$ctx
,
$store
);
=item * CTX_set_cert_verify_callback
Sets the verification callback function
for
$ctx
. SSL objects that are created from
$ctx
inherit the setting valid at the
time
when
C<Net::SSLeay::new(
$ctx
)> is called.
Net::SSLeay::CTX_set_cert_verify_callback(
$ctx
,
$func
,
$data
);
=item * CTX_set_cipher_list
Sets the list of available ciphers
for
$ctx
using the control string
$str
.
The list of ciphers is inherited by all ssl objects created from
$ctx
.
my
$rv
= Net::SSLeay::CTX_set_cipher_list(
$s
,
$str
);
=item * CTX_set_ciphersuites
B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and
before
; requires at least OpenSSL 1.1.1 or at least LibreSSL 3.4.0 and Net-SSLeay-1.94
Configure the available TLSv1.3 ciphersuites.
my
$rv
= Net::SSLeay::CTX_set_ciphersuites(
$ctx
,
$str
);
=item * CTX_set_client_CA_list
Sets the list of CAs sent to the client
when
requesting a client certificate
for
$ctx
.
Net::SSLeay::CTX_set_client_CA_list(
$ctx
,
$list
);
=item * CTX_set_default_passwd_cb
Sets the
default
password callback called
when
loading/storing a PEM certificate
with
encryption.
Net::SSLeay::CTX_set_default_passwd_cb(
$ctx
,
$func
);
=item * CTX_set_default_passwd_cb_userdata
Sets a pointer to userdata which will be provided to the password callback on invocation.
Net::SSLeay::CTX_set_default_passwd_cb_userdata(
$ctx
,
$userdata
);
=item * CTX_set_default_verify_paths
??? (more info needed)
my
$rv
= Net::SSLeay::CTX_set_default_verify_paths(
$ctx
);
=item * CTX_set_ex_data
Is used to store application data at
$data
for
$idx
into the
$ctx
object.
my
$rv
= Net::SSLeay::CTX_set_ex_data(
$ssl
,
$idx
,
$data
);
=item * CTX_set_purpose
my
$rv
= Net::SSLeay::CTX_set_purpose(
$s
,
$purpose
);
$purpose
=
&Net::SSLeay::X509_PURPOSE_SSL_CLIENT
;
$purpose
=
&Net::SSLeay::X509_PURPOSE_TIMESTAMP_SIGN
;
=item * CTX_set_quiet_shutdown
Sets the
'quiet shutdown'
flag
for
$ctx
to be mode. SSL objects created from
$ctx
inherit the mode valid at the
time
C<Net::SSLeay::new(
$ctx
)> is called.
Net::SSLeay::CTX_set_quiet_shutdown(
$ctx
,
$mode
);
=item * CTX_set_read_ahead
my
$rv
= Net::SSLeay::CTX_set_read_ahead(
$ctx
,
$val
);
=item * CTX_set_session_id_context
Sets the context
$sid_ctx
of
length
$sid_ctx_len
within which a session can be reused
for
the
$ctx
object.
my
$rv
= Net::SSLeay::CTX_set_session_id_context(
$ctx
,
$sid_ctx
,
$sid_ctx_len
);
=item * CTX_set_ssl_version
Sets a new
default
TLS/SSL method
for
SSL objects newly created from this
$ctx
.
SSL objects already created
with
C<Net::SSLeay::new(
$ctx
)> are not
affected, except
when
C<Net::SSLeay:clear(
$ssl
)> is being called.
my
$rv
= Net::SSLeay::CTX_set_ssl_version(
$ctx
,
$meth
);
=item * CTX_set_timeout
Sets the timeout
for
newly created sessions
for
$ctx
to
$t
. The timeout value
$t
must be
given
in seconds.
my
$rv
= Net::SSLeay::CTX_set_timeout(
$ctx
,
$t
);
=item * CTX_set_tmp_dh
Sets DH parameters to be used to be
$dh
. The key is inherited by all ssl objects created from
$ctx
.
my
$rv
= Net::SSLeay::CTX_set_tmp_dh(
$ctx
,
$dh
);
=item * CTX_set_tmp_dh_callback
Sets the callback function
for
$ctx
to be used
when
a DH parameters are required to
$tmp_dh_callback
.
Net::SSLeay::CTX_set_tmp_dh_callback(
$ctx
,
$tmp_dh_callback
);
=item * CTX_set_tmp_rsa
Sets the temporary/ephemeral RSA key to be used to be
$rsa
.
my
$rv
= Net::SSLeay::CTX_set_tmp_rsa(
$ctx
,
$rsa
);
Not available
with
OpenSSL 1.1 and later.
=item * CTX_set_tmp_rsa_callback
Sets the callback function
for
ctx to be used
when
a temporary/ephemeral RSA key is required to
$tmp_rsa_callback
.
??? (does this function really work?)
Net::SSLeay::CTX_set_tmp_rsa_callback(
$ctx
,
$tmp_rsa_callback
);
Not available
with
OpenSSL 1.1 and later.
=item * CTX_set_trust
my
$rv
= Net::SSLeay::CTX_set_trust(
$s
,
$trust
);
$trust
=
&Net::SSLeay::X509_TRUST_COMPAT
;
$trust
=
&Net::SSLeay::X509_TRUST_TSA
;
=item * CTX_set_verify_depth
Sets the maximum depth
for
the certificate chain verification that shall be allowed
for
ctx.
Net::SSLeay::CTX_set_verify_depth(
$ctx
,
$depth
);
=item * CTX_use_PKCS12_file
Adds the certificate and private key from PKCS12 file
$p12filename
to
$ctx
.
my
$rv
= Net::SSLeay::CTX_use_PKCS12_file(
$ctx
,
$p12filename
,
$password
);
B<NOTE> Net::SSLeay 1.92_01 and earlier: With some combinations of
Windows, perl, compiler and compiler options, you may see a runtime
error
"no OPENSSL_Applink"
,
when
calling
Net::SSLeay::CTX_use_PKCS12_file. See README.Win32
for
more details.
=item * CTX_use_PrivateKey
Adds the private key
$pkey
to
$ctx
.
my
$rv
= Net::SSLeay::CTX_use_PrivateKey(
$ctx
,
$pkey
);
=item * CTX_use_PrivateKey_file
Adds the first private key found in
$file
to
$ctx
.
my
$rv
= Net::SSLeay::CTX_use_PrivateKey_file(
$ctx
,
$file
,
$type
);
=item * CTX_use_RSAPrivateKey
Adds the RSA private key
$rsa
to
$ctx
.
my
$rv
= Net::SSLeay::CTX_use_RSAPrivateKey(
$ctx
,
$rsa
);
=item * CTX_use_RSAPrivateKey_file
Adds the first RSA private key found in
$file
to
$ctx
.
my
$rv
= Net::SSLeay::CTX_use_RSAPrivateKey_file(
$ctx
,
$file
,
$type
);
=item * CTX_use_certificate
Loads the certificate
$x
into
$ctx
my
$rv
= Net::SSLeay::CTX_use_certificate(
$ctx
,
$x
);
=item * CTX_use_certificate_chain_file
Loads a certificate chain from
$file
into
$ctx
. The certificates must be in PEM
format
and must be sorted
starting
with
the subject's certificate (actual client or server certificate), followed by intermediate
CA certificates
if
applicable, and ending at the highest level (root) CA.
my
$rv
= Net::SSLeay::CTX_use_certificate_chain_file(
$ctx
,
$file
);
=item * CTX_use_certificate_file
Loads the first certificate stored in
$file
into
$ctx
.
my
$rv
= Net::SSLeay::CTX_use_certificate_file(
$ctx
,
$file
,
$type
);
=item * CTX_get_security_level
B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and
before
; requires at least OpenSSL 1.1.0 or at least LibreSSL 3.6.0 and Net-SSLeay-1.94
Returns the security level associated
with
$ctx
.
my
$level
= Net::SSLeay::CTX_get_security_level(
$ctx
);
=item * CTX_set_security_level
B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and
before
; requires at least OpenSSL 1.1.0 or at least LibreSSL 3.6.0 and Net-SSLeay-1.94
Sets the security level associated
with
$ctx
to
$level
.
Net::SSLeay::CTX_set_security_level(
$ctx
,
$level
);
=item * CTX_set_num_tickets
B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and
before
; requires at least OpenSSL 1.1.1 or at least LibreSSL 3.5.0 and Net-SSLeay-1.94
Set number of TLSv1.3 session tickets that will be sent to a client.
my
$rv
= Net::SSLeay::CTX_set_num_tickets(
$ctx
,
$number_of_tickets
);
Set to zero
if
you
do
not
no
want to support a session resumption.
=item * CTX_get_num_tickets
B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and
before
; requires at least OpenSSL 1.1.1 or at least LibreSSL 3.5.0 and Net-SSLeay-1.94
Get number of TLSv1.3 session tickets that will be sent to a client.
my
$number_of_tickets
= Net::SSLeay::CTX_get_num_tickets(
$ctx
);
=item * CTX_set_keylog_callback
B<COMPATIBILITY:> not available in Net-SSLeay-1.90 and
before
; requires at least OpenSSL 1.1.1pre1 or at least LibreSSL 3.5.0 and Net-SSLeay-1.94
Set the TLS key logging callback.
Net::SSLeay::CTX_set_keylog_callback(
$ctx
,
$cb
);
The callback function will be called like this:
keylog_cb_func(
$ssl
,
$line
);
=item * CTX_get_keylog_callback
B<COMPATIBILITY:> not available in Net-SSLeay-1.90 and
before
; requires at least OpenSSL 1.1.1pre1 or at least LibreSSL 3.5.0 and Net-SSLeay-1.94
Retrieve the previously set TLS key logging callback.
my
$cb
= Net::SSLeay::CTX_get_keylog_callback(
$ctx
);
=item * CTX_set_client_hello_cb
B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and
before
; requires at least OpenSSL 1.1.1pre1, not in LibreSSL
Set a callback function called during the early stages of ClientHello processing on the server.
When callback is
undef
, the existing callback is disabled.
Net::SSLeay::CTX_set_client_hello_cb(
$ctx
,
$f
, [
$arg
]);
The callback function will be called like this:
client_hello_cb_func(
$ssl
,
$arg
);
=back
=head3 Low level API: SSL_* related functions
B<NOTE:> Please note that the function described in this chapter have
"SSL_"
part stripped from their original openssl names.
=over
=item * new
Creates a new SSL structure which is needed to hold the data
for
a TLS/SSL connection.
The new structure inherits the settings of the underlying context
$ctx
: connection
method (SSLv2/v3/TLSv1), options, verification settings, timeout settings.
my
$rv
= Net::SSLeay::new(
$ctx
);
=item *
accept
Waits
for
a TLS/SSL client to initiate the TLS/SSL handshake. The communication
channel must already have been set and assigned to the ssl by setting an underlying BIO.
my
$rv
= Net::SSLeay::
accept
(
$ssl
);
=item * add_client_CA
Adds the CA name extracted from cacert to the list of CAs sent to the client
when
requesting a client certificate
for
the chosen ssl, overriding the setting
valid
for
ssl's SSL_CTX object.
my
$rv
= Net::SSLeay::add_client_CA(
$ssl
,
$x
);
=item * callback_ctrl
??? (more info needed)
my
$rv
= Net::SSLeay::callback_ctrl(
$ssl
,
$cmd
,
$fp
);
=item * check_private_key
Checks the consistency of a private key
with
the corresponding certificate loaded into
$ssl
my
$rv
= Net::SSLeay::check_private_key(
$ssl
);
=item * clear
Reset SSL object to allow another connection.
Net::SSLeay::clear(
$ssl
);
=item *
connect
Initiate the TLS/SSL handshake
with
an TLS/SSL server.
my
$rv
= Net::SSLeay::
connect
(
$ssl
);
=item * copy_session_id
Copies the session structure fro
$from
to
$to
(+ also the private key and certificate associated
with
$from
).
Net::SSLeay::copy_session_id(
$to
,
$from
);
=item * ctrl
Internal handling function
for
SSL objects.
B<BEWARE:> openssl doc says: This function should never be called directly!
my
$rv
= Net::SSLeay::ctrl(
$ssl
,
$cmd
,
$larg
,
$parg
);
For more details about valid
$cmd
values
check L</CTX_ctrl>.
=item * do_handshake
Will
wait
for
a SSL/TLS handshake to take place. If the connection is in client
mode, the handshake will be started. The handshake routines may have to be
explicitly set in advance using either SSL_set_connect_state or SSL_set_accept_state(3).
my
$rv
= Net::SSLeay::do_handshake(
$ssl
);
=item * dup
Returns a duplicate of
$ssl
.
my
$rv
= Net::SSLeay::dup(
$ssl
);
=item * free
Free an allocated SSL structure.
Net::SSLeay::free(
$ssl
);
=item * get0_param
B<COMPATIBILITY:> not available in Net-SSLeay-1.82 and
before
; requires at least OpenSSL 1.0.2-beta1 or LibreSSL 2.7.0
Returns the current verification parameters.
my
$vpm
= Net::SSLeay::get0_param(
$ssl
);
=item * get_SSL_CTX
Returns a pointer to the SSL_CTX object, from which
$ssl
was created
with
Net::SSLeay::new.
my
$rv
= Net::SSLeay::get_SSL_CTX(
$ssl
);
=item * set_SSL_CTX
B<COMPATIBILITY:> requires at least OpenSSL 0.9.8f
Sets the SSL_CTX the corresponds to an SSL session.
my
$the_ssl_ctx
= Net::SSLeay::set_SSL_CTX(
$ssl
,
$ssl_ctx
);
=item * get_app_data
Can be used to get application
defined
value/data.
my
$rv
= Net::SSLeay::get_app_data(
$ssl
);
=item * set_app_data
Can be used to set some application
defined
value/data.
my
$rv
= Net::SSLeay::set_app_data(
$ssl
,
$arg
);
=item * get_certificate
Gets X509 certificate from an established SSL connection.
my
$rv
= Net::SSLeay::get_certificate(
$ssl
);
=item * get_cipher
Obtains the name of the currently used cipher.
my
$rv
= Net::SSLeay::get_cipher(
$ssl
);
=item * get_cipher_bits
Obtain the number of secret/algorithm bits used.
my
$rv
= Net::SSLeay::get_cipher_bits(
$ssl
);
=item * get_ciphers
B<COMPATIBILITY:> not available in Net-SSLeay-1.88 and
before
Returns a list of SSL_CIPHER structures available
for
$ssl
sorted by preference
my
@ciphers
= Net::SSLeay::get_ciphers(
$ssl
);
Example:
my
@ciphers
= Net::SSLeay::get_ciphers(
$ssl
);
foreach
my
$c
(
@ciphers
) {
print
Net::SSLeay::CIPHER_get_name(
$c
) .
"\n"
;
}
=item * get_cipher_list
Returns the name (string) of the SSL_CIPHER listed
for
$ssl
with
priority
$n
.
my
$rv
= Net::SSLeay::get_cipher_list(
$ssl
,
$n
);
Call Net::SSLeay::get_cipher_list
with
priority starting from 0 to obtain
the sorted list of available ciphers,
until
undef
is returned:
my
$priority
= 0;
while
(
my
$c
= Net::SSLeay::get_cipher_list(
$ssl
,
$priority
)) {
print
"cipher[$priority] = $c\n"
;
$priority
++;
}
=item * get_client_CA_list
Returns the list of client CAs explicitly set
for
$ssl
using C<Net::SSLeay::set_client_CA_list>
or
$ssl
's SSL_CTX object
with
C<Net::SSLeay::CTX_set_client_CA_list>,
when
in server mode.
In client mode, returns the list of client CAs sent from the server,
if
any.
my
$rv
= Net::SSLeay::get_client_CA_list(
$ssl
);
=item * get_current_cipher
Returns the cipher actually used.
my
$rv
= Net::SSLeay::get_current_cipher(
$ssl
);
=item * get_default_timeout
Returns the
default
timeout value assigned to SSL_SESSION objects negotiated
for
the protocol valid
for
$ssl
.
my
$rv
= Net::SSLeay::get_default_timeout(
$ssl
);
=item * get_error
Returns a result code
for
a preceding call to C<
connect
>, C<
accept
>, C<do_handshake>, C<
read
>, C<peek> or C<
write
> on
$ssl
.
my
$rv
= Net::SSLeay::get_error(
$ssl
,
$ret
);
=item * get_ex_data
Is used to retrieve the information
for
$idx
from
$ssl
.
my
$rv
= Net::SSLeay::get_ex_data(
$ssl
,
$idx
);
=item * set_ex_data
Is used to store application data at
$data
for
$idx
into the
$ssl
object.
my
$rv
= Net::SSLeay::set_ex_data(
$ssl
,
$idx
,
$data
);
=item * get_ex_new_index
Is used to register a new
index
for
application specific data.
my
$rv
= Net::SSLeay::get_ex_new_index(
$argl
,
$argp
,
$new_func
,
$dup_func
,
$free_func
);
=item * get_fd
Returns the file descriptor which is linked to
$ssl
.
my
$rv
= Net::SSLeay::get_fd(
$ssl
);
=item * get_finished
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
.
my
$rv
= Net::SSLeay::get_finished(
$ssl
,
$buf
,
$count
);
=item * get_peer_finished
Obtains the latest
'Finished'
message expected from the
peer. Parameters and
return
value are similar to get_finished().
my
$rv
= Net::SSLeay::get_peer_finished(
$ssl
,
$buf
,
$count
);
=item * get_keyblock_size
Gets the
length
of the TLS keyblock. Look
for
'key_block'
in TLS 1.2
and earlier TLS RFCs. Consider using TLS exporter interface
defined
by
RFC 5705 instead of creating your own keying material exporter.
B<NOTE:> Does not exactly correspond to any low level API function. Intended
for
EAP-FAST.
my
$rv
= Net::SSLeay::get_keyblock_size(
$ssl
);
=item * get_mode
Returns the mode (bitmask) set
for
$ssl
.
my
$rv
= Net::SSLeay::get_mode(
$ssl
);
To decode the
return
value (bitmask) see documentation
for
L</CTX_get_mode>.
=item * set_mode
Adds the mode set via bitmask in
$mode
to
$ssl
. Options already set
before
are not cleared.
my
$rv
= Net::SSLeay::set_mode(
$ssl
,
$mode
);
For
$mode
bitmask details see L</CTX_get_mode>.
=item * get_options
Returns the options (bitmask) set
for
$ssl
.
my
$rv
= Net::SSLeay::get_options(
$ssl
);
To decode the
return
value (bitmask) see documentation
for
L</CTX_get_options>.
=item * set_options
Adds the options set via bitmask in
$options
to
$ssl
. Options already set
before
are not cleared!
Net::SSLeay::set_options(
$ssl
,
$options
);
For
$options
bitmask details see L</CTX_get_options>.
=item * get_peer_certificate
Get the X509 certificate of the peer.
my
$rv
= Net::SSLeay::get_peer_certificate(
$ssl
);
=item * get_peer_cert_chain
Get the certificate chain of the peer as an array of X509 structures.
my
@chain
= Net::SSLeay::get_peer_cert_chain(
$ssl
);
Example:
my
@chain
= Net::SSLeay::get_peer_cert_chain(
$ssl
);
foreach
my
$x509
(
@chain
) {
print
Net::SSLeay::X509_NAME_oneline(Net::SSLeay::X509_get_subject_name(
$cert
)) .
"\n"
;
}
=item * get_quiet_shutdown
Returns the
'quiet shutdown'
setting of ssl.
my
$rv
= Net::SSLeay::get_quiet_shutdown(
$ssl
);
=item * get_rbio
Get
'read'
BIO linked to an SSL object
$ssl
.
my
$rv
= Net::SSLeay::get_rbio(
$ssl
);
=item * get_read_ahead
my
$rv
= Net::SSLeay::get_read_ahead(
$ssl
);
=item * set_read_ahead
Net::SSLeay::set_read_ahead(
$ssl
,
$val
);
=item * get_security_level
B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and
before
; requires at least OpenSSL 1.1.0 or at least LibreSSL 3.6.0 and Net-SSLeay-1.94
Returns the security level associated
with
$ssl
.
my
$level
= Net::SSLeay::get_security_level(
$ssl
);
=item * set_security_level
B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and
before
; requires at least OpenSSL 1.1.0 or at least LibreSSL 3.6.0 and Net-SSLeay-1.94
Sets the security level associated
with
$ssl
to
$level
.
Net::SSLeay::set_security_level(
$ssl
,
$level
);
=item * set_num_tickets
B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and
before
; requires at least OpenSSL 1.1.1 or at least LibreSSL 3.5.0 and Net-SSLeay-1.94
Set number of TLSv1.3 session tickets that will be sent to a client.
my
$rv
= Net::SSLeay::set_num_tickets(
$ssl
,
$number_of_tickets
);
Set to zero
if
you
do
not
no
want to support a session resumption.
=item * get_num_tickets
B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and
before
; requires at least OpenSSL 1.1.1 or at least LibreSSL 3.5.0 and Net-SSLeay-1.94
Get number of TLSv1.3 session tickets that will be sent to a client.
my
$number_of_tickets
= Net::SSLeay::get_num_tickets(
$ctx
);
=item * get_server_random
Returns internal SSLv3 server_random value.
Net::SSLeay::get_server_random(
$ssl
);
=item * get_client_random
B<NOTE:> Does not exactly correspond to any low level API function
Returns internal SSLv3 client_random value.
Net::SSLeay::get_client_random(
$ssl
);
=item * export_keying_material
Returns keying material based on the string
$label
and optional
$context
. Note that
with
TLSv1.2 and lower, empty context (empty
string) and undefined context (
no
value or
'undef'
) will
return
different
values
.
my
$out
= Net::SSLeay::export_keying_material(
$ssl
,
$olen
,
$label
,
$context
);
=item * get_session
Retrieve TLS/SSL session data used in
$ssl
. The reference count of the SSL_SESSION is NOT incremented.
my
$rv
= Net::SSLeay::get_session(
$ssl
);
=item * SSL_get0_session
The alias
for
L</get_session> (note that the name is C<SSL_get0_session> NOT C<get0_session>).
my
$rv
= Net::SSLeay::SSL_get0_session();
=item * get1_session
Returns a pointer to the SSL_SESSION actually used in
$ssl
. The reference count of the SSL_SESSION is incremented by 1.
my
$rv
= Net::SSLeay::get1_session(
$ssl
);
=item * get_shared_ciphers
Returns string
with
a list (colon
':'
separated) of ciphers shared between client and server
within SSL session
$ssl
.
my
$rv
= Net::SSLeay::get_shared_ciphers();
=item * get_shutdown
Returns the
shutdown
mode of
$ssl
.
my
$rv
= Net::SSLeay::get_shutdown(
$ssl
);
=item * get_ssl_method
Returns a function pointer to the TLS/SSL method set in
$ssl
.
my
$rv
= Net::SSLeay::get_ssl_method(
$ssl
);
=item * in_init, in_before, is_init_finished, in_connect_init, in_accept_init
B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and
before
.
Retrieve information about the handshake state machine. All functions take
$ssl
as the only argument and
return
0 or 1. These functions are recommended over get_state() and state().
my
$rv
= Net::SSLeay::is_init_finished(
$ssl
);
=item * get_state
B<COMPATIBILITY:> OpenSSL 1.1.0 and later
use
different constants which are not made available. Use is_init_finished() and related functions instead.
Returns the SSL connection state.
my
$rv
= Net::SSLeay::get_state(
$ssl
);
=item * state
Exactly the same as L</get_state>.
my
$rv
= Net::SSLeay::state(
$ssl
);
=item * set_state
Sets the SSL connection state.
Net::SSLeay::set_state(
$ssl
,Net::SSLeay::SSL_ST_ACCEPT());
Not available
with
OpenSSL 1.1 and later.
=item * get_verify_depth
Returns the verification depth limit currently set in
$ssl
.
my
$rv
= Net::SSLeay::get_verify_depth(
$ssl
);
=item * set_verify_depth
Sets the maximum depth
for
the certificate chain verification that shall be allowed
for
$ssl
.
Net::SSLeay::set_verify_depth(
$ssl
,
$depth
);
=item * get_verify_mode
Returns the verification mode (bitmask) currently set in
$ssl
.
my
$rv
= Net::SSLeay::get_verify_mode(
$ssl
);
To decode the
return
value (bitmask) see documentation
for
L</CTX_get_verify_mode>.
=item * set_verify
Sets the verification flags
for
$ssl
to be
$mode
and specifies the
$verify_callback
function to be used.
Net::SSLeay::set_verify(
$ssl
,
$mode
,
$callback
);
For
$mode
bitmask details see L</CTX_get_verify_mode>.
=item * set_post_handshake_auth
B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and
before
; requires at least OpenSSL 1.1.1, not in LibreSSL
Enable the Post-Handshake Authentication extension to be added to the ClientHello such that post-handshake authentication can be requested by the server.
Net::SSLeay::set_posthandshake_auth(
$ssl
,
$val
);
=item * verify_client_post_handshake
B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and
before
; requires at least OpenSSL 1.1.1, not in LibreSSL
verify_client_post_handshake causes a CertificateRequest message to be sent by a server on the
given
ssl connection.
my
$rv
= Net::SSLeay::verify_client_post_handshake(
$ssl
);
=item * get_verify_result
Returns the result of the verification of the X509 certificate presented by the peer,
if
any.
my
$rv
= Net::SSLeay::get_verify_result(
$ssl
);
=item * set_verify_result
Override result of peer certificate verification.
Net::SSLeay::set_verify_result(
$ssl
,
$v
);
For more info about valid
return
values
see L</get_verify_result>
=item * get_wbio
Get
'write'
BIO linked to an SSL object
$ssl
.
my
$rv
= Net::SSLeay::get_wbio(
$ssl
);
=item * load_client_CA_file
Load X509 certificates from file (PEM formatted).
my
$rv
= Net::SSLeay::load_client_CA_file(
$file
);
=item * clear_num_renegotiations
Executes SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS command on
$ssl
.
my
$rv
= Net::SSLeay::clear_num_renegotiations(
$ssl
);
=item * need_tmp_RSA
Executes SSL_CTRL_NEED_TMP_RSA command on
$ssl
.
my
$rv
= Net::SSLeay::need_tmp_RSA(
$ssl
);
Not available
with
OpenSSL 1.1 and later.
=item * num_renegotiations
Executes SSL_CTRL_GET_NUM_RENEGOTIATIONS command on
$ssl
.
my
$rv
= Net::SSLeay::num_renegotiations(
$ssl
);
=item * total_renegotiations
Executes SSL_CTRL_GET_TOTAL_RENEGOTIATIONS command on
$ssl
.
my
$rv
= Net::SSLeay::total_renegotiations(
$ssl
);
=item * peek
Copies
$max
bytes from the specified
$ssl
into the returned value.
In contrast to the C<Net::SSLeay::
read
()> function, the data in the SSL
buffer is unmodified
after
the SSL_peek() operation.
Net::SSLeay::peek(
$ssl
,
$max
);
=item * peek_ex
B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and
before
; requires at least OpenSSL 1.1.1, not in LibreSSL
Copies
$max
bytes from the specified
$ssl
into the returned value.
In contrast to the C<Net::SSLeay::read_ex()> function, the data in the SSL
buffer is unmodified
after
the SSL_peek_ex() operation.
my
(
$got
,
$rv
) = Net::SSLeay::peek_ex(
$ssl
,
$max
);
=item * pending
Obtain number of readable bytes buffered in
$ssl
object.
my
$rv
= Net::SSLeay::pending(
$ssl
);
=item * has_pending
B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and
before
; requires at least OpenSSL 1.1.0, not in LibreSSL
Returns 1
if
$ssl
has
buffered data (whether processed or unprocessed) and 0 otherwise.
my
$rv
= Net::SSLeay::has_pending(
$ssl
);
=item *
read
Tries to
read
$max
bytes from the specified
$ssl
.
my
$got
= Net::SSLeay::
read
(
$ssl
,
$max
);
my
(
$got
,
$rv
) = Net::SSLeay::
read
(
$ssl
,
$max
);
=item * read_ex
B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and
before
; requires at least OpenSSL 1.1.1, not in LibreSSL
Tries to
read
$max
bytes from the specified
$ssl
.
my
(
$got
,
$rv
) = Net::SSLeay::read_ex(
$ssl
,
$max
);
=item * renegotiate
Turn on flags
for
renegotiation so that renegotiation will happen
my
$rv
= Net::SSLeay::renegotiate(
$ssl
);
=item * rstate_string
Returns a 2 letter string indicating the current
read
state of the SSL object
$ssl
.
my
$rv
= Net::SSLeay::rstate_string(
$ssl
);
=item * rstate_string_long
Returns a string indicating the current
read
state of the SSL object ssl.
my
$rv
= Net::SSLeay::rstate_string_long(
$ssl
);
=item * session_reused
Query whether a reused session was negotiated during handshake.
my
$rv
= Net::SSLeay::session_reused(
$ssl
);
=item * set1_param
B<COMPATIBILITY:> requires at least OpenSSL 1.0.0-beta3
Applies X509 verification parameters
$vpm
on
$ssl
my
$rv
= Net::SSLeay::set1_param(
$ssl
,
$vpm
);
=item * set_accept_state
Sets
$ssl
to work in server mode.
Net::SSLeay::set_accept_state(
$ssl
);
=item * set_bio
Connects the BIOs
$rbio
and
$wbio
for
the
read
and
write
operations of the TLS/SSL (encrypted) side of
$ssl
.
Net::SSLeay::set_bio(
$ssl
,
$rbio
,
$wbio
);
=item * set_cipher_list
Sets the list of ciphers only
for
ssl.
my
$rv
= Net::SSLeay::set_cipher_list(
$ssl
,
$str
);
=item * set_ciphersuites
B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and
before
; requires at least OpenSSL 1.1.1 or at least LibreSSL 3.4.0 and Net-SSLeay-1.94
Configure the available TLSv1.3 ciphersuites.
my
$rv
= Net::SSLeay::set_ciphersuites(
$ssl
,
$str
);
=item * set_client_CA_list
Sets the list of CAs sent to the client
when
requesting a client certificate
for
the chosen
$ssl
, overriding the setting valid
for
$ssl
's SSL_CTX object.
my
$rv
= Net::SSLeay::set_client_CA_list(
$ssl
,
$list
);
=item * set_connect_state
Sets
$ssl
to work in client mode.
Net::SSLeay::set_connect_state(
$ssl
);
=item * set_fd
Sets the file descriptor
$fd
as the input/output facility
for
the TLS/SSL (encrypted)
side of
$ssl
,
$fd
will typically be the
socket
file descriptor of a network connection.
my
$rv
= Net::SSLeay::set_fd(
$ssl
,
$fd
);
=item * set_psk_client_callback
Sets the psk client callback.
Net::SSLeay::set_psk_client_callback(
$ssl
,
sub
{
my
$hint
=
shift
;
return
(
$identity
,
$key
) } );
=item * set_rfd
Sets the file descriptor
$fd
as the input (
read
) facility
for
the TLS/SSL (encrypted) side of
$ssl
.
my
$rv
= Net::SSLeay::set_rfd(
$ssl
,
$fd
);
=item * set_wfd
my
$rv
= Net::SSLeay::set_wfd(
$ssl
,
$fd
);
=item * set_info_callback
Sets the callback function, that can be used to obtain state information
for
$ssl
during connection setup and
use
.
When callback is
undef
, the callback setting currently valid
for
ctx is used.
Net::SSLeay::set_info_callback(
$ssl
,
$cb
, [
$data
]);
=item * CTX_set_info_callback
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.
Net::SSLeay::CTX_set_info_callback(
$ssl
,
$cb
, [
$data
]);
=item * set_msg_callback
Sets the callback function, that can be used to obtain protocol messages information
for
$ssl
during connection setup and
use
.
When callback is
undef
, the callback setting currently valid
for
ctx is used.
Note that set_msg_callback_arg is not provided as there is
no
need to explicitly set
$arg
, this is handled by set_msg_callback.
Net::SSLeay::set_msg_callback(
$ssl
,
$cb
, [
$arg
]);
=item * CTX_set_msg_callback
Sets the callback function on ctx, that can be used to obtain protocol messages information
for
ssl connection setup and
use
.
When callback is
undef
, the existing callback will be disabled.
Note that CTX_set_msg_callback_arg is not provided as there is
no
need to explicitly set
$arg
, this is handled by CTX_set_msg_callback.
Net::SSLeay::CTX_set_msg_callback(
$ssl
,
$cb
, [
$arg
]);
=item * set_pref_cipher
Sets the list of available ciphers
for
$ssl
using the control string
$str
.
my
$rv
= Net::SSLeay::set_pref_cipher(
$ssl
,
$str
);
=item * CTX_set_psk_client_callback
Sets the psk client callback.
Net::SSLeay::CTX_set_psk_client_callback(
$ssl
,
sub
{
my
$hint
=
shift
;
return
(
$identity
,
$key
) } );
=item * set_purpose
my
$rv
= Net::SSLeay::set_purpose(
$ssl
,
$purpose
);
For more info about available
$purpose
identifiers see L</CTX_set_purpose>.
=item * set_quiet_shutdown
Sets the
'quiet shutdown'
flag
for
$ssl
to be
$mode
.
Net::SSLeay::set_quiet_shutdown(
$ssl
,
$mode
);
=item * set_session
Set a TLS/SSL session to be used during TLS/SSL
connect
.
my
$rv
= Net::SSLeay::set_session(
$to
,
$ses
);
=item * set_session_id_context
Sets the context
$sid_ctx
of
length
$sid_ctx_len
within which a session can be reused
for
the
$ssl
object.
my
$rv
= Net::SSLeay::set_session_id_context(
$ssl
,
$sid_ctx
,
$sid_ctx_len
);
=item * set_session_secret_cb
Setup pre-shared secret session resumption function.
Net::SSLeay::set_session_secret_cb(
$ssl
,
$func
,
$data
);
The callback function will be called like:
callback_function(
$secret
,
$ciphers
,
$pref_cipher
,
$data
);
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).
With OpenSSL 1.1 and later, callback_function can change the master key
for
the session by
altering
$secret
and returning 1.
=item * CTX_set_tlsext_ticket_getkey_cb
Setup encryption
for
TLS session tickets (stateless session reuse).
Net::SSLeay::CTX_set_tlsext_ticket_getkey_cb(
$ctx
,
$func
,
$data
);
The callback function will be called like:
getkey(
$data
,[
$key_name
]) -> (
$key
,
$current_key_name
)
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.
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.
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 AES-128 encryption
while
the
next
16 byte are used
for
the SHA-256 HMAC.
The key name are binary data and must be exactly 16 byte long.
Example:
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
],
[
$oldkey_name
,
$oldkey
],
);
Net::SSLeay::CTX_set_tlsext_ticket_getkey_cb(
$server2
->_ctx,
sub
{
my
(
$mykeys
,
$name
) =
@_
;
return
(
$mykeys
->[0][1],
$mykeys
->[0][0])
if
!
$name
;
for
(
my
$i
= 0;
$i
<
@$mykeys
;
$i
++) {
next
if
$name
ne
$mykeys
->[
$i
][0];
return
(
$mykeys
->[
$i
][1],
$mykeys
->[0][0]);
}
return
;
},\
@keys
);
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
=item * set_session_ticket_ext_cb
Setup callback
for
TLS session tickets (stateless session reuse).
Net::SSLeay::set_session_ticket_ext_cb(
$ssl
,
$func
,
$data
);
The callback function will be called like:
getticket(
$ssl
,
$ticket
,
$data
) ->
$return_value
This function is based on the OpenSSL function SSL_set_session_ticket_ext_cb.
=item * set_session_ticket_ext
Set TLS session ticket (stateless session reuse).
Net::SSLeay::set_session_ticket_ext(
$ssl
,
$ticket
);
The callback function will be called like:
getticket(
$ssl
,
$ticket
,
$data
) ->
$return_value
This function is based on the OpenSSL function SSL_set_session_ticket_ext_cb.
=item * set_shutdown
Sets the
shutdown
state of
$ssl
to
$mode
.
Net::SSLeay::set_shutdown(
$ssl
,
$mode
);
=item * set_ssl_method
Sets a new TLS/SSL method
for
a particular
$ssl
object.
my
$rv
= Net::SSLeay::set_ssl_method(
$ssl
,
$method
);
=item * set_tmp_dh
Sets DH parameters to be used to be
$dh
.
my
$rv
= Net::SSLeay::set_tmp_dh(
$ssl
,
$dh
);
=item * set_tmp_dh_callback
Sets the callback function
for
$ssl
to be used
when
a DH parameters are required to
$dh_cb
.
??? (does this function really work?)
Net::SSLeay::set_tmp_dh_callback(
$ssl
,
$dh
);
=item * set_tmp_rsa
Sets the temporary/ephemeral RSA key to be used in
$ssl
to be
$rsa
.
my
$rv
= Net::SSLeay::set_tmp_rsa(
$ssl
,
$rsa
);
Example:
$rsakey
= Net::SSLeay::RSA_generate_key();
Net::SSLeay::set_tmp_rsa(
$ssl
,
$rsakey
);
Net::SSLeay::RSA_free(
$rsakey
);
=item * set_tmp_rsa_callback
Sets the callback function
for
$ssl
to be used
when
a temporary/ephemeral RSA key is required to
$tmp_rsa_callback
.
??? (does this function really work?)
Net::SSLeay::set_tmp_rsa_callback(
$ssl
,
$tmp_rsa_callback
);
=item * set_trust
my
$rv
= Net::SSLeay::set_trust(
$ssl
,
$trust
);
For more details about
$trust
values
see L</CTX_set_trust>.
=item *
shutdown
Shuts down an active TLS/SSL connection. It sends the
'close notify'
shutdown
alert to the peer.
my
$rv
= Net::SSLeay::
shutdown
(
$ssl
);
=item * state_string
Returns a 6 letter string indicating the current state of the SSL object
$ssl
.
my
$rv
= Net::SSLeay::state_string(
$ssl
);
=item * state_string_long
Returns a string indicating the current state of the SSL object
$ssl
.
my
$rv
= Net::SSLeay::state_string_long(
$ssl
);
=item * set_default_passwd_cb
B<COMPATIBILITY:> not available in Net-SSLeay-1.82 and
before
; requires at least OpenSSL 1.1.0f. Not needed
with
LibreSSL.
Sets the
default
password callback called
when
loading/storing a PEM certificate
with
encryption
for
$ssl
.
Net::SSLeay::set_default_passwd_cb(
$ssl
,
$func
);
=item * set_default_passwd_cb_userdata
B<COMPATIBILITY:> not available in Net-SSLeay-1.82 and
before
; requires at least OpenSSL 1.1.0f. Not needed
with
LibreSSL.
Sets a pointer to userdata which will be provided to the password callback of
$ssl
on invocation.
Net::SSLeay::set_default_passwd_cb_userdata(
$ssl
,
$userdata
);
=item * use_PrivateKey
Adds
$pkey
as private key to
$ssl
.
my
$rv
= Net::SSLeay::use_PrivateKey(
$ssl
,
$pkey
);
=item * use_PrivateKey_ASN1
Adds the private key of type
$pk
stored in
$data
to
$ssl
.
my
$rv
= Net::SSLeay::use_PrivateKey_ASN1(
$pk
,
$ssl
,
$d
,
$len
);
=item * use_PrivateKey_file
Adds the first private key found in
$file
to
$ssl
.
my
$rv
= Net::SSLeay::use_PrivateKey_file(
$ssl
,
$file
,
$type
);
=item * use_RSAPrivateKey
Adds
$rsa
as RSA private key to
$ssl
.
my
$rv
= Net::SSLeay::use_RSAPrivateKey(
$ssl
,
$rsa
);
=item * use_RSAPrivateKey_ASN1
Adds RSA private key stored in
$data
to
$ssl
.
my
$rv
= Net::SSLeay::use_RSAPrivateKey_ASN1(
$ssl
,
$data
,
$len
);
=item * use_RSAPrivateKey_file
Adds the first RSA private key found in
$file
to
$ssl
.
my
$rv
= Net::SSLeay::use_RSAPrivateKey_file(
$ssl
,
$file
,
$type
);
=item * use_certificate
Loads the certificate
$x
into
$ssl
.
my
$rv
= Net::SSLeay::use_certificate(
$ssl
,
$x
);
=item * use_certificate_ASN1
Loads the ASN1 encoded certificate from
$data
to
$ssl
.
my
$rv
= Net::SSLeay::use_certificate_ASN1(
$ssl
,
$data
,
$len
);
=item * use_certificate_chain_file
B<COMPATIBILITY>: not available in Net-SSLeay-1.82 and
before
; requires at least OpenSSL 1.1.0 or at least LibreSSL 3.6.0 and Net-SSLeay-1.94
Loads a certificate chain from
$file
into
$ssl
. The certificates must be in PEM
format
and must be sorted
starting
with
the subject's certificate (actual client or server certificate), followed by intermediate
CA certificates
if
applicable, and ending at the highest level (root) CA.
my
$rv
= Net::SSLeay::use_certificate_chain_file(
$ssl
,
$file
);
=item * use_certificate_file
Loads the first certificate stored in
$file
into
$ssl
.
my
$rv
= Net::SSLeay::use_certificate_file(
$ssl
,
$file
,
$type
);
=item * get_version
Returns SSL/TLS protocol name
my
$rv
= Net::SSLeay::get_version(
$ssl
);
=item * version
Returns SSL/TLS protocol version
my
$rv
= Net::SSLeay::version(
$ssl
);
=item * client_version
B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and
before
; requires at least OpenSSL 1.1.0, not in LibreSSL
Returns TLS protocol version used by the client
when
initiating the connection
my
$rv
= Net::SSLeay::client_version(
$ssl
);
=item * is_dtls
B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and
before
; requires at least OpenSSL 1.1.0 or at least LibreSSL 3.3.1 and Net-SSLeay-1.94
my
$rv
= Net::SSLeay::is_dtls(
$ssl
);
=item * want
Returns state information
for
the SSL object
$ssl
.
my
$rv
= Net::SSLeay::want(
$ssl
);
=item *
write
Writes data from the buffer
$data
into the specified
$ssl
connection.
my
$rv
= Net::SSLeay::
write
(
$ssl
,
$data
);
=item * write_ex
B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and
before
; requires at least OpenSSL 1.1.1, not in LibreSSL
Writes data from the buffer
$data
into the specified
$ssl
connection.
my
(
$len
,
$rv
) = Net::SSLeay::write_ex(
$ssl
,
$data
);
=item * write_partial
B<NOTE:> Does not exactly correspond to any low level API function
Writes a fragment of data in
$data
from the buffer
$data
into the specified
$ssl
connection. This is a non-blocking function like L<Net::SSLeay::
write
()>.
my
$rv
= Net::SSLeay::write_partial(
$ssl
,
$from
,
$count
,
$data
);
=item * set_tlsext_host_name
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
; requires at least OpenSSL 0.9.8f
Sets TLS servername extension on SSL object
$ssl
to value
$name
.
my
$rv
= set_tlsext_host_name(
$ssl
,
$name
);
=item * client_hello_isv2
B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and
before
; requires at least OpenSSL 1.1.1pre1, not in LibreSSL
B<NOTE:> to be used only from a callback set
with
L<CTX_set_client_hello_cb>.
Indicate
if
the ClientHello was carried in a SSLv2 record and is in the SSLv2
format
.
my
$rv
= client_hello_isv2(
$s
);
=item * client_hello_get0_legacy_version
B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and
before
; requires at least OpenSSL 1.1.1pre1, not in LibreSSL
B<NOTE:> to be used only from a callback set
with
L<CTX_set_client_hello_cb>.
Returns legacy_version, also known as client_version, field from the ClientHello.
my
$rv
= client_hello_get0_legacy_version(
$s
);
=item * client_hello_get0_random, client_hello_get0_session_id, client_hello_get0_ciphers and client_hello_get0_compression_methods
B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and
before
; requires at least OpenSSL 1.1.1pre1, not in LibreSSL
B<NOTE:> to be used only from a callback set
with
L<CTX_set_client_hello_cb>.
These functions
return
random, session_id, cipher_suites and compression_methods fields from the ClientHello, respectively.
my
$random
= client_hello_get0_random(
$s
);
my
$session_id
= client_hello_get0_session_id(
$s
);
my
$ciphers
= client_hello_get0_ciphers(
$s
);
my
$compression_methods
= client_hello_get0_compression_methods(
$s
);
=item * client_hello_get1_extensions_present and client_hello_get_extension_order
B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and
before
; requires at least OpenSSL 1.1.1pre1, not in LibreSSL
B<NOTE:> to be used only from a callback set
with
L<CTX_set_client_hello_cb>.
Returns a reference to an array holding the numerical value of the TLS extension types in the order they appear in the ClientHello. client_hello_get_extension_order is similar and requires at least OpenSSL 3.2.0, not in LibreSSL.
my
$ref
= client_hello_get1_extensions_present(
$s
);
Example from a TLS 1.3 ClientHello:
sub
client_hello_cb {
my
(
$ssl
,
$arg
) =
@_
;
my
$ref
= client_hello_get1_extensions_present(
$ssl
);
print
join
(
' '
,
@$ref
),
"\n"
if
$ref
;
}
Prints: C<11 10 35 22 23 13 43 45 51>
=item * client_hello_get0_ext
B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and
before
; requires at least OpenSSL 1.1.1pre1, not in LibreSSL
B<NOTE:> to be used only from a callback set
with
L<CTX_set_client_hello_cb>.
Returns an extension by type number from the ClientHello.
my
$ref
= client_hello_get1_extensions_present(
$s
,
$type
);
Example: Get the value of TLS extension C<supported_versions>. You can
use
constant C<TLSEXT_TYPE_supported_versions> or 43 directly.
sub
client_hello_cb {
my
(
$ssl
,
$arg
) =
@_
;
my
$ext_ver
= Net::SSLeay::client_hello_get0_ext(
$ssl
, Net::SSLeay::TLSEXT_TYPE_supported_versions());
print
unpack
(
'H*'
,
$ext_ver
),
"\n"
if
defined
$ext_ver
;
}
Prints: C<080304030303020301> where the first octet 0x08 is the extension
length
and the following four 16bit
values
correspond to TLS versions 1.3, 1.2, 1.1 and 1.0.
=back
=head3 Low level API: RAND_* related functions
=over
=item * RAND_add
Mixes the
$num
bytes at
$buf
into the PRNG state.
Net::SSLeay::RAND_add(
$buf
,
$num
,
$entropy
);
=item * RAND_seed
Equivalent to L</RAND_add>
when
$num
==
$entropy
.
Net::SSLeay::RAND_seed(
$buf
);
=item * RAND_status
Gives PRNG status (seeded enough or not).
my
$rv
= Net::SSLeay::RAND_status();
=item * RAND_bytes
Puts
$num
cryptographically strong pseudo-random bytes into
$buf
.
my
$rv
= Net::SSLeay::RAND_bytes(
$buf
,
$num
);
=item * RAND_priv_bytes
B<COMPATIBILITY:> not available in Net-SSLeay-1.85 and
before
; requires at least OpenSSL 1.1.1, not in LibreSSL
Puts
$num
cryptographically strong pseudo-random bytes into
$buf
.
my
$rv
= Net::SSLeay::RAND_priv_bytes(
$buf
,
$num
);
RAND_priv_bytes
has
the same semantics as RAND_bytes, but see see the documentation
for
more information.
=item * RAND_pseudo_bytes
Puts
$num
pseudo-random (not necessarily unpredictable) bytes into
$buf
.
my
$rv
= Net::SSLeay::RAND_pseudo_bytes(
$buf
,
$num
);
=item * RAND_cleanup
Erase the PRNG state.
Net::SSLeay::RAND_cleanup();
=item * RAND_egd_bytes
Queries the entropy gathering daemon EGD on
socket
$path
for
$bytes
bytes.
my
$rv
= Net::SSLeay::RAND_egd_bytes(
$path
,
$bytes
);
=item * RAND_file_name
Generates a
default
path
for
the random seed file.
my
$file
= Net::SSLeay::RAND_file_name(
$num
);
LibreSSL and OpenSSL 1.1.0a and later
return
undef
when
,
for
example,
$num
is not large enough to hold the filename.
=item * RAND_load_file
B<COMPATIBILITY:> Is
no
longer functional on LibreSSL
Reads
$max_bytes
of bytes from
$file_name
and adds them to the PRNG.
my
$rv
= Net::SSLeay::RAND_load_file(
$file_name
,
$max_bytes
);
=item * RAND_write_file
Writes 1024 random bytes to
$file_name
which can be used to initialize the PRNG by calling L</RAND_load_file> in a later session.
my
$rv
= Net::SSLeay::RAND_write_file(
$file_name
);
=item * RAND_poll
Collects some entropy from operating
system
and adds it to the PRNG.
my
$rv
= Net::SSLeay::RAND_poll();
=back
=head3 Low level API: OBJ_* related functions
=over
=item * OBJ_cmp
Compares ASN1_OBJECT
$a
to ASN1_OBJECT
$b
.
my
$rv
= Net::SSLeay::OBJ_cmp(
$a
,
$b
);
=item * OBJ_dup
Returns a copy/duplicate of
$o
.
my
$rv
= Net::SSLeay::OBJ_dup(
$o
);
=item * OBJ_nid2ln
Returns long name
for
given
NID
$n
.
my
$rv
= Net::SSLeay::OBJ_nid2ln(
$n
);
=item * OBJ_ln2nid
Returns NID corresponding to
given
long name
$n
.
my
$rv
= Net::SSLeay::OBJ_ln2nid(
$s
);
=item * OBJ_nid2sn
Returns short name
for
given
NID
$n
.
my
$rv
= Net::SSLeay::OBJ_nid2sn(
$n
);
Example:
print
Net::SSLeay::OBJ_nid2sn(
&Net::SSLeay::NID_commonName
);
=item * OBJ_sn2nid
Returns NID corresponding to
given
short name
$s
.
my
$rv
= Net::SSLeay::OBJ_sn2nid(
$s
);
Example:
print
"NID_commonName constant="
,
&Net::SSLeay::NID_commonName
;
print
"OBJ_sn2nid('CN')="
, Net::SSLeay::OBJ_sn2nid(
'CN'
);
=item * OBJ_nid2obj
Returns ASN1_OBJECT
for
given
NID
$n
.
my
$rv
= Net::SSLeay::OBJ_nid2obj(
$n
);
=item * OBJ_obj2nid
Returns NID corresponding to
given
ASN1_OBJECT
$o
.
my
$rv
= Net::SSLeay::OBJ_obj2nid(
$o
);
=item * OBJ_txt2obj
Converts the text string s into an ASN1_OBJECT structure. If
$no_name
is 0 then
long names (e.g.
'commonName'
) and short names (e.g.
'CN'
) will be interpreted
as well as numerical forms (e.g.
'2.5.4.3'
). If
$no_name
is 1 only the numerical
form is acceptable.
my
$rv
= Net::SSLeay::OBJ_txt2obj(
$s
,
$no_name
);
=item * OBJ_obj2txt
Converts the ASN1_OBJECT a into a textual representation.
Net::SSLeay::OBJ_obj2txt(
$a
,
$no_name
);
=item * OBJ_txt2nid
Returns NID corresponding to text string
$s
which can be a long name, a short name or the numerical representation of an object.
my
$rv
= Net::SSLeay::OBJ_txt2nid(
$s
);
Example:
my
$nid
= Net::SSLeay::OBJ_txt2nid(
'2.5.4.3'
);
Net::SSLeay::OBJ_nid2sn(
$n
);
=back
=head3 Low level API: ASN1_INTEGER_* related functions
=over
=item * ASN1_INTEGER_new
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Creates a new ASN1_INTEGER structure.
my
$rv
= Net::SSLeay::ASN1_INTEGER_new();
=item * ASN1_INTEGER_free
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Free an allocated ASN1_INTEGER structure.
Net::SSLeay::ASN1_INTEGER_free(
$i
);
=item * ASN1_INTEGER_get
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Returns integer value of
given
ASN1_INTEGER object.
B<BEWARE:> If the value stored in ASN1_INTEGER 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 ASN1_INTEGER
values
consider using L</P_ASN1_INTEGER_get_dec> or L</P_ASN1_INTEGER_get_hex>.
my
$rv
= Net::SSLeay::ASN1_INTEGER_get(
$a
);
=item * ASN1_INTEGER_set
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Sets value of
given
ASN1_INTEGER object to value
$val
B<BEWARE:>
$val
has
max. limit (= max. integer that can be stored in
'long'
type).
For setting large ASN1_INTEGER
values
consider using L</P_ASN1_INTEGER_set_dec> or L</P_ASN1_INTEGER_set_hex>.
my
$rv
= Net::SSLeay::ASN1_INTEGER_set(
$i
,
$val
);
=item * P_ASN1_INTEGER_get_dec
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Returns string
with
decimal representation of integer value of
given
ASN1_INTEGER object.
Net::SSLeay::P_ASN1_INTEGER_get_dec(
$i
);
=item * P_ASN1_INTEGER_get_hex
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Returns string
with
hexadecimal representation of integer value of
given
ASN1_INTEGER object.
Net::SSLeay::P_ASN1_INTEGER_get_hex(
$i
);
=item * P_ASN1_INTEGER_set_dec
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Sets value of
given
ASN1_INTEGER object to value
$val
(decimal string, suitable
for
large integers)
Net::SSLeay::P_ASN1_INTEGER_set_dec(
$i
,
$str
);
=item * P_ASN1_INTEGER_set_hex
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Sets value of
given
ASN1_INTEGER object to value
$val
(hexadecimal string, suitable
for
large integers)
Net::SSLeay::P_ASN1_INTEGER_set_hex(
$i
,
$str
);
=back
=head3 Low level API: ASN1_STRING_* related functions
=over
=item * P_ASN1_STRING_get
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Returns string value of
given
ASN1_STRING object.
Net::SSLeay::P_ASN1_STRING_get(
$s
,
$utf8_decode
);
$string
= Net::SSLeay::P_ASN1_STRING_get(
$s
);
$string
= Net::SSLeay::P_ASN1_STRING_get(
$s
, 0);
=back
=head3 Low level API: ASN1_TIME_* related functions
=over
=item * ASN1_TIME_new
B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and
before
my
$time
= ASN1_TIME_new();
=item * ASN1_TIME_free
B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and
before
ASN1_TIME_free(
$time
);
=item * ASN1_TIME_set
B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and
before
ASN1_TIME_set(
$time
,
$t
);
B<BEWARE:> 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).
If you want to safely set date and
time
after
2038
use
function L</P_ASN1_TIME_set_isotime>.
=item * P_ASN1_TIME_get_isotime
B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and
before
B<NOTE:> Does not exactly correspond to any low level API function
Gives ISO-8601 string representation of ASN1_TIME structure.
my
$datetime_string
= P_ASN1_TIME_get_isotime(
$time
);
The output
format
is compatible
with
module L<DateTime::Format::RFC3339>
=item * P_ASN1_TIME_set_isotime
B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and
before
B<NOTE:> Does not exactly correspond to any low level API function
Sets
time
and date value of ANS1_time structure.
my
$rv
= P_ASN1_TIME_set_isotime(
$time
,
$string
);
The C<
$string
> parameter
has
to be in full form like C<
"2012-03-22T23:55:33"
> or
C<
"2012-03-22T23:55:33Z"
> or C<
"2012-03-22T23:55:33CET"
>. Short forms like
C<
"2012-03-22T23:55"
> or C<
"2012-03-22"
> are not supported.
=item * P_ASN1_TIME_put2string
B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and
before
,
has
bugs
with
OpenSSL 0.9.8i
B<NOTE:> Does not exactly correspond to any low level API function
Gives string representation of ASN1_TIME structure.
my
$str
= P_ASN1_TIME_put2string(
$time
);
=item * P_ASN1_UTCTIME_put2string
B<NOTE:> deprecated function, only
for
backward compatibility, just an alias
for
L</P_ASN1_TIME_put2string>
=back
=head3 Low level API: X509_* related functions
=over
=item * X509_new
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Allocates and initializes a X509 structure.
my
$rv
= Net::SSLeay::X509_new();
=item * X509_free
Frees up the X509 structure.
Net::SSLeay::X509_free(
$a
);
=item * X509_check_host
B<COMPATIBILITY:> 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.
Checks
if
the certificate Subject Alternative Name (SAN) or Subject CommonName
(CN) matches the specified host name.
my
$rv
= Net::SSLeay::X509_check_host(
$cert
,
$name
,
$flags
,
$peername
);
=item * X509_check_email
B<COMPATIBILITY:> not available in Net-SSLeay-1.68 and
before
; requires at least OpenSSL 1.0.2.
Checks
if
the certificate matches the specified email address.
my
$rv
= Net::SSLeay::X509_check_email(
$cert
,
$address
,
$flags
);
=item * X509_check_ip
B<COMPATIBILITY:> not available in Net-SSLeay-1.68 and
before
; requires at least OpenSSL 1.0.2.
Checks
if
the certificate matches the specified IPv4 or IPv6 address.
my
$rv
= Net::SSLeay::X509_check_ip(
$cert
,
$address
,
$flags
);
=item * X509_check_ip_asc
B<COMPATIBILITY:> not available in Net-SSLeay-1.68 and
before
; requires at least OpenSSL 1.0.2.
Checks
if
the certificate matches the specified IPv4 or IPv6 address.
my
$rv
= Net::SSLeay::X509_check_ip_asc(
$cert
,
$address
,
$flags
);
=item * X509_certificate_type
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Returns bitmask
with
type of certificate
$x
.
my
$rv
= Net::SSLeay::X509_certificate_type(
$x
);
=item * X509_digest
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Computes digest/fingerprint of X509
$data
using
$type
hash function.
my
$digest_value
= Net::SSLeay::X509_digest(
$data
,
$type
);
print
unpack
(
'H*'
,
$digest_value
);
=item * X509_issuer_and_serial_hash
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Sort of a checksum of issuer name and serial number of X509 certificate
$x
.
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.
my
$rv
= Net::SSLeay::X509_issuer_and_serial_hash(
$x
);
=item * X509_issuer_name_hash
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Sort of a checksum of issuer name of X509 certificate
$x
.
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.
my
$rv
= Net::SSLeay::X509_issuer_name_hash(
$x
);
=item * X509_subject_name_hash
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Sort of a checksum of subject name of X509 certificate
$x
.
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.
my
$rv
= Net::SSLeay::X509_subject_name_hash(
$x
);
=item * X509_pubkey_digest
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Computes digest/fingerprint of public key from X509 certificate
$data
using
$type
hash function.
my
$digest_value
= Net::SSLeay::X509_pubkey_digest(
$data
,
$type
);
print
unpack
(
'H*'
,
$digest_value
);
=item * X509_set_issuer_name
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Sets issuer of X509 certificate
$x
to
$name
.
my
$rv
= Net::SSLeay::X509_set_issuer_name(
$x
,
$name
);
=item * X509_set_pubkey
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Sets public key of X509 certificate
$x
to
$pkey
.
my
$rv
= Net::SSLeay::X509_set_pubkey(
$x
,
$pkey
);
=item * X509_set_serialNumber
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Sets serial number of X509 certificate
$x
to
$serial
.
my
$rv
= Net::SSLeay::X509_set_serialNumber(
$x
,
$serial
);
$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);
=item * X509_set_subject_name
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Sets subject of X509 certificate
$x
to
$name
.
my
$rv
= Net::SSLeay::X509_set_subject_name(
$x
,
$name
);
=item * X509_set_version
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Set
'version'
value
for
X509 certificate $ to
$version
.
my
$rv
= Net::SSLeay::X509_set_version(
$x
,
$version
);
=item * X509_sign
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Sign X509 certificate
$x
with
private key
$pkey
(using digest algorithm
$md
).
my
$rv
= Net::SSLeay::X509_sign(
$x
,
$pkey
,
$md
);
=item * X509_verify
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Verifies X509 object
$a
using public key
$r
(pubkey of issuing CA).
my
$rv
= Net::SSLeay::X509_verify(
$x
,
$r
);
=item * X509_get_ext_count
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Returns the total number of extensions in X509 object
$x
.
my
$rv
= Net::SSLeay::X509_get_ext_count(
$x
);
=item * X509_get_pubkey
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Returns public key corresponding to
given
X509 object
$x
.
my
$rv
= Net::SSLeay::X509_get_pubkey(
$x
);
B<NOTE:> This method returns only the public key's key bits, without the
algorithm or parameters. Use C<X509_get_X509_PUBKEY()> to
return
the full
public key (SPKI) instead.
=item * X509_get_X509_PUBKEY
B<COMPATIBILITY:> not available in Net-SSLeay-1.72 and
before
Returns the full public key (SPKI) of
given
X509 certificate
$x
.
Net::SSLeay::X509_get_X509_PUBKEY(
$x
);
=item * X509_get_serialNumber
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Returns serial number of X509 certificate
$x
.
my
$rv
= Net::SSLeay::X509_get_serialNumber(
$x
);
See L</P_ASN1_INTEGER_get_dec>, L</P_ASN1_INTEGER_get_hex> or L</ASN1_INTEGER_get> to decode ASN1_INTEGER object.
=item * X509_get0_serialNumber
B<COMPATIBILITY:> available in Net-SSLeay-1.86 onwards
X509_get0_serialNumber() is the same as X509_get_serialNumber() except it accepts a const parameter and returns a const result.
=item * X509_get_version
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Returns
'version'
value of
given
X509 certificate
$x
.
my
$rv
= Net::SSLeay::X509_get_version(
$x
);
=item * X509_get_ext
Returns X509_EXTENSION from
$x509
based on
given
position/
index
.
my
$rv
= Net::SSLeay::X509_get_ext(
$x509
,
$index
);
=item * X509_get_ext_by_NID
Returns X509_EXTENSION from
$x509
based on
given
NID.
my
$rv
= Net::SSLeay::X509_get_ext_by_NID(
$x509
,
$nid
,
$loc
);
=item * X509_get_fingerprint
Returns fingerprint of certificate
$cert
.
B<NOTE:> Does not exactly correspond to any low level API function. The implementation
is based on openssl's C<X509_digest()>.
Net::SSLeay::X509_get_fingerprint(
$x509
,
$type
);
=item * X509_get_issuer_name
Return an X509_NAME object representing the issuer of the certificate
$cert
.
my
$rv
= Net::SSLeay::X509_get_issuer_name(
$cert
);
=item * X509_get0_notAfter, X509_getm_notAfter and X509_get_notAfter
B<COMPATIBILITY:> X509_get0_notAfter and X509_getm_notAfter are not available in Net-SSLeay-1.92 and
before
Return an object giving the
time
after
which the certificate
$cert
is not valid.
my
$rv
= Net::SSLeay::X509_get0_notAfter(
$cert
);
my
$rvm
= Net::SSLeay::X509_getm_notAfter(
$cert
);
To get human readable/printable form the
return
value you can
use
:
my
$time
= Net::SSLeay::X509_get_notAfter(
$cert
);
print
"notAfter="
, Net::SSLeay::P_ASN1_TIME_get_isotime(
$time
),
"\n"
;
B<NOTE:> X509_get_notAfter is an alias and deprecated in OpenSSL 1.1.0 and later
=item * X509_get0_notBefore, X509_getm_notBefore and X509_get_notBefore
B<COMPATIBILITY:> X509_get0_notBefore and X509_getm_notBefore are not available in Net-SSLeay-1.92 and
before
Return an object giving the
time
before
which the certificate
$cert
is not valid
my
$rv
= Net::SSLeay::X509_get0_notBefore(
$cert
);
my
$rvm
= Net::SSLeay::X509_getm_notBefore(
$cert
);
To get human readable/printable form the
return
value you can
use
:
my
$time
= Net::SSLeay::X509_get_notBefore(
$cert
);
print
"notBefore="
, Net::SSLeay::P_ASN1_TIME_get_isotime(
$time
),
"\n"
;
B<NOTE:> X509_get_notBefore is an alias and deprecated in OpenSSL 1.1.0 and later
=item * X509_get_subjectAltNames
B<NOTE:> Does not exactly correspond to any low level API function.
Returns the list of alternative subject names from X509 certificate
$cert
.
my
@rv
= Net::SSLeay::X509_get_subjectAltNames(
$cert
);
Note: type 7 - GEN_IPADD contains the IP address as a packed binary
address. GEN_RID is available in Net-SSLeay-1.90 and later. Maximum
length
for
returned RID string is currently 2500. Invalid and overly
long RID
values
are skipped and not returned. GEN_X400 and
GEN_EDIPARTY are not supported and will not be returned even
when
present in the certificate.
=item * X509_get_subject_name
Returns the subject of the certificate
$cert
.
my
$rv
= Net::SSLeay::X509_get_subject_name(
$cert
);
=item * X509_gmtime_adj
Adjust the ASN1_TIME object to the timestamp (in GMT).
my
$rv
= Net::SSLeay::X509_gmtime_adj(
$s
,
$adj
);
B<BEWARE:> 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 L</P_ASN1_TIME_set_isotime> instead).
=item * X509_load_cert_crl_file
Takes PEM file and loads all X509 certificates and X509 CRLs from that file into X509_LOOKUP structure.
my
$rv
= Net::SSLeay::X509_load_cert_crl_file(
$ctx
,
$file
,
$type
);
=item * X509_load_cert_file
Loads/adds X509 certificate from
$file
to X509_LOOKUP structure
my
$rv
= Net::SSLeay::X509_load_cert_file(
$ctx
,
$file
,
$type
);
=item * X509_load_crl_file
Loads/adds X509 CRL from
$file
to X509_LOOKUP structure
my
$rv
= Net::SSLeay::X509_load_crl_file(
$ctx
,
$file
,
$type
);
=item * X509_policy_level_get0_node
B<COMPATIBILITY:>
no
longer available in LibreSSL 3.8.0 and later
??? (more info needed)
my
$rv
= Net::SSLeay::X509_policy_level_get0_node(
$level
,
$i
);
=item * X509_policy_level_node_count
B<COMPATIBILITY:>
no
longer available in LibreSSL 3.8.0 and later
??? (more info needed)
my
$rv
= Net::SSLeay::X509_policy_level_node_count(
$level
);
=item * X509_policy_node_get0_parent
B<COMPATIBILITY:>
no
longer available in LibreSSL 3.8.0 and later
??? (more info needed)
my
$rv
= Net::SSLeay::X509_policy_node_get0_parent(
$node
);
=item * X509_policy_node_get0_policy
B<COMPATIBILITY:>
no
longer available in LibreSSL 3.8.0 and later
??? (more info needed)
my
$rv
= Net::SSLeay::X509_policy_node_get0_policy(
$node
);
=item * X509_policy_node_get0_qualifiers
B<COMPATIBILITY:>
no
longer available in LibreSSL 3.8.0 and later
??? (more info needed)
my
$rv
= Net::SSLeay::X509_policy_node_get0_qualifiers(
$node
);
=item * X509_policy_tree_free
B<COMPATIBILITY:>
no
longer available in LibreSSL 3.8.0 and later
??? (more info needed)
Net::SSLeay::X509_policy_tree_free(
$tree
);
=item * X509_policy_tree_get0_level
B<COMPATIBILITY:>
no
longer available in LibreSSL 3.8.0 and later
??? (more info needed)
my
$rv
= Net::SSLeay::X509_policy_tree_get0_level(
$tree
,
$i
);
=item * X509_policy_tree_get0_policies
B<COMPATIBILITY:>
no
longer available in LibreSSL 3.8.0 and later
??? (more info needed)
my
$rv
= Net::SSLeay::X509_policy_tree_get0_policies(
$tree
);
=item * X509_policy_tree_get0_user_policies
B<COMPATIBILITY:>
no
longer available in LibreSSL 3.8.0 and later
??? (more info needed)
my
$rv
= Net::SSLeay::X509_policy_tree_get0_user_policies(
$tree
);
=item * X509_policy_tree_level_count
B<COMPATIBILITY:>
no
longer available in LibreSSL 3.8.0 and later
??? (more info needed)
my
$rv
= Net::SSLeay::X509_policy_tree_level_count(
$tree
);
=item * X509_verify_cert_error_string
Returns a human readable error string
for
verification error
$n
.
my
$rv
= Net::SSLeay::X509_verify_cert_error_string(
$n
);
=item * P_X509_add_extensions
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Adds one or more X509 extensions to X509 object
$x
.
my
$rv
= Net::SSLeay::P_X509_add_extensions(
$x
,
$ca_cert
,
$nid
,
$value
);
You can set more extensions at once:
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'
,
);
=item * P_X509_copy_extensions
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Copies X509 extensions from X509_REQ object to X509 object - handy
when
you need to turn X509_REQ into X509 certificate.
Net::SSLeay::P_X509_copy_extensions(
$x509_req
,
$x509
,
$override
);
=item * P_X509_get_crl_distribution_points
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Get the list of CRL distribution points from X509 certificate.
my
@cdp
= Net::SSLeay::P_X509_get_crl_distribution_points(
$x509
);
=item * P_X509_get_ext_key_usage
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Gets the list of extended key usage of
given
X509 certificate
$cert
.
my
@ext_usage
= Net::SSLeay::P_X509_get_ext_key_usage(
$cert
,
$format
);
Examples:
my
@extkeyusage_oid
= Net::SSLeay::P_X509_get_ext_key_usage(
$x509
,0);
my
@extkeyusage_nid
= Net::SSLeay::P_X509_get_ext_key_usage(
$x509
,1);
my
@extkeyusage_sn
= Net::SSLeay::P_X509_get_ext_key_usage(
$x509
,2);
my
@extkeyusage_ln
= Net::SSLeay::P_X509_get_ext_key_usage(
$x509
,3);
=item * P_X509_get_key_usage
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Gets the list of key usage of
given
X509 certificate
$cert
.
my
@keyusage
= Net::SSLeay::P_X509_get_key_usage(
$cert
);
=item * P_X509_get_netscape_cert_type
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Gets the list of Netscape cert types of
given
X509 certificate
$cert
.
Net::SSLeay::P_X509_get_netscape_cert_type(
$cert
);
=item * P_X509_get_pubkey_alg
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Returns ASN1_OBJECT corresponding to X509 certificate public key algorithm.
my
$rv
= Net::SSLeay::P_X509_get_pubkey_alg(
$x
);
To get textual representation
use
:
my
$alg
= Net::SSLeay::OBJ_obj2txt(Net::SSLeay::P_X509_get_pubkey_alg(
$x509
));
=item * P_X509_get_signature_alg
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Returns ASN1_OBJECT corresponding to X509 signature key algorithm.
my
$rv
= Net::SSLeay::P_X509_get_signature_alg(
$x
);
To get textual representation
use
:
my
$alg
= Net::SSLeay::OBJ_obj2txt(Net::SSLeay::P_X509_get_signature_alg(
$x509
));
=item * sk_X509_new_null
Returns a new, empty, STACK_OF(X509) structure.
my
$rv
= Net::SSLeay::sk_X509_new_null();
=item * sk_X509_push
Pushes an X509 structure onto a STACK_OF(X509) structure.
my
$rv
= Net::SSLeay::sk_X509_push(
$sk_x509
,
$x509
);
=item * sk_X509_pop
Pops an single X509 structure from a STACK_OF(X509) structure.
my
$x509
= Net::SSLeay::sk_X509_pop(
$sk_x509
);
=item * sk_X509_shift
Shifts an single X509 structure onto a STACK_OF(X509) structure.
my
$x509
= Net::SSLeay::sk_X509_shift(
$sk_x509
,
$x509
);
=item * sk_X509_unshift
Unshifts an single X509 structure from a STACK_OF(X509) structure.
my
$rv
= Net::SSLeay::sk_X509_unshift(
$sk_x509
);
=item * sk_X509_insert
Inserts a single X509 structure into a STACK_OF(X509) at the specified
index
.
my
$rv
= Net::SSLeay::sk_X509_insert(
$sk_x509
,
$x509
,
$index
);
=item * sk_X509_delete
Delete a single X509 structure from a STACK_OF(X509) at the specified
index
.
my
$x509
= Net::SSLeay::sk_X509_delete(
$sk_x509
,
$index
);
=item * sk_X509_value
Return a single X509 structure from a STACK_OF(X509) at the specified
index
.
my
$x509
= Net::SSLeay::sk_X509_value(
$sk_x509
,
$index
);
=item * sk_X509_num
Return the number of X509 elements in a STACK_OF(X509).
my
$num
= Net::SSLeay::sk_X509_num(
$sk_x509
);
=back
=head3 Low level API: X509_REQ_* related functions
=over
=item * X509_REQ_new
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Creates a new X509_REQ structure.
my
$rv
= Net::SSLeay::X509_REQ_new();
=item * X509_REQ_free
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Free an allocated X509_REQ structure.
Net::SSLeay::X509_REQ_free(
$x
);
=item * X509_REQ_add1_attr_by_NID
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Adds an attribute whose name is
defined
by a NID
$nid
. The field value to be added is in
$bytes
.
my
$rv
= Net::SSLeay::X509_REQ_add1_attr_by_NID(
$req
,
$nid
,
$type
,
$bytes
);
=item * X509_REQ_digest
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Computes digest/fingerprint of X509_REQ
$data
using
$type
hash function.
my
$digest_value
= Net::SSLeay::X509_REQ_digest(
$data
,
$type
);
print
unpack
(
'H*'
,
$digest_value
);
=item * X509_REQ_get_attr_by_NID
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Retrieve the
next
index
matching
$nid
after
$lastpos
(
$lastpos
should initially be set to -1).
my
$rv
= Net::SSLeay::X509_REQ_get_attr_by_NID(
$req
,
$nid
,
$lastpos
=-1);
Note:
use
L </P_X509_REQ_get_attr> to get the actual attribute value - e.g.
my
$index
= Net::SSLeay::X509_REQ_get_attr_by_NID(
$req
,
$nid
);
my
@attr_values
= Net::SSLeay::P_X509_REQ_get_attr(
$req
,
$index
);
=item * X509_REQ_get_attr_by_OBJ
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Retrieve the
next
index
matching
$obj
after
$lastpos
(
$lastpos
should initially be set to -1).
my
$rv
= Net::SSLeay::X509_REQ_get_attr_by_OBJ(
$req
,
$obj
,
$lastpos
=-1);
Note:
use
L </P_X509_REQ_get_attr> to get the actual attribute value - e.g.
my
$index
= Net::SSLeay::X509_REQ_get_attr_by_NID(
$req
,
$nid
);
my
@attr_values
= Net::SSLeay::P_X509_REQ_get_attr(
$req
,
$index
);
=item * X509_REQ_get_attr_count
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Returns the total number of attributes in
$req
.
my
$rv
= Net::SSLeay::X509_REQ_get_attr_count(
$req
);
=item * X509_REQ_get_pubkey
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Returns public key corresponding to
given
X509_REQ object
$x
.
my
$rv
= Net::SSLeay::X509_REQ_get_pubkey(
$x
);
=item * X509_REQ_get_subject_name
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Returns X509_NAME object corresponding to subject name of
given
X509_REQ object
$x
.
my
$rv
= Net::SSLeay::X509_REQ_get_subject_name(
$x
);
=item * X509_REQ_get_version
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Returns
'version'
value
for
given
X509_REQ object
$x
.
my
$rv
= Net::SSLeay::X509_REQ_get_version(
$x
);
=item * X509_REQ_set_pubkey
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Sets public key of
given
X509_REQ object
$x
to
$pkey
.
my
$rv
= Net::SSLeay::X509_REQ_set_pubkey(
$x
,
$pkey
);
=item * X509_REQ_set_subject_name
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Sets subject name of
given
X509_REQ object
$x
to X509_NAME object
$name
.
my
$rv
= Net::SSLeay::X509_REQ_set_subject_name(
$x
,
$name
);
=item * X509_REQ_set_version
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Sets
'version'
of
given
X509_REQ object
$x
to
$version
.
my
$rv
= Net::SSLeay::X509_REQ_set_version(
$x
,
$version
);
=item * X509_REQ_sign
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Sign X509_REQ object
$x
with
private key
$pk
(using digest algorithm
$md
).
my
$rv
= Net::SSLeay::X509_REQ_sign(
$x
,
$pk
,
$md
);
=item * X509_REQ_verify
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Verifies X509_REQ object
$x
using public key
$r
(pubkey of requesting party).
my
$rv
= Net::SSLeay::X509_REQ_verify(
$x
,
$r
);
=item * P_X509_REQ_add_extensions
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Adds one or more X509 extensions to X509_REQ object
$x
.
my
$rv
= Net::SSLeay::P_X509_REQ_add_extensions(
$x
,
$nid
,
$value
);
You can set more extensions at once:
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'
,
);
=item * P_X509_REQ_get_attr
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Returns attribute value
for
X509_REQ's attribute at
index
$n
.
Net::SSLeay::P_X509_REQ_get_attr(
$req
,
$n
);
=back
=head3 Low level API: X509_CRL_* related functions
=over
=item * X509_CRL_new
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Creates a new X509_CRL structure.
my
$rv
= Net::SSLeay::X509_CRL_new();
=item * X509_CRL_free
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Free an allocated X509_CRL structure.
Net::SSLeay::X509_CRL_free(
$x
);
=item * X509_CRL_digest
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Computes digest/fingerprint of X509_CRL
$data
using
$type
hash function.
my
$digest_value
= Net::SSLeay::X509_CRL_digest(
$data
,
$type
);
Example:
my
$x509_crl
;
my
$md
= Net::SSLeay::EVP_get_digestbyname(
"sha1"
);
my
$digest_value
= Net::SSLeay::X509_CRL_digest(
$x509_crl
,
$md
);
print
"digest="
,
unpack
(
'H*'
,
$digest_value
),
"\n"
;
=item * X509_CRL_get_ext
B<COMPATIBILITY:> not available in Net-SSLeay-1.54 and
before
Returns X509_EXTENSION from
$x509
based on
given
position/
index
.
my
$rv
= Net::SSLeay::X509_CRL_get_ext(
$x509
,
$index
);
=item * X509_CRL_get_ext_by_NID
B<COMPATIBILITY:> not available in Net-SSLeay-1.54 and
before
Returns X509_EXTENSION from
$x509
based on
given
NID.
my
$rv
= Net::SSLeay::X509_CRL_get_ext_by_NID(
$x509
,
$nid
,
$loc
);
=item * X509_CRL_get_ext_count
B<COMPATIBILITY:> not available in Net-SSLeay-1.54 and
before
Returns the total number of extensions in X509_CRL object
$x
.
my
$rv
= Net::SSLeay::X509_CRL_get_ext_count(
$x
);
=item * X509_CRL_get_issuer
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Returns X509_NAME object corresponding to the issuer of X509_CRL
$x
.
my
$rv
= Net::SSLeay::X509_CRL_get_issuer(
$x
);
See other C<X509_NAME_*> functions to get more info from X509_NAME structure.
=item * X509_CRL_get0_lastUpdate and X509_CRL_get_lastUpdate
B<COMPATIBILITY:> X509_CRL_get0_lastUpdate not available in Net-SSLeay-1.92 and
before
, X509_CRL_get_lastUpdate not available in Net-SSLeay-1.45 and
before
Returns
'lastUpdate'
date-
time
value of X509_CRL object
$x
.
my
$rv
= Net::SSLeay::X509_CRL_get0_lastUpdate(
$x
);
B<NOTE:> X509_CRL_get_lastUpdate is an alias and deprecated in OpenSSL 1.1.0 and later
=item * X509_CRL_get0_nextUpdate and X509_CRL_get_nextUpdate
B<COMPATIBILITY:> X509_CRL_get0_nextUpdate not available in Net-SSLeay-1.92 and
before
, X509_CRL_get_nextUpdate not available in Net-SSLeay-1.45 and
before
Returns
'nextUpdate'
date-
time
value of X509_CRL object
$x
.
my
$rv
= Net::SSLeay::X509_CRL_get0_nextUpdate(
$x
);
B<NOTE:> X509_CRL_get_nextUpdate is an alias and deprecated in OpenSSL 1.1.0 and later
=item * X509_CRL_get_version
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Returns
'version'
value of
given
X509_CRL structure
$x
.
my
$rv
= Net::SSLeay::X509_CRL_get_version(
$x
);
=item * X509_CRL_set_issuer_name
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Sets the issuer of X509_CRL object
$x
to X509_NAME object
$name
.
my
$rv
= Net::SSLeay::X509_CRL_set_issuer_name(
$x
,
$name
);
=item * X509_CRL_set1_lastUpdate and X509_CRL_set_lastUpdate
B<COMPATIBILITY:> X509_CRL_set1_lastUpdate not available in Net-SSLeay-1.92 and
before
, X509_CRL_set_lastUpdate not available in Net-SSLeay-1.45 and
before
Sets
'lastUpdate'
value of X509_CRL object
$x
to
$tm
.
my
$rv
= Net::SSLeay::X509_CRL_set1_lastUpdate(
$x
,
$tm
);
B<NOTE:> X509_CRL_set_lastUpdate is an alias and deprecated in OpenSSL 1.1.0 and later
=item * X509_CRL_set1_nextUpdate and X509_CRL_set_nextUpdate
B<COMPATIBILITY:> X509_CRL_set1_nextUpdate not available in Net-SSLeay-1.92 and
before
, X509_CRL_set_nextUpdate not available in Net-SSLeay-1.45 and
before
Sets
'nextUpdate'
value of X509_CRL object
$x
to
$tm
.
my
$rv
= Net::SSLeay::X509_CRL_set1_nextUpdate(
$x
,
$tm
);
B<NOTE:> X509_CRL_set_nextUpdate is an alias and deprecated in OpenSSL 1.1.0 and later
=item * X509_CRL_set_version
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Sets
'version'
value of
given
X509_CRL structure
$x
to
$version
.
my
$rv
= Net::SSLeay::X509_CRL_set_version(
$x
,
$version
);
Note that
if
you want to
use
any X509_CRL extension you need to set
"version 2 CRL"
- C<Net::SSLeay::X509_CRL_set_version(
$x
, 1)>.
=item * X509_CRL_sign
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Sign X509_CRL object
$x
with
private key
$pkey
(using digest algorithm
$md
).
my
$rv
= Net::SSLeay::X509_CRL_sign(
$x
,
$pkey
,
$md
);
=item * X509_CRL_sort
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Sorts the data of X509_CRL object so it will be written in serial number order.
my
$rv
= Net::SSLeay::X509_CRL_sort(
$x
);
=item * X509_CRL_verify
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Verifies X509_CRL object
$a
using public key
$r
(pubkey of issuing CA).
my
$rv
= Net::SSLeay::X509_CRL_verify(
$a
,
$r
);
=item * P_X509_CRL_add_revoked_serial_hex
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Adds
given
serial number
$serial_hex
to X509_CRL object
$crl
.
Net::SSLeay::P_X509_CRL_add_revoked_serial_hex(
$crl
,
$serial_hex
,
$rev_time
,
$reason_code
,
$comp_time
);
=item * P_X509_CRL_get_serial
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Returns serial number of X509_CRL object.
my
$rv
= Net::SSLeay::P_X509_CRL_get_serial(
$crl
);
=item * P_X509_CRL_set_serial
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Sets serial number of X509_CRL object to
$crl_number
.
my
$rv
= Net::SSLeay::P_X509_CRL_set_serial(
$crl
,
$crl_number
);
=item * P_X509_CRL_add_extensions
B<COMPATIBILITY:> not available in Net-SSLeay-1.88 and
before
Adds one or more X509 extensions to X509 CRL object
$x
.
my
$rv
= Net::SSLeay::P_X509_CRL_add_extensions(
$x
,
$ca_cert
,
$nid
,
$value
);
For more details see L</P_X509_add_extensions>.
=back
=head3 Low level API: X509_EXTENSION_* related functions
=over
=item * X509_EXTENSION_get_critical
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Returns
'critical'
flag of
given
X509_EXTENSION object
$ex
.
my
$rv
= Net::SSLeay::X509_EXTENSION_get_critical(
$ex
);
=item * X509_EXTENSION_get_data
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Returns value (raw data) of X509_EXTENSION object
$ne
.
my
$rv
= Net::SSLeay::X509_EXTENSION_get_data(
$ne
);
Note: you can
use
L </P_ASN1_STRING_get> to convert ASN1_OCTET_STRING into perl
scalar
variable.
=item * X509_EXTENSION_get_object
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Returns OID (ASN1_OBJECT) of X509_EXTENSION object
$ne
.
my
$rv
= Net::SSLeay::X509_EXTENSION_get_object(
$ex
);
=item * X509V3_EXT_print
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Returns string representation of
given
X509_EXTENSION object
$ext
.
Net::SSLeay::X509V3_EXT_print(
$ext
,
$flags
,
$utf8_decode
);
=item * X509V3_EXT_d2i
Parses an extension and returns its internal structure.
my
$rv
= Net::SSLeay::X509V3_EXT_d2i(
$ext
);
=back
=head3 Low level API: X509_NAME_* related functions
=over
=item * X509_NAME_ENTRY_get_data
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Retrieves the field value of
$ne
in and ASN1_STRING structure.
my
$rv
= Net::SSLeay::X509_NAME_ENTRY_get_data(
$ne
);
=item * X509_NAME_ENTRY_get_object
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Retrieves the field name of
$ne
in and ASN1_OBJECT structure.
my
$rv
= Net::SSLeay::X509_NAME_ENTRY_get_object(
$ne
);
=item * X509_NAME_new
B<COMPATIBILITY:> not available in Net-SSLeay-1.55 and
before
Creates a new X509_NAME structure.
Adds a field whose name is
defined
by a string
$field
. The field value to be added is in
$bytes
.
my
$rv
= Net::SSLeay::X509_NAME_new();
=item * X509_NAME_hash
B<COMPATIBILITY:> not available in Net-SSLeay-1.55 and
before
Sort of a checksum of issuer name
$name
.
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.
my
$rv
= Net::SSLeay::X509_NAME_hash(
$name
);
=item * X509_NAME_add_entry_by_txt
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Adds a field whose name is
defined
by a string
$field
. The field value to be added is in
$bytes
.
my
$rv
= Net::SSLeay::X509_NAME_add_entry_by_txt(
$name
,
$field
,
$type
,
$bytes
,
$len
,
$loc
,
$set
);
Unicode note:
when
passing non-ascii (unicode) string in
$bytes
do
not forget to set C<
$flags
=
&Net::SSLeay::MBSTRING_UTF8
> and encode the perl
$string
via C<
$bytes
= encode(
'utf-8'
,
$string
)>.
=item * X509_NAME_add_entry_by_NID
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Adds a field whose name is
defined
by a NID
$nid
. The field value to be added is in
$bytes
.
my
$rv
= Net::SSLeay::X509_NAME_add_entry_by_NID(
$name
,
$nid
,
$type
,
$bytes
,
$len
,
$loc
,
$set
);
=item * X509_NAME_add_entry_by_OBJ
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Adds a field whose name is
defined
by a object (OID)
$obj
. The field value to be added is in
$bytes
.
my
$rv
= Net::SSLeay::X509_NAME_add_entry_by_OBJ(
$name
,
$obj
,
$type
,
$bytes
,
$len
,
$loc
,
$set
);
=item * X509_NAME_cmp
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Compares two X509_NAME objects.
my
$rv
= Net::SSLeay::X509_NAME_cmp(
$a
,
$b
);
=item * X509_NAME_digest
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Computes digest/fingerprint of X509_NAME
$data
using
$type
hash function.
my
$digest_value
= Net::SSLeay::X509_NAME_digest(
$data
,
$type
);
print
unpack
(
'H*'
,
$digest_value
);
=item * X509_NAME_entry_count
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Returns the total number of entries in
$name
.
my
$rv
= Net::SSLeay::X509_NAME_entry_count(
$name
);
=item * X509_NAME_get_entry
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Retrieves the X509_NAME_ENTRY from
$name
corresponding to
index
$loc
. Acceptable
values
for
$loc
run
from 0 to C<Net::SSLeay::X509_NAME_entry_count(
$name
) - 1>. The value returned is an internal pointer which must not be freed.
my
$rv
= Net::SSLeay::X509_NAME_get_entry(
$name
,
$loc
);
=item * X509_NAME_print_ex
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Returns a string
with
human readable version of
$name
.
Net::SSLeay::X509_NAME_print_ex(
$name
,
$flags
,
$utf8_decode
);
Most likely you will be fine
with
default
:
Net::SSLeay::X509_NAME_print_ex(
$name
,
&Net::SSLeay::XN_FLAG_RFC2253
);
Or you might want RFC2253-like output without utf8 chars escaping:
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);
=item * X509_NAME_get_text_by_NID
Retrieves the text from the first entry in name which matches
$nid
,
if
no
such entry
exists
-1 is returned.
B<openssl note:> 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.
Net::SSLeay::X509_NAME_get_text_by_NID(
$name
,
$nid
);
=item * X509_NAME_oneline
Return an ASCII version of
$name
.
Net::SSLeay::X509_NAME_oneline(
$name
);
=item * sk_X509_NAME_free
Free an allocated STACK_OF(X509_NAME) structure.
Net::SSLeay::sk_X509_NAME_free(
$sk
);
=item * sk_X509_NAME_num
Return number of items in STACK_OF(X509_NAME)
my
$rv
= Net::SSLeay::sk_X509_NAME_num(
$sk
);
=item * sk_X509_NAME_value
Returns X509_NAME from position
$index
in STACK_OF(X509_NAME)
my
$rv
= Net::SSLeay::sk_X509_NAME_value(
$sk
,
$i
);
=item * add_file_cert_subjects_to_stack
Add a file of certs to a stack. All certs in
$file
that are not already in the
$stackCAs
will be added.
my
$rv
= Net::SSLeay::add_file_cert_subjects_to_stack(
$stackCAs
,
$file
);
=item * add_dir_cert_subjects_to_stack
Add a directory of certs to a stack. All certs in
$dir
that are not already in the
$stackCAs
will be added.
my
$rv
= Net::SSLeay::add_dir_cert_subjects_to_stack(
$stackCAs
,
$dir
);
=back
=head3 Low level API: X509_STORE_* related functions
=over
=item * X509_STORE_CTX_new
returns a newly initialised X509_STORE_CTX structure.
=item * X509_STORE_CTX_init
X509_STORE_CTX_init() sets up an X509_STORE_CTX
for
a subsequent verification operation.
It must be called
before
each
call to X509_verify_cert().
my
$rv
= Net::SSLeay::X509_STORE_CTX_init(
$x509_store_ctx
,
$x509_store
,
$x509
,
$chain
);
=item * X509_STORE_CTX_free
Frees an X509_STORE_CTX structure.
Net::SSLeay::X509_STORE_CTX_free(
$x509_store_ctx
);
=item * X509_verify_cert
The X509_verify_cert() function attempts to discover and validate a
certificate chain based on parameters in ctx. A complete description
of the process is contained in the verify(1) manual page.
information.
my
$rv
= Net::SSLeay::X509_verify_cert(
$x509_store_ctx
);
=item * X509_STORE_CTX_get_current_cert
Returns the certificate in ctx which caused the error or 0
if
no
certificate is relevant.
my
$rv
= Net::SSLeay::X509_STORE_CTX_get_current_cert(
$x509_store_ctx
);
=item * X509_STORE_CTX_get0_cert
B<COMPATIBILITY>: not available in Net-SSLeay-1.88 and
before
; requires at least OpenSSL 1.1.0pre6 or LibreSSL 2.7.0
Returns an internal pointer to the certificate being verified by the ctx.
my
$x509
= Net::SSLeay::X509_STORE_CTX_get0_cert(
$x509_store_ctx
);
=item * X509_STORE_CTX_get1_chain
Returns a returns a complete validate chain
if
a previous call to X509_verify_cert() is successful.
my
$rv
= Net::SSLeay::X509_STORE_CTX_get1_chain(
$x509_store_ctx
);
=item * X509_STORE_CTX_get_error
Returns the error code of
$ctx
.
my
$rv
= Net::SSLeay::X509_STORE_CTX_get_error(
$x509_store_ctx
);
For more info about error code
values
check function L</get_verify_result>.
=item * X509_STORE_CTX_get_error_depth
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.
my
$rv
= Net::SSLeay::X509_STORE_CTX_get_error_depth(
$x509_store_ctx
);
=item * X509_STORE_CTX_get_ex_data
Is used to retrieve the information
for
$idx
from
$x509_store_ctx
.
my
$rv
= Net::SSLeay::X509_STORE_CTX_get_ex_data(
$x509_store_ctx
,
$idx
);
=item * X509_STORE_CTX_set_ex_data
Is used to store application data at arg
for
idx into
$x509_store_ctx
.
my
$rv
= Net::SSLeay::X509_STORE_CTX_set_ex_data(
$x509_store_ctx
,
$idx
,
$data
);
=item * X509_STORE_CTX_set_cert
Sets the certificate to be verified in
$x509_store_ctx
to
$x
.
Net::SSLeay::X509_STORE_CTX_set_cert(
$x509_store_ctx
,
$x
);
=item * X509_STORE_new
Returns a newly initialized X509_STORE structure.
my
$rv
= Net::SSLeay::X509_STORE_new();
=item * X509_STORE_free
Frees an X509_STORE structure
Net::SSLeay::X509_STORE_free(
$x509_store
);
=item * X509_STORE_add_lookup
Adds a lookup to an X509_STORE
for
a
given
lookup method.
my
$method
=
&Net::SSLeay::X509_LOOKUP_hash_dir
;
my
$rv
= Net::SSLeay::X509_STORE_add_lookup(
$x509_store
,
$method
);
=item * X509_STORE_CTX_set_error
Sets the error code of
$ctx
to
$s
. For example it might be used in a verification callback to set an error based on additional checks.
Net::SSLeay::X509_STORE_CTX_set_error(
$x509_store_ctx
,
$s
);
=item * X509_STORE_add_cert
Adds X509 certificate
$x
into the X509_STORE
$store
.
my
$rv
= Net::SSLeay::X509_STORE_add_cert(
$store
,
$x
);
=item * X509_STORE_add_crl
Adds X509 CRL
$x
into the X509_STORE
$store
.
my
$rv
= Net::SSLeay::X509_STORE_add_crl(
$store
,
$x
);
=item * X509_STORE_set1_param
??? (more info needed)
my
$rv
= Net::SSLeay::X509_STORE_set1_param(
$store
,
$pm
);
=item * X509_LOOKUP_hash_dir
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> or crls
with
filenames in the
format
I<hash.>B<r>I<N>
my
$rv
= Net::SSLeay::X509_LOOKUP_hash_dir();
=item * X509_LOOKUP_add_dir
Add a directory to an X509_LOOKUP structure, usually obtained from
X509_STORE_add_lookup.
my
$method
=
&Net::SSLeay::X509_LOOKUP_hash_dir
;
my
$lookup
= Net::SSLeay::X509_STORE_add_lookup(
$x509_store
,
$method
);
my
$type
=
&Net::SSLeay::X509_FILETYPE_PEM
;
Net::SSLeay::X509_LOOKUP_add_dir(
$lookup
,
$dir
,
$type
);
=item * X509_STORE_set_flags
Net::SSLeay::X509_STORE_set_flags(
$ctx
,
$flags
);
$flags
= Net::SSLeay::X509_V_FLAG_CRL_CHECK();
For more details about
$flags
bitmask see L</X509_VERIFY_PARAM_set_flags>.
=item * X509_STORE_set_purpose
Net::SSLeay::X509_STORE_set_purpose(
$ctx
,
$purpose
);
For more details about
$purpose
identifier check L</CTX_set_purpose>.
=item * X509_STORE_set_trust
Net::SSLeay::X509_STORE_set_trust(
$ctx
,
$trust
);
For more details about
$trust
identifier check L</CTX_set_trust>.
=back
=head3 Low Level API: X509_INFO related functions
=over
=item * sk_X509_INFO_num
Returns the number of
values
in a STACK_OF(X509_INFO) structure.
my
$rv
= Net::SSLeay::sk_X509_INFO_num(
$sk_x509_info
);
=item * sk_X509_INFO_value
Returns the value of a STACK_OF(X509_INFO) structure at a
given
index
.
my
$rv
= Net::SSLeay::sk_X509_INFO_value(
$sk_x509_info
,
$index
);
=item * P_X509_INFO_get_x509
Returns the X509 structure stored in an X509_INFO structure.
my
$rv
= Net::SSLeay::P_X509_INFO_get_x509(
$x509_info
);
=back
=head3 Low level API: X509_VERIFY_PARAM_* related functions
=over
=item * X509_VERIFY_PARAM_add0_policy
Enables policy checking (it is disabled by
default
) and adds
$policy
to the acceptable policy set.
my
$rv
= Net::SSLeay::X509_VERIFY_PARAM_add0_policy(
$param
,
$policy
);
=item * X509_VERIFY_PARAM_add0_table
??? (more info needed)
my
$rv
= Net::SSLeay::X509_VERIFY_PARAM_add0_table(
$param
);
=item * X509_VERIFY_PARAM_add1_host
B<COMPATIBILITY:> not available in Net-SSLeay-1.82 and
before
; requires at least OpenSSL 1.0.2-beta2 or LibreSSL 2.7.0
Adds an additional reference identifier that can match the peer's certificate.
my
$rv
= Net::SSLeay::X509_VERIFY_PARAM_add1_host(
$param
,
$name
);
See also OpenSSL docs, L</X509_VERIFY_PARAM_set1_host> and
L</X509_VERIFY_PARAM_set_hostflags>
for
more information, including
wildcard matching.
=item * X509_VERIFY_PARAM_clear_flags
Clears the flags
$flags
in param.
my
$rv
= Net::SSLeay::X509_VERIFY_PARAM_clear_flags(
$param
,
$flags
);
For more details about
$flags
bitmask see L</X509_VERIFY_PARAM_set_flags>.
=item * X509_VERIFY_PARAM_free
Frees up the X509_VERIFY_PARAM structure.
Net::SSLeay::X509_VERIFY_PARAM_free(
$param
);
=item * X509_VERIFY_PARAM_get0_peername
B<COMPATIBILITY:> not available in Net-SSLeay-1.82 and
before
; requires at least OpenSSL 1.0.2-beta2 or LibreSSL 2.7.0
Returns the DNS hostname or subject CommonName from the peer certificate that matched one of the reference identifiers.
my
$rv
= Net::SSLeay::X509_VERIFY_PARAM_get0_peername(
$param
);
=item * X509_VERIFY_PARAM_get_depth
Returns the current verification depth.
my
$rv
= Net::SSLeay::X509_VERIFY_PARAM_get_depth(
$param
);
=item * X509_VERIFY_PARAM_get_flags
Returns the current verification flags.
my
$rv
= Net::SSLeay::X509_VERIFY_PARAM_get_flags(
$param
);
For more details about returned flags bitmask see L</X509_VERIFY_PARAM_set_flags>.
=item * X509_VERIFY_PARAM_set_flags
my
$rv
= Net::SSLeay::X509_VERIFY_PARAM_set_flags(
$param
,
$flags
);
$flags
= Net::SSLeay::X509_V_FLAG_CRL_CHECK();
For more details about
$flags
bitmask, see the OpenSSL docs below.
=item * X509_VERIFY_PARAM_inherit
??? (more info needed)
my
$rv
= Net::SSLeay::X509_VERIFY_PARAM_inherit(
$to
,
$from
);
=item * X509_VERIFY_PARAM_lookup
Finds X509_VERIFY_PARAM by name.
my
$rv
= Net::SSLeay::X509_VERIFY_PARAM_lookup(
$name
);
=item * X509_VERIFY_PARAM_new
Creates a new X509_VERIFY_PARAM structure.
my
$rv
= Net::SSLeay::X509_VERIFY_PARAM_new();
=item * X509_VERIFY_PARAM_set1
Sets the name of X509_VERIFY_PARAM structure
$to
to the same value
as the name of X509_VERIFY_PARAM structure
$from
.
my
$rv
= Net::SSLeay::X509_VERIFY_PARAM_set1(
$to
,
$from
);
=item * X509_VERIFY_PARAM_set1_email
B<COMPATIBILITY:> not available in Net-SSLeay-1.82 and
before
; requires at least OpenSSL 1.0.2-beta1 or LibreSSL 2.7.0
Sets the expected RFC822 email address to email.
my
$rv
= Net::SSLeay::X509_VERIFY_PARAM_set1_email(
$param
,
$email
);
=item * X509_VERIFY_PARAM_set1_host
B<COMPATIBILITY:> not available in Net-SSLeay-1.82 and
before
; requires at least OpenSSL 1.0.2-beta1 or LibreSSL 2.7.0
Sets the expected DNS hostname to name clearing any previously specified host name or names.
my
$rv
= Net::SSLeay::X509_VERIFY_PARAM_set1_host(
$param
,
$name
);
See also OpenSSL docs, L</X509_VERIFY_PARAM_add1_host> and
L</X509_VERIFY_PARAM_set_hostflags>
for
more information, including
wildcard matching.
=item * X509_VERIFY_PARAM_set1_ip
B<COMPATIBILITY:> not available in Net-SSLeay-1.82 and
before
; requires at least OpenSSL 1.0.2-beta1 or LibreSSL 2.7.0
Sets the expected IP address to ip.
my
$rv
= Net::SSLeay::X509_VERIFY_PARAM_set1_ip(
$param
,
$ip
);
=item * X509_VERIFY_PARAM_set1_ip_asc
B<COMPATIBILITY:> not available in Net-SSLeay-1.82 and
before
; requires at least OpenSSL 1.0.2-beta1 or LibreSSL 2.7.0
Sets the expected IP address to ipasc.
my
$rv
= Net::SSLeay::X509_VERIFY_PARAM_set1_asc(
$param
,
$ipasc
);
=item * X509_VERIFY_PARAM_set1_name
Sets the name of X509_VERIFY_PARAM structure
$param
to
$name
.
my
$rv
= Net::SSLeay::X509_VERIFY_PARAM_set1_name(
$param
,
$name
);
=item * X509_VERIFY_PARAM_set1_policies
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.
my
$rv
= Net::SSLeay::X509_VERIFY_PARAM_set1_policies(
$param
,
$policies
);
=item * X509_VERIFY_PARAM_set_depth
Sets the maximum verification depth to depth. That is the maximum number of untrusted CA certificates that can appear in a chain.
Net::SSLeay::X509_VERIFY_PARAM_set_depth(
$param
,
$depth
);
=item * X509_VERIFY_PARAM_set_hostflags
B<COMPATIBILITY:> not available in Net-SSLeay-1.82 and
before
; requires at least OpenSSL 1.0.2-beta2 or LibreSSL 2.7.0
Net::SSLeay::X509_VERIFY_PARAM_set_hostflags(
$param
,
$flags
);
See also OpenSSL docs, L</X509_VERIFY_PARAM_add1_host> and L</X509_VERIFY_PARAM_set1_host>
for
more information.
The flags
for
controlling wildcard checks and other features are
defined
in OpenSSL docs.
=item * X509_VERIFY_PARAM_set_purpose
Sets the verification purpose in
$param
to
$purpose
. This determines the acceptable purpose
of the certificate chain,
for
example SSL client or SSL server.
my
$rv
= Net::SSLeay::X509_VERIFY_PARAM_set_purpose(
$param
,
$purpose
);
For more details about
$purpose
identifier check L</CTX_set_purpose>.
=item * X509_VERIFY_PARAM_set_time
Sets the verification
time
in
$param
to
$t
. Normally the current
time
is used.
Net::SSLeay::X509_VERIFY_PARAM_set_time(
$param
,
$t
);
=item * X509_VERIFY_PARAM_set_trust
Sets the trust setting in
$param
to
$trust
.
my
$rv
= Net::SSLeay::X509_VERIFY_PARAM_set_trust(
$param
,
$trust
);
For more details about
$trust
identifier check L</CTX_set_trust>.
=item * X509_VERIFY_PARAM_table_cleanup
??? (more info needed)
Net::SSLeay::X509_VERIFY_PARAM_table_cleanup();
=back
=head3 Low level API: Cipher (EVP_CIPHER_*) related functions
=over
=item * EVP_get_cipherbyname
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
Returns an EVP_CIPHER structure
when
passed a cipher name.
my
$rv
= Net::SSLeay::EVP_get_cipherbyname(
$name
);
=back
=head3 Low level API: Digest (EVP_MD_*) related functions
=over
=item * OpenSSL_add_all_digests
B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and
before
Net::SSLeay::OpenSSL_add_all_digests();
=item * P_EVP_MD_list_all
B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and
before
; requires at least OpenSSL 1.0.0
B<NOTE:> Does not exactly correspond to any low level API function
my
$rv
= Net::SSLeay::P_EVP_MD_list_all();
The returned digest names correspond to
values
expected by L</EVP_get_digestbyname>.
Note that some of the digests are available by
default
and some only
after
calling L</OpenSSL_add_all_digests>.
=item * EVP_get_digestbyname
B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and
before
my
$rv
= Net::SSLeay::EVP_get_digestbyname(
$name
);
Or better check the supported digests by calling L</P_EVP_MD_list_all>.
=item * EVP_MD_type
B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and
before
my
$rv
= Net::SSLeay::EVP_MD_type(
$md
);
C<EVP_MD_type> is a non-deprecated alias macro of C<EVP_MD_get_type> since OpenSSL 3.0.0.
=item * EVP_MD_size
B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and
before
my
$rv
= Net::SSLeay::EVP_MD_size(
$md
);
=item * EVP_MD_get0_description
B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and
before
; requires at least OpenSSL 3.0.0-beta1, not in LibreSSL
Return description of a message digest.
my
$rv
= Net::SSLeay::EVP_MD_get0_description(
$md
);
=item * EVP_MD_get0_name
B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and
before
; requires at least OpenSSL 3.0.0-beta1, not in LibreSSL
Return one name of a message digest.
my
$rv
= Net::SSLeay::EVP_MD_get0_description(
$md
);
=item * EVP_MD_get_type
B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and
before
; requires at least OpenSSL 3.0.0-beta1, not in LibreSSL
Return NID value of a message digest.
my
$rv
= Net::SSLeay::EVP_MD_get_type(
$md
);
=item * EVP_MD_CTX_md
B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and
before
Net::SSLeay::EVP_MD_CTX_md(
$ctx
);
=item * EVP_MD_CTX_create
B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and
before
Allocates, initializes and returns a digest context.
my
$rv
= Net::SSLeay::EVP_MD_CTX_create();
The complete idea behind EVP_MD_CTX looks like this example:
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"
;
=item * EVP_DigestInit_ex
B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and
before
Sets up digest context
$ctx
to
use
a digest
$type
from ENGINE
$impl
,
$ctx
must be
initialized
before
calling this function, type will typically be supplied by a function
such as L</EVP_get_digestbyname>. If
$impl
is 0 then the
default
implementation of digest
$type
is used.
my
$rv
= Net::SSLeay::EVP_DigestInit_ex(
$ctx
,
$type
,
$impl
);
=item * EVP_DigestInit
B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and
before
Behaves in the same way as L</EVP_DigestInit_ex> except the passed context
$ctx
does not have
to be initialized, and it always uses the
default
digest implementation.
my
$rv
= Net::SSLeay::EVP_DigestInit(
$ctx
,
$type
);
=item * EVP_MD_CTX_destroy
B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and
before
Cleans up digest context
$ctx
and frees up the space allocated to it, it should be
called only on a context created using L</EVP_MD_CTX_create>.
Net::SSLeay::EVP_MD_CTX_destroy(
$ctx
);
=item * EVP_DigestUpdate
B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and
before
my
$rv
= Net::SSLeay::EVP_DigestUpdate(
$ctx
,
$data
);
=item * EVP_DigestFinal_ex
B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and
before
Retrieves the digest value from
$ctx
. After calling L</EVP_DigestFinal_ex>
no
additional calls to L</EVP_DigestUpdate> can be made, but
L</EVP_DigestInit_ex> can be called to initialize a new digest operation.
my
$digest_value
= Net::SSLeay::EVP_DigestFinal_ex(
$ctx
);
print
unpack
(
'H*'
,
$digest_value
);
=item * EVP_DigestFinal
B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and
before
Similar to L</EVP_DigestFinal_ex> except the digest context ctx is automatically cleaned up.
my
$rv
= Net::SSLeay::EVP_DigestFinal(
$ctx
);
print
unpack
(
'H*'
,
$digest_value
);
=item * MD2
B<COMPATIBILITY:> not supported by
default
in OpenSSL 1.0.0
Computes MD2 from
given
$data
(all data needs to be loaded into memory)
my
$digest
= Net::SSLeay::MD2(
$data
);
print
"digest(hexadecimal)="
,
unpack
(
'H*'
,
$digest
);
=item * MD4
Computes MD4 from
given
$data
(all data needs to be loaded into memory)
my
$digest
= Net::SSLeay::MD4(
$data
);
print
"digest(hexadecimal)="
,
unpack
(
'H*'
,
$digest
);
=item * MD5
Computes MD5 from
given
$data
(all data needs to be loaded into memory)
my
$digest
= Net::SSLeay::MD5(
$data
);
print
"digest(hexadecimal)="
,
unpack
(
'H*'
,
$digest
);
=item * RIPEMD160
Computes RIPEMD160 from
given
$data
(all data needs to be loaded into memory)
my
$digest
= Net::SSLeay::RIPEMD160(
$data
);
print
"digest(hexadecimal)="
,
unpack
(
'H*'
,
$digest
);
=item * SHA1
B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and
before
Computes SHA1 from
given
$data
(all data needs to be loaded into memory)
my
$digest
= Net::SSLeay::SHA1(
$data
);
print
"digest(hexadecimal)="
,
unpack
(
'H*'
,
$digest
);
=item * SHA256
B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and
before
; requires at least OpenSSL 0.9.8
Computes SHA256 from
given
$data
(all data needs to be loaded into memory)
my
$digest
= Net::SSLeay::SHA256(
$data
);
print
"digest(hexadecimal)="
,
unpack
(
'H*'
,
$digest
);
=item * SHA512
B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and
before
; requires at least OpenSSL 0.9.8
Computes SHA512 from
given
$data
(all data needs to be loaded into memory)
my
$digest
= Net::SSLeay::SHA512(
$data
);
print
"digest(hexadecimal)="
,
unpack
(
'H*'
,
$digest
);
=item * EVP_Digest
B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and
before
Computes
"any"
digest from
given
$data
(all data needs to be loaded into memory)
my
$md
= Net::SSLeay::EVP_get_digestbyname(
"sha1"
);
my
$digest
= Net::SSLeay::EVP_Digest(
$data
,
$md
);
print
"digest(hexadecimal)="
,
unpack
(
'H*'
,
$digest
);
=item * EVP_sha1
B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and
before
my
$md
= Net::SSLeay::EVP_sha1();
=item * EVP_sha256
B<COMPATIBILITY:> requires at least OpenSSL 0.9.8
my
$md
= Net::SSLeay::EVP_sha256();
=item * EVP_sha512
B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and
before
; requires at least OpenSSL 0.9.8
my
$md
= Net::SSLeay::EVP_sha512();
=item * EVP_add_digest
my
$rv
= Net::SSLeay::EVP_add_digest(
$digest
);
=back
=head3 Low level API: CIPHER_* related functions
=over
=item * CIPHER_get_name
B<COMPATIBILITY:> not available in Net-SSLeay-1.42 and
before
Returns name of the cipher used.
my
$rv
= Net::SSLeay::CIPHER_get_name(
$cipher
);
Example:
my
$ssl_cipher
= Net::SSLeay::get_current_cipher(
$ssl
);
my
$cipher_name
= Net::SSLeay::CIPHER_get_name(
$ssl_cipher
);
=item * CIPHER_description
B<COMPATIBILITY:> doesn't work correctly in Net-SSLeay-1.88 and
before
Returns a textual description of the cipher used.
my
$rv
= Net::SSLeay::CIPHER_description(
$cipher
);
=item * CIPHER_get_bits
B<COMPATIBILITY:>
$alg_bits
doesn't work correctly in Net-SSLeay-1.88 and
before
Returns the number of secret bits used
for
cipher.
my
$rv
= Net::SSLeay::CIPHER_get_bits(
$cipher
,
$alg_bits
);
Example:
my
$alg_bits
;
my
$bits
= Net::SSLeay::CIPHER_get_bits(
$cipher
,
$alg_bits
);
print
"bits: $bits, alg_bits: $alg_bits\n"
;
=item * CIPHER_get_version
B<COMPATIBILITY:> not available in Net-SSLeay-1.88 and
before
Returns version of SSL/TLS protocol that first
defined
the cipher
my
$rv
= Net::SSLeay::CIPHER_get_version(
$cipher
);
=item * CIPHER_get_handshake_digest
B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and
before
; requires at least OpenSSL 1.1.1-pre1, not in LibreSSL
Returns version of SSL/TLS protocol that first
defined
the cipher
my
$rv
= Net::SSLeay::CIPHER_get_handshake_digest(
$cipher
);
=item * CIPHER_find
B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and
before
; requires at least OpenSSL 1.0.2 or LibreSSL 3.4.0
Returns a SSL_CIPHER structure from the current SSL using a two octet cipher ID.
my
$cipher
= Net::SSLeay::CIPHER_find(
$ssl
,
$id
);
Example that prints
'OpenSSL name is: TLS_AES_128_GCM_SHA256'
with
TLSv1.3
when
the ciphersuite is enabled:
my
$id
=
pack
(
'n'
, 0x1301);
my
$cipher
= Net::SSLeay::CIPHER_find(
$ssl
,
$id
);
printf
(
"OpenSSL name is: "
. Net::SSLeay::CIPHER_get_name(
$cipher
));
=back
=head3 Low level API: BN_* related functions
=over
=item * BN_dup
Creates and returns a new BIGNUM from an existing BIGNUM.
my
$bn
= Net::SSLeay::BN_dup(
$from
);
=item * BN_clear
Clears BIGNUM data
when
it is
no
longer needed.
Net::SSLeay::BN_clear(
$bn
);
=item * BN_clear_free
Clears and frees a previously allocated BIGNUM.
Net::SSLeay::BN_clear_free(
$bn
);
=item * BN_free
Frees previously a allocated BIGNUM.
Net::SSLeay::BN_free(
$bn
);
=back
=head3 Low level API: RSA_* related functions
=over
=item * RSA_generate_key
Generates a key pair and returns it in a newly allocated RSA structure.
The pseudo-random number generator must be seeded prior to calling RSA_generate_key.
my
$rv
= Net::SSLeay::RSA_generate_key(
$bits
,
$e
,
$perl_cb
,
$perl_cb_arg
);
=item * RSA_free
Frees the RSA structure and its components. The key is erased
before
the memory is returned to the
system
.
Net::SSLeay::RSA_free(
$r
);
=item * RSA_get_key_parameters
B<COMPATIBILITY>: not available
when
OpenSSL is 1.1.0 or later and Net-SSLeay is 1.92 or earlier
Returns a list of pointers to BIGNUMs representing the parameters of
the key in this order: C<(n, e, d, p,
q, dmp1,
dmq1, iqmp)>
B<Caution>: returned list consists of direct pointers to BIGNUMs. These must
not be freed by the
caller
. These pointers can be used to duplicate a
BIGNUM, which would need to be blessed as Crypt::OpenSSL::Bignum
for
further
use
. See L<Crypt::OpenSSL::Bignum> and OpenSSL manual
for
more about
C<bless_pointer> to why C<BN_dup()> is used.
my
(
@params
) = RSA_get_key_parameters(
$r
);
my
$dup
= Net::SSLeay::BN_dup(
$params
[1]);
my
$e
= Crypt::OpenSSL::Bignum->bless_pointer(
$dup
);
print
"exponent: "
,
$e
->to_decimal(),
"\n"
;
This function
has
no
equivalent in OpenSSL or LibreSSL but combines
functions C<RSA_get0_key>, C<RSA_get0_factors> and C<RSA_get0_crt_params>
for
an easier interface.
=back
=head3 Low level API: BIO_* related functions
=over
=item * BIO_eof
Returns 1
if
the BIO
has
read
EOF, the precise meaning of
'EOF'
varies according to the BIO type.
my
$rv
= Net::SSLeay::BIO_eof(
$s
);
=item * BIO_f_ssl
Returns the SSL BIO method. This is a filter BIO which is a wrapper
round the OpenSSL SSL routines adding a BIO
'flavour'
to SSL I/O.
my
$rv
= Net::SSLeay::BIO_f_ssl();
=item * BIO_free
Frees up a single BIO.
my
$rv
= Net::SSLeay::BIO_free(
$bio
);
=item * BIO_new
Returns a new BIO using method
$type
my
$rv
= Net::SSLeay::BIO_new(
$type
);
=item * BIO_new_buffer_ssl_connect
Creates a new BIO chain consisting of a buffering BIO, an SSL BIO (using ctx) and a
connect
BIO.
my
$rv
= Net::SSLeay::BIO_new_buffer_ssl_connect(
$ctx
);
=item * BIO_new_file
Creates a new file BIO
with
mode
$mode
the meaning of mode is the same
as the stdio function fopen(). The BIO_CLOSE flag is set on the returned BIO.
my
$rv
= Net::SSLeay::BIO_new_file(
$filename
,
$mode
);
=item * BIO_new_ssl
Allocates an SSL BIO using SSL_CTX ctx and using client mode
if
client is non zero.
my
$rv
= Net::SSLeay::BIO_new_ssl(
$ctx
,
$client
);
=item * BIO_new_ssl_connect
Creates a new BIO chain consisting of an SSL BIO (using ctx) followed by a
connect
BIO.
my
$rv
= Net::SSLeay::BIO_new_ssl_connect(
$ctx
);
=item * BIO_pending
Return the number of pending characters in the BIOs
read
buffers.
my
$rv
= Net::SSLeay::BIO_pending(
$s
);
=item * BIO_wpending
Return the number of pending characters in the BIOs
write
buffers.
my
$rv
= Net::SSLeay::BIO_wpending(
$s
);
=item * BIO_read
Read the underlying descriptor.
Net::SSLeay::BIO_read(
$s
,
$max
);
=item * BIO_write
Attempts to
write
data from
$buffer
to BIO
$b
.
my
$rv
= Net::SSLeay::BIO_write(
$b
,
$buffer
);
=item * BIO_s_mem
Return the memory BIO method function.
my
$rv
= Net::SSLeay::BIO_s_mem();
=item * BIO_ssl_copy_session_id
Copies an SSL session id between BIO chains from and to. It does this by locating
the SSL BIOs in
each
chain and calling SSL_copy_session_id() on the internal SSL pointer.
my
$rv
= Net::SSLeay::BIO_ssl_copy_session_id(
$to
,
$from
);
=item * BIO_ssl_shutdown
Closes down an SSL connection on BIO chain bio. It does this by locating the
SSL BIO in the chain and calling SSL_shutdown() on its internal SSL pointer.
Net::SSLeay::BIO_ssl_shutdown(
$ssl_bio
);
=back
=head3 Low level API: Server side Server Name Indication (SNI) support
=over
=item * set_tlsext_host_name
TBA
=item * get_servername
TBA
=item * get_servername_type
TBA
=item * CTX_set_tlsext_servername_callback
B<COMPATIBILITY:> requires at least OpenSSL 0.9.8f
This function is used in a server to support Server side Server Name Indication (SNI).
Net::SSLeay::CTX_set_tlsext_servername_callback(
$ctx
,
$code
);
On the client side:
On the server side:
Set up an additional SSL_CTX()
for
each
different certificate.
Add a servername callback to
each
SSL_CTX() using CTX_set_tlsext_servername_callback().
The callback function is required to retrieve the client-supplied servername
with
get_servername(ssl). Figure out the right
SSL_CTX to go
with
that host name, then switch the SSL object to that SSL_CTX
with
set_SSL_CTX().
Example:
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
};
} );
More complete example:
my
%hostnames
= (
'sni1'
=> {
cert
=>
'sni1.pem'
,
key
=>
'sni1.key'
},
'sni2'
=> {
cert
=>
'sni2.pem'
,
key
=>
'sni2.key'
},
);
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
;
}
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
;
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
};
} );
$s
= Net::SSLeay::new(
$ctx
);
Net::SSLeay::set_fd(
$s
,
fileno
(
$accepted_socket
));
Net::SSLeay::
accept
(
$s
);
=back
=head3 Low level API: NPN (
next
protocol negotiation) related functions
NPN is being replaced
with
ALPN, a more recent TLS extension
for
application
protocol negotiation that's in process of being adopted by IETF. Please look
below
for
APLN API description.
Simple approach
for
using NPN support looks like this:
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"
;
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
();
}
Please note that the selection (negotiation) is performed by client side, the server side simply advertise the list of supported protocols.
Advanced approach allows you to implement your own negotiation algorithm.
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
);
Detection of NPN support (works even in older Net::SSLeay versions):
if
(
exists
&Net::SSLeay::P_next_proto_negotiated
) {
}
=over
=item * CTX_set_next_proto_select_cb
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
; requires at least OpenSSL 1.0.1
B<NOTE:> You need CTX_set_next_proto_select_cb on B<client side> of SSL connection.
Simple usage - in this case a
"common"
negotiation algorithm (as implemented by openssl's function SSL_select_next_proto) is used.
$rv
= Net::SSLeay::CTX_set_next_proto_select_cb(
$ctx
,
$arrayref
);
Advanced usage (you probably
do
not need this):
$rv
= Net::SSLeay::CTX_set_next_proto_select_cb(
$ctx
,
$perl_callback_function
,
$callback_data
);
sub
npn_advertised_cb_invoke {
my
(
$ssl
,
$arrayref_proto_list_advertised_by_server
,
$callback_data
) =
@_
;
my
$status
;
$status
= 1;
return
$status
, [
'http1.1'
,
'spdy/2'
];
}
To undefine/clear this callback
use
:
Net::SSLeay::CTX_set_next_proto_select_cb(
$ctx
,
undef
);
=item * CTX_set_next_protos_advertised_cb
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
; requires at least OpenSSL 1.0.1
B<NOTE:> You need CTX_set_next_proto_select_cb on B<server side> of SSL connection.
Simple usage:
$rv
= Net::SSLeay::CTX_set_next_protos_advertised_cb(
$ctx
,
$arrayref
);
Advanced usage (you probably
do
not need this):
$rv
= Net::SSLeay::CTX_set_next_protos_advertised_cb(
$ctx
,
$perl_callback_function
,
$callback_data
);
sub
npn_advertised_cb_invoke {
my
(
$ssl
,
$callback_data
) =
@_
;
return
[
'http1.1'
,
'spdy/2'
];
}
To undefine/clear this callback
use
:
Net::SSLeay::CTX_set_next_protos_advertised_cb(
$ctx
,
undef
);
=item * P_next_proto_negotiated
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
; requires at least OpenSSL 1.0.1
Returns the name of negotiated protocol
for
given
SSL connection
$ssl
.
$rv
= Net::SSLeay::P_next_proto_negotiated(
$ssl
);
=item * P_next_proto_last_status
B<COMPATIBILITY:> not available in Net-SSLeay-1.45 and
before
; requires at least OpenSSL 1.0.1
Returns the result of the
last
negotiation
for
given
SSL connection
$ssl
.
$rv
= Net::SSLeay::P_next_proto_last_status(
$ssl
);
=back
=head3 Low level API: ALPN (application layer protocol negotiation) related functions
Application protocol can be negotiated via two different mechanisms employing
two different TLS extensions: NPN (obsolete) and ALPN (recommended).
The API is rather similar,
with
slight differences reflecting protocol
specifics. In particular,
with
ALPN the protocol negotiation takes place on
server,
while
with
NPN the client implements the protocol negotiation logic.
With ALPN, the most basic implementation looks like this:
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"
;
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
();
}
Advanced approach allows you to implement your own negotiation algorithm.
Net::SSLeay::CTX_set_alpn_select_cb(
$ctx
,
$perl_callback_function
,
$callback_data
);
Detection of ALPN support (works even in older Net::SSLeay versions):
if
(
exists
&Net::SSLeay::P_alpn_selected
) {
}
=over
=item * CTX_set_alpn_select_cb
B<COMPATIBILITY:> not available in Net-SSLeay-1.55 and
before
; requires at least OpenSSL 1.0.2
B<NOTE:> You need CTX_set_alpn_select_cb on B<server side> of TLS connection.
Simple usage - in this case a
"common"
negotiation algorithm (as implemented by openssl's function SSL_select_next_proto) is used.
$rv
= Net::SSLeay::CTX_set_alpn_select_cb(
$ctx
,
$arrayref
);
Advanced usage (you probably
do
not need this):
$rv
= Net::SSLeay::CTX_set_alpn_select_cb(
$ctx
,
$perl_callback_function
,
$callback_data
);
sub
alpn_select_cb_invoke {
my
(
$ssl
,
$arrayref_proto_list_advertised_by_client
,
$callback_data
) =
@_
;
if
(
$negotiated
) {
return
'http/2.0'
;
}
else
{
return
undef
;
}
}
To undefine/clear this callback
use
:
Net::SSLeay::CTX_set_alpn_select_cb(
$ctx
,
undef
);
=item * set_alpn_protos
B<COMPATIBILITY:> not available in Net-SSLeay-1.55 and
before
; requires at least OpenSSL 1.0.2
B<NOTE:> You need set_alpn_protos on B<client side> of TLS connection.
This adds list of supported application layer protocols to ClientHello message sent by a client.
It advertises the enumeration of supported protocols:
Net::SSLeay::set_alpn_protos(
$ssl
, [
'http/1.1'
,
'http/2.0'
,
'spdy/3'
]);
=item * CTX_set_alpn_protos
B<COMPATIBILITY:> not available in Net-SSLeay-1.55 and
before
; requires at least OpenSSL 1.0.2
B<NOTE:> You need CTX_set_alpn_protos on B<client side> of TLS connection.
This adds list of supported application layer protocols to ClientHello message sent by a client.
It advertises the enumeration of supported protocols:
Net::SSLeay::CTX_set_alpn_protos(
$ctx
, [
'http/1.1'
,
'http/2.0'
,
'spdy/3'
]);
=item * P_alpn_selected
B<COMPATIBILITY:> not available in Net-SSLeay-1.55 and
before
; requires at least OpenSSL 1.0.2
Returns the name of negotiated protocol
for
given
TLS connection
$ssl
.
$rv
= Net::SSLeay::P_alpn_selected(
$ssl
);
=back
=head3 Low level API: DANE Support
OpenSSL version 1.0.2 adds preliminary support RFC6698 Domain Authentication of
Named Entities (DANE) Transport Layer Association within OpenSSL
=over
=item * SSL_get_tlsa_record_byname
B<COMPATIBILITY:> DELETED from net-ssleay, since it is not supported by OpenSSL
In order to facilitate DANE there is additional interface,
SSL_get_tlsa_record_byname, accepting hostname, port and
socket
type
that returns packed TLSA 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).
Net::SSLeay::get_tlsa_record_byname(
$name
,
$port
,
$type
);
=back
=head3 Low level API: Other functions
=over
=item * COMP_add_compression_method
Adds the compression method cm
with
the identifier id to the list of available compression methods.
This list is globally maintained
for
all SSL operations within this application.
It cannot be set
for
specific SSL_CTX or SSL objects.
my
$rv
= Net::SSLeay::COMP_add_compression_method(
$id
,
$cm
);
=item * DH_free
Frees the DH structure and its components. The
values
are erased
before
the memory is returned to the
system
.
Net::SSLeay::DH_free(
$dh
);
=item * FIPS_mode_set
Enable or disable FIPS mode in a FIPS capable OpenSSL.
Net::SSLeay::FIPS_mode_set(
$enable
);
=back
=head3 Low level API: EC related functions
=over
=item * CTX_set_tmp_ecdh
TBA
=item * EC_KEY_free
TBA
=item * EC_KEY_new_by_curve_name
TBA
=item * EC_KEY_generate_key
Generates a EC key and returns it in a newly allocated EC_KEY structure.
The EC key then can be used to create a PKEY which can be used in calls
like X509_set_pubkey.
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
);
This function
has
no
equivalent in OpenSSL but combines multiple OpenSSL
functions
for
an easier interface.
=item * CTX_set_ecdh_auto, set_ecdh_auto
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
ECDH temporary
keys
used during key exchange.
This function is
no
longer available
for
OpenSSL 1.1.0 or higher.
Net::SSLeay::CTX_set_ecdh_auto(
$ctx
,1);
Net::SSLeay::set_ecdh_auto(
$ssl
,1);
=item * CTX_set1_curves_list, set1_curves_list
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 TLS 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.
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"
);
=item * CTX_set1_groups_list, set1_groups_list
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 DH groups can be
given
as supported by TLS 1.3.
These functions are only available since OpenSSL 1.1.1.
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"
);
=back
=head3 Low level API: OSSL_LIB_CTX and OSSL_PROVIDER related functions
=over
=item * OSSL_LIB_CTX_get0_global_default
Returns a concrete (non NULL) reference to the global
default
library context.
my
$libctx
= Net::SSLeay::OSSL_LIB_CTX_get0_global_default();
Typically it's simpler to
use
undef
with
functions that take an
OSSL_LIB_CTX argument
when
global
default
library context is needed.
=item * OSSL_PROVIDER_load
Loads and initializes a provider
my
$provider
= Net::SSLeay::OSSL_PROVIDER_load(
$libctx
,
$name
);
Using
undef
loads the provider within the global
default
library context.
my
$provider
= Net::SSLeay::OSSL_PROVIDER_load(
undef
,
'legacy'
);
=item * OSSL_PROVIDER_try_load
Loads and initializes a provider similar to OSSL_PROVIDER_load
with
additional fallback control.
my
$provider
= Net::SSLeay::OSSL_PROVIDER_try_load(
$libctx
,
$name
,
$retain_fallbacks
);
=item * OSSL_PROVIDER_unload
Unloads the
given
provider.
my
$rv
= Net::SSLeay::OSSL_PROVIDER_unload(
$provider
);
=item * OSSL_PROVIDER_available
Checks
if
a named provider is available
for
use
.
my
$rv
= Net::SSLeay::OSSL_PROVIDER_available(
$libctx
,
$name
);
=item * OSSL_PROVIDER_do_all
Iterates over all loaded providers. A callback is called
for
each
provider.
my
$rv
= Net::SSLeay::OSSL_PROVIDER_do_all(
$libctx
,
$cb
,
$cbdata
);
Example:
sub
do_all_cb {
my
(
$provider
,
$cbdata
) =
@_
;
my
$name
= Net::SSLeay::OSSL_PROVIDER_get0_name(
$provider
);
print
"Callback for provider: '$name', cbdata: '$cbdata'\n"
;
return
1;
}
my
$data_for_cb
=
'Hello'
;
Net::SSLeay::OSSL_PROVIDER_available(
undef
,
'default'
) ||
die
'default provider not available'
;
Net::SSLeay::OSSL_PROVIDER_load(
undef
,
'legacy'
) ||
die
'load legacy'
;
Net::SSLeay::OSSL_PROVIDER_load(
undef
,
'null'
) ||
die
'load null'
;
Net::SSLeay::OSSL_PROVIDER_do_all(
undef
, \
&do_all_cb
,
$data_for_cb
) ||
die
'a callback failed'
;
=item * OSSL_PROVIDER_get0_name
Returns the name of the
given
provider.
my
$name
= Net::SSLeay::OSSL_PROVIDER_get0_name(
$provider
);
=item * OSSL_PROVIDER_self_test
Runs the provider's self tests.
my
$rv
= Net::SSLeay::OSSL_PROVIDER_self_test(
$provider
);
=back
=head3 Low level API: TLS PSK related functions
B<COMPATIBILITY:> not available in Net-SSLeay-1.92 and
before
. The TLSv1.3 specific functions
require
at least OpenSSL 1.1.1 and the others
require
at least OpenSSL 1.0.0. Not available in LibreSSL.
=over
=item * CTX_use_psk_identity_hint
Set PSK identity hint
for
SSL_CTX on TLS server
for
TLSv1.2 and earlier versions.
my
$ret
= Net::SSLeay::CTX_use_psk_identity_hint(
$ctx
,
$hint
);
Example:
my
$ret
= Net::SSLeay::CTX_use_psk_identity_hint(
$ctx
,
'ctx server identity_hint'
);
=item * use_psk_identity_hint
Set PSK identity hint
for
SSL on TLS server
for
TLSv1.2 and earlier versions.
my
$ret
= Net::SSLeay::use_psk_identity_hint(
$ssl
,
$hint
);
Example:
my
$ret
= Net::SSLeay::use_psk_identity_hint(
$ssl
,
'ssl server identity_hint'
);
=item * CTX_set_psk_server_callback
Set a callback
for
an SSL_CTX on TLS server
for
using PSKs
with
all TLS versions.
B<NOTE:> With TLSv1.3 Net::SSLeay::CTX_set_psk_find_session_callback
or Net::SSLeay::set_psk_find_session_callback is recommended.
sub
tls12_psk_cb {
my
(
$ssl
,
$identity
,
$max_psk_len
) =
@_
;
my
$psk
=
pack
(
'H*'
,
'deadbeef'
);
return
$psk
if
length
$psk
<=
$max_psk_len
;
return
undef
;
}
my
$cb
= \
&tls12_psk_cb
;
Net::SSLeay::CTX_set_psk_server_callback(
$ctx
,
$cb
);
The callback function must
return
a PSK in packed binary
format
, or
C<
undef
> to trigger C<unknown_psk_identity> alert and TLS handshake
failure. If TLS handshake failure without PSK specific alert is
required,
return
packed random data.
=item * set_psk_server_callback
Set a callback
for
an SSL on TLS server
for
using PSKs
with
all TLS versions.
B<NOTE:> With TLSv1.3 Net::SSLeay::CTX_set_psk_find_session_callback
or Net::SSLeay::set_psk_find_session_callback is recommended.
Net::SSLeay::set_psk_server_callback(
$ssl
,
$cb
);
See Net::SSLeay::CTX_set_psk_server_callback() documentation
for
a full example
with
a callback.
=item * CTX_set_psk_find_session_callback
Set a callback
for
an SSL_CTX on TLS server
for
using TLSv1.3 PSKs.
sub
tls13_psk_cb {
my
(
$ssl
,
$identity
) =
@_
;
my
$sess
= Net::SSLeay::SESSION_new();
my
$cipher
= Net::SSLeay::CIPHER_find(
$ssl
,
pack
(
'n'
, 0x1301));
Net::SSLeay::SESSION_set1_master_key(
$sess
,
pack
(
'H*'
,
'deadbeef'
));
Net::SSLeay::SESSION_set_cipher(
$sess
,
$cipher
);
Net::SSLeay::SESSION_set_protocol_version(
$sess
, Net::SSLeay::version(
$ssl
));
return
(1,
$sess
);
}
my
$cb
= \
&tls13_psk_cb
;
Net::SSLeay::CTX_set_psk_find_session_callback(
$ctx
,
$cb
);
The callback function must
return
a two value list. When the first
value is 0, the connection setup fails. When the first value is 1, the
second value must be a valid C<SSL_SESSION> or C<
undef
>. When the
second value is a valid C<SSL_SESSION>, the TLS handshake proceeds
with
PSK authentication. When the the second value is C<
undef
>, PSK is
not used the TLS handshake proceeds
with
certificate authentication.
=item * set_psk_find_session_callback
Set a callback
for
an SSL on TLS server
for
using TLSv1.3 PSKs.
Net::SSLeay::set_psk_find_session_callback(
$ssl
,
$cb
);
See Net::SSLeay::CTX_set_psk_find_session_callback() documentation
for
a full example
with
a callback.
=item * CTX_set_psk_use_session_callback
Set a callback
for
an SSL_CTX on TLS client
for
using TLSv1.3 PSKs.
sub
tls13_use_psk_cb {
my
(
$ssl
,
$md
) =
@_
;
my
$psk_identity
=
"test-tls-psk"
;
my
$sess
= Net::SSLeay::SESSION_new();
my
$cipher
= Net::SSLeay::CIPHER_find(
$ssl
,
pack
(
'n'
, 0x1301));
Net::SSLeay::SESSION_set1_master_key(
$sess
,
pack
(
'H*'
,
'deadbeef'
));
Net::SSLeay::SESSION_set_cipher(
$sess
,
$cipher
);
Net::SSLeay::SESSION_set_protocol_version(
$sess
, Net::SSLeay::TLS1_3_VERSION());
if
(
$md
) {
my
$sess_md
= Net::SSLeay::CIPHER_get_handshake_digest(
$cipher
);
my
$md_type
;
$md_type
= Net::SSLeay::EVP_MD_type(
$md
)
if
$md
;
my
$sess_md_type
= Net::SSLeay::EVP_MD_type(
$sess_md
);
if
(
$md_type
!=
$sess_md_type
) {
my
$switched_cipher
= Net::SSLeay::CIPHER_find(
$ssl
,
pack
(
'n'
, 0x1302));
my
$switched_md
= Net::SSLeay::CIPHER_get_handshake_digest(
$switched_cipher
);
my
$switched_md_type
= Net::SSLeay::EVP_MD_type(
$switched_md
);
if
(
$md_type
!=
$switched_md_type
) {
Net::SSLeay::SESSION_free(
$sess
);
return
(0,
undef
,
undef
);
}
Net::SSLeay::SESSION_set_cipher(
$sess
,
$switched_cipher
);
}
}
return
(1,
$psk_identity
,
$sess
);
}
my
$cb
= \
&tls13_use_psk_cb
;
Net::SSLeay::CTX_set_psk_use_session_callback(
$ctx
,
$cb
);
The callback function must
return
a two value list. When the first
value is 0, the connection setup fails. When the first value is 1, the
second value must be a valid C<SSL_SESSION> or C<
undef
>. When the
second value is a valid C<SSL_SESSION>, the TLS handshake proceeds
with
PSK authentication. When the the second value is C<
undef
>, PSK is
not used the TLS handshake proceeds
with
certificate authentication.
=item * set_psk_use_session_callback
Set a callback
for
an SSL on TLS client
for
using TLSv1.3 PSKs.
sub
tls13_psk_cb {
my
(
$ssl
,
$identity
) =
@_
;
my
$sess
= Net::SSLeay::SESSION_new();
my
$cipher
= Net::SSLeay::CIPHER_find(
$ssl
,
pack
(
'n'
, 0x1301));
Net::SSLeay::SESSION_set1_master_key(
$sess
,
pack
(
'H*'
,
'deadbeef'
));
Net::SSLeay::SESSION_set_cipher(
$sess
,
$cipher
);
Net::SSLeay::SESSION_set_protocol_version(
$sess
, Net::SSLeay::version(
$ssl
));
return
(1,
$sess
);
}
my
$cb
= \
&tls13_psk_cb
;
Net::SSLeay::CTX_set_psk_find_session_callback(
$ctx
,
$cb
);
The callback function must
return
a two value list. When the first
value is 0, the connection setup fails. When the first value is 1, the
second value must be a valid C<SSL_SESSION> or C<
undef
>. When the
second value is a valid C<SSL_SESSION>, the TLS handshake proceeds
with
PSK authentication. When the the second value is C<
undef
>, PSK is
not used the TLS handshake proceeds
with
certificate authentication.
=back
=head2 Constants
There are many openssl constants available in L<Net::SSLeay>. You can
use
them like this:
print
&Net::SSLeay::NID_commonName
;
print
Net::SSLeay::NID_commonName();
Or you can
import
them and
use
:
print
&NID_commonName
;
print
NID_commonName();
print
NID_commonName;
The constants names are derived from openssl constants, however constants starting
with
C<SSL_> prefix
have name
with
C<SSL_> part stripped - e.g. openssl's constant C<SSL_OP_ALL> is available as C<Net::SSLeay::OP_ALL>
The list of all available constant names:
=
for
comment
The list below is automatically generated -
do
not manually modify it.
To add or remove a constant, edit helper_script/constants.txt, then run
helper_script/update-exported-constants.
=
for
start_constants
AD_ACCESS_DENIED OPENSSL_INIT_NO_LOAD_CRYPTO_STRINGS
AD_BAD_CERTIFICATE OPENSSL_INIT_NO_LOAD_SSL_STRINGS
AD_BAD_CERTIFICATE_HASH_VALUE OPENSSL_MODULES_DIR
AD_BAD_CERTIFICATE_STATUS_RESPONSE OPENSSL_PLATFORM
AD_BAD_RECORD_MAC OPENSSL_VERSION
AD_CERTIFICATE_EXPIRED OPENSSL_VERSION_MAJOR
AD_CERTIFICATE_REQUIRED OPENSSL_VERSION_MINOR
AD_CERTIFICATE_REVOKED OPENSSL_VERSION_NUMBER
AD_CERTIFICATE_UNKNOWN OPENSSL_VERSION_PATCH
AD_CERTIFICATE_UNOBTAINABLE OPENSSL_VERSION_STRING
AD_CLOSE_NOTIFY OP_ALL
AD_DECODE_ERROR OP_ALLOW_CLIENT_RENEGOTIATION
AD_DECOMPRESSION_FAILURE OP_ALLOW_NO_DHE_KEX
AD_DECRYPTION_FAILED OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION
AD_DECRYPT_ERROR OP_CIPHER_SERVER_PREFERENCE
AD_EXPORT_RESTRICTION OP_CISCO_ANYCONNECT
AD_HANDSHAKE_FAILURE OP_CLEANSE_PLAINTEXT
AD_ILLEGAL_PARAMETER OP_COOKIE_EXCHANGE
AD_INAPPROPRIATE_FALLBACK OP_CRYPTOPRO_TLSEXT_BUG
AD_INSUFFICIENT_SECURITY OP_DISABLE_TLSEXT_CA_NAMES
AD_INTERNAL_ERROR OP_DONT_INSERT_EMPTY_FRAGMENTS
AD_MISSING_EXTENSION OP_ENABLE_KTLS
AD_NO_APPLICATION_PROTOCOL OP_ENABLE_MIDDLEBOX_COMPAT
AD_NO_CERTIFICATE OP_EPHEMERAL_RSA
AD_NO_RENEGOTIATION OP_IGNORE_UNEXPECTED_EOF
AD_PROTOCOL_VERSION OP_LEGACY_SERVER_CONNECT
AD_RECORD_OVERFLOW OP_MICROSOFT_BIG_SSLV3_BUFFER
AD_UNEXPECTED_MESSAGE OP_MICROSOFT_SESS_ID_BUG
AD_UNKNOWN_CA OP_MSIE_SSLV2_RSA_PADDING
AD_UNKNOWN_PSK_IDENTITY OP_NETSCAPE_CA_DN_BUG
AD_UNRECOGNIZED_NAME OP_NETSCAPE_CHALLENGE_BUG
AD_UNSUPPORTED_CERTIFICATE OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG
AD_UNSUPPORTED_EXTENSION OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG
AD_USER_CANCELLED OP_NON_EXPORT_FIRST
ASN1_STRFLGS_ESC_CTRL OP_NO_ANTI_REPLAY
ASN1_STRFLGS_ESC_MSB OP_NO_CLIENT_RENEGOTIATION
ASN1_STRFLGS_ESC_QUOTE OP_NO_COMPRESSION
ASN1_STRFLGS_RFC2253 OP_NO_ENCRYPT_THEN_MAC
ASYNC_NO_JOBS OP_NO_EXTENDED_MASTER_SECRET
ASYNC_PAUSED OP_NO_QUERY_MTU
CB_ACCEPT_EXIT OP_NO_RENEGOTIATION
CB_ACCEPT_LOOP OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION
CB_ALERT OP_NO_SSL_MASK
CB_CONNECT_EXIT OP_NO_SSLv2
CB_CONNECT_LOOP OP_NO_SSLv3
CB_EXIT OP_NO_TICKET
CB_HANDSHAKE_DONE OP_NO_TLSv1
CB_HANDSHAKE_START OP_NO_TLSv1_1
CB_LOOP OP_NO_TLSv1_2
CB_READ OP_NO_TLSv1_3
CB_READ_ALERT OP_PKCS1_CHECK_1
CB_WRITE OP_PKCS1_CHECK_2
CB_WRITE_ALERT OP_PRIORITIZE_CHACHA
CLIENT_HELLO_CB OP_SAFARI_ECDHE_ECDSA_BUG
CLIENT_HELLO_ERROR OP_SINGLE_DH_USE
CLIENT_HELLO_RETRY OP_SINGLE_ECDH_USE
CLIENT_HELLO_SUCCESS OP_SSLEAY_080_CLIENT_DH_BUG
CONF_MFLAGS_DEFAULT_SECTION OP_SSLREF2_REUSE_CERT_TYPE_BUG
CONF_MFLAGS_IGNORE_ERRORS OP_TLSEXT_PADDING
CONF_MFLAGS_IGNORE_MISSING_FILE OP_TLS_BLOCK_PADDING_BUG
CONF_MFLAGS_IGNORE_RETURN_CODES OP_TLS_D5_BUG
CONF_MFLAGS_NO_DSO OP_TLS_ROLLBACK_BUG
CONF_MFLAGS_SILENT READING
ERROR_NONE RECEIVED_SHUTDOWN
ERROR_SSL RETRY_VERIFY
ERROR_SYSCALL RSA_3
ERROR_WANT_ACCEPT RSA_F4
ERROR_WANT_ASYNC R_BAD_AUTHENTICATION_TYPE
ERROR_WANT_ASYNC_JOB R_BAD_CHECKSUM
ERROR_WANT_CLIENT_HELLO_CB R_BAD_MAC_DECODE
ERROR_WANT_CONNECT R_BAD_RESPONSE_ARGUMENT
ERROR_WANT_READ R_BAD_SSL_FILETYPE
ERROR_WANT_RETRY_VERIFY R_BAD_SSL_SESSION_ID_LENGTH
ERROR_WANT_WRITE R_BAD_STATE
ERROR_WANT_X509_LOOKUP R_BAD_WRITE_RETRY
ERROR_ZERO_RETURN R_CHALLENGE_IS_DIFFERENT
EVP_PKS_DSA R_CIPHER_TABLE_SRC_ERROR
EVP_PKS_EC R_INVALID_CHALLENGE_LENGTH
EVP_PKS_RSA R_NO_CERTIFICATE_SET
EVP_PKT_ENC R_NO_CERTIFICATE_SPECIFIED
EVP_PKT_EXCH R_NO_CIPHER_LIST
EVP_PKT_EXP R_NO_CIPHER_MATCH
EVP_PKT_SIGN R_NO_PRIVATEKEY
EVP_PK_DH R_NO_PUBLICKEY
EVP_PK_DSA R_NULL_SSL_CTX
EVP_PK_EC R_PEER_DID_NOT_RETURN_A_CERTIFICATE
EVP_PK_RSA R_PEER_ERROR
FILETYPE_ASN1 R_PEER_ERROR_CERTIFICATE
FILETYPE_PEM R_PEER_ERROR_NO_CIPHER
F_CLIENT_CERTIFICATE R_PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE
F_CLIENT_HELLO R_PUBLIC_KEY_ENCRYPT_ERROR
F_CLIENT_MASTER_KEY R_PUBLIC_KEY_IS_NOT_RSA
F_D2I_SSL_SESSION R_READ_WRONG_PACKET_TYPE
F_GET_CLIENT_FINISHED R_SHORT_READ
F_GET_CLIENT_HELLO R_SSL_SESSION_ID_IS_DIFFERENT
F_GET_CLIENT_MASTER_KEY R_UNABLE_TO_EXTRACT_PUBLIC_KEY
F_GET_SERVER_FINISHED R_UNKNOWN_REMOTE_ERROR_TYPE
F_GET_SERVER_HELLO R_UNKNOWN_STATE
F_GET_SERVER_VERIFY R_X509_LIB
F_I2D_SSL_SESSION SENT_SHUTDOWN
F_READ_N SESSION_ASN1_VERSION
F_REQUEST_CERTIFICATE SESS_CACHE_BOTH
F_SERVER_HELLO SESS_CACHE_CLIENT
F_SSL_CERT_NEW SESS_CACHE_NO_AUTO_CLEAR
F_SSL_GET_NEW_SESSION SESS_CACHE_NO_INTERNAL
F_SSL_NEW SESS_CACHE_NO_INTERNAL_LOOKUP
F_SSL_READ SESS_CACHE_NO_INTERNAL_STORE
F_SSL_RSA_PRIVATE_DECRYPT SESS_CACHE_OFF
F_SSL_RSA_PUBLIC_ENCRYPT SESS_CACHE_SERVER
F_SSL_SESSION_NEW SESS_CACHE_UPDATE_TIME
F_SSL_SESSION_PRINT_FP SSL2_MT_CLIENT_CERTIFICATE
F_SSL_SET_FD SSL2_MT_CLIENT_FINISHED
F_SSL_SET_RFD SSL2_MT_CLIENT_HELLO
F_SSL_SET_WFD SSL2_MT_CLIENT_MASTER_KEY
F_SSL_USE_CERTIFICATE SSL2_MT_ERROR
F_SSL_USE_CERTIFICATE_ASN1 SSL2_MT_REQUEST_CERTIFICATE
F_SSL_USE_CERTIFICATE_FILE SSL2_MT_SERVER_FINISHED
F_SSL_USE_PRIVATEKEY SSL2_MT_SERVER_HELLO
F_SSL_USE_PRIVATEKEY_ASN1 SSL2_MT_SERVER_VERIFY
F_SSL_USE_PRIVATEKEY_FILE SSL2_VERSION
F_SSL_USE_RSAPRIVATEKEY SSL3_MT_CCS
F_SSL_USE_RSAPRIVATEKEY_ASN1 SSL3_MT_CERTIFICATE
F_SSL_USE_RSAPRIVATEKEY_FILE SSL3_MT_CERTIFICATE_REQUEST
F_WRITE_PENDING SSL3_MT_CERTIFICATE_STATUS
GEN_DIRNAME SSL3_MT_CERTIFICATE_URL
GEN_DNS SSL3_MT_CERTIFICATE_VERIFY
GEN_EDIPARTY SSL3_MT_CHANGE_CIPHER_SPEC
GEN_EMAIL SSL3_MT_CLIENT_HELLO
GEN_IPADD SSL3_MT_CLIENT_KEY_EXCHANGE
GEN_OTHERNAME SSL3_MT_ENCRYPTED_EXTENSIONS
GEN_RID SSL3_MT_END_OF_EARLY_DATA
GEN_URI SSL3_MT_FINISHED
GEN_X400 SSL3_MT_HELLO_REQUEST
LIBRESSL_VERSION_NUMBER SSL3_MT_KEY_UPDATE
MBSTRING_ASC SSL3_MT_MESSAGE_HASH
MBSTRING_BMP SSL3_MT_NEWSESSION_TICKET
MBSTRING_FLAG SSL3_MT_NEXT_PROTO
MBSTRING_UNIV SSL3_MT_SERVER_DONE
MBSTRING_UTF8 SSL3_MT_SERVER_HELLO
MIN_RSA_MODULUS_LENGTH_IN_BYTES SSL3_MT_SERVER_KEY_EXCHANGE
MODE_ACCEPT_MOVING_WRITE_BUFFER SSL3_MT_SUPPLEMENTAL_DATA
MODE_ASYNC SSL3_RT_ALERT
MODE_AUTO_RETRY SSL3_RT_APPLICATION_DATA
MODE_ENABLE_PARTIAL_WRITE SSL3_RT_CHANGE_CIPHER_SPEC
MODE_NO_AUTO_CHAIN SSL3_RT_HANDSHAKE
MODE_RELEASE_BUFFERS SSL3_RT_HEADER
NID_OCSP_sign SSL3_RT_INNER_CONTENT_TYPE
NID_SMIMECapabilities SSL3_VERSION
NID_X500 SSLEAY_BUILT_ON
NID_X509 SSLEAY_CFLAGS
NID_ad_OCSP SSLEAY_DIR
NID_ad_ca_issuers SSLEAY_PLATFORM
NID_algorithm SSLEAY_VERSION
NID_authority_key_identifier ST_ACCEPT
NID_basic_constraints ST_BEFORE
NID_bf_cbc ST_CONNECT
NID_bf_cfb64 ST_INIT
NID_bf_ecb ST_OK
NID_bf_ofb64 ST_READ_BODY
NID_cast5_cbc ST_READ_HEADER
NID_cast5_cfb64 TLS1_1_VERSION
NID_cast5_ecb TLS1_2_VERSION
NID_cast5_ofb64 TLS1_3_VERSION
NID_certBag TLS1_VERSION
NID_certificate_policies TLSEXT_STATUSTYPE_ocsp
NID_client_auth TLSEXT_TYPE_application_layer_protocol_negotiation
NID_code_sign TLSEXT_TYPE_cert_type
NID_commonName TLSEXT_TYPE_certificate_authorities
NID_countryName TLSEXT_TYPE_client_authz
NID_crlBag TLSEXT_TYPE_client_cert_type
NID_crl_distribution_points TLSEXT_TYPE_client_certificate_url
NID_crl_number TLSEXT_TYPE_compress_certificate
NID_crl_reason TLSEXT_TYPE_cookie
NID_delta_crl TLSEXT_TYPE_early_data
NID_des_cbc TLSEXT_TYPE_ec_point_formats
NID_des_cfb64 TLSEXT_TYPE_elliptic_curves
NID_des_ecb TLSEXT_TYPE_encrypt_then_mac
NID_des_ede TLSEXT_TYPE_extended_master_secret
NID_des_ede3 TLSEXT_TYPE_key_share
NID_des_ede3_cbc TLSEXT_TYPE_max_fragment_length
NID_des_ede3_cfb64 TLSEXT_TYPE_next_proto_neg
NID_des_ede3_ofb64 TLSEXT_TYPE_padding
NID_des_ede_cbc TLSEXT_TYPE_post_handshake_auth
NID_des_ede_cfb64 TLSEXT_TYPE_psk
NID_des_ede_ofb64 TLSEXT_TYPE_psk_kex_modes
NID_des_ofb64 TLSEXT_TYPE_quic_transport_parameters
NID_description TLSEXT_TYPE_renegotiate
NID_desx_cbc TLSEXT_TYPE_server_authz
NID_dhKeyAgreement TLSEXT_TYPE_server_cert_type
NID_dnQualifier TLSEXT_TYPE_server_name
NID_dsa TLSEXT_TYPE_session_ticket
NID_dsaWithSHA TLSEXT_TYPE_signature_algorithms
NID_dsaWithSHA1 TLSEXT_TYPE_signature_algorithms_cert
NID_dsaWithSHA1_2 TLSEXT_TYPE_signed_certificate_timestamp
NID_dsa_2 TLSEXT_TYPE_srp
NID_email_protect TLSEXT_TYPE_status_request
NID_ext_key_usage TLSEXT_TYPE_supported_groups
NID_ext_req TLSEXT_TYPE_supported_versions
NID_friendlyName TLSEXT_TYPE_truncated_hmac
NID_givenName TLSEXT_TYPE_trusted_ca_keys
NID_hmacWithSHA1 TLSEXT_TYPE_use_srtp
NID_id_ad TLSEXT_TYPE_user_mapping
NID_id_ce VERIFY_CLIENT_ONCE
NID_id_kp VERIFY_FAIL_IF_NO_PEER_CERT
NID_id_pbkdf2 VERIFY_NONE
NID_id_pe VERIFY_PEER
NID_id_pkix VERIFY_POST_HANDSHAKE
NID_id_qt_cps V_OCSP_CERTSTATUS_GOOD
NID_id_qt_unotice V_OCSP_CERTSTATUS_REVOKED
NID_idea_cbc V_OCSP_CERTSTATUS_UNKNOWN
NID_idea_cfb64 WRITING
NID_idea_ecb X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT
NID_idea_ofb64 X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS
NID_info_access X509_CHECK_FLAG_NEVER_CHECK_SUBJECT
NID_initials X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS
NID_invalidity_date X509_CHECK_FLAG_NO_WILDCARDS
NID_issuer_alt_name X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS
NID_keyBag X509_CRL_VERSION_1
NID_key_usage X509_CRL_VERSION_2
NID_localKeyID X509_FILETYPE_ASN1
NID_localityName X509_FILETYPE_DEFAULT
NID_md2 X509_FILETYPE_PEM
NID_md2WithRSAEncryption X509_LOOKUP
NID_md5 X509_PURPOSE_ANY
NID_md5WithRSA X509_PURPOSE_CRL_SIGN
NID_md5WithRSAEncryption X509_PURPOSE_NS_SSL_SERVER
NID_md5_sha1 X509_PURPOSE_OCSP_HELPER
NID_mdc2 X509_PURPOSE_SMIME_ENCRYPT
NID_mdc2WithRSA X509_PURPOSE_SMIME_SIGN
NID_ms_code_com X509_PURPOSE_SSL_CLIENT
NID_ms_code_ind X509_PURPOSE_SSL_SERVER
NID_ms_ctl_sign X509_PURPOSE_TIMESTAMP_SIGN
NID_ms_efs X509_REQ_VERSION_1
NID_ms_ext_req X509_REQ_VERSION_2
NID_ms_sgc X509_REQ_VERSION_3
NID_name X509_TRUST_COMPAT
NID_netscape X509_TRUST_DEFAULT
NID_netscape_base_url X509_TRUST_EMAIL
NID_netscape_ca_policy_url X509_TRUST_OBJECT_SIGN
NID_netscape_ca_revocation_url X509_TRUST_OCSP_REQUEST
NID_netscape_cert_extension X509_TRUST_OCSP_SIGN
NID_netscape_cert_sequence X509_TRUST_SSL_CLIENT
NID_netscape_cert_type X509_TRUST_SSL_SERVER
NID_netscape_comment X509_TRUST_TSA
NID_netscape_data_type X509_VERSION_1
NID_netscape_renewal_url X509_VERSION_2
NID_netscape_revocation_url X509_VERSION_3
NID_netscape_ssl_server_name X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH
NID_ns_sgc X509_V_ERR_AKID_SKID_MISMATCH
NID_organizationName X509_V_ERR_APPLICATION_VERIFICATION
NID_organizationalUnitName X509_V_ERR_AUTHORITY_KEY_IDENTIFIER_CRITICAL
NID_pbeWithMD2AndDES_CBC X509_V_ERR_CA_BCONS_NOT_CRITICAL
NID_pbeWithMD2AndRC2_CBC X509_V_ERR_CA_CERT_MISSING_KEY_USAGE
NID_pbeWithMD5AndCast5_CBC X509_V_ERR_CA_KEY_TOO_SMALL
NID_pbeWithMD5AndDES_CBC X509_V_ERR_CA_MD_TOO_WEAK
NID_pbeWithMD5AndRC2_CBC X509_V_ERR_CERT_CHAIN_TOO_LONG
NID_pbeWithSHA1AndDES_CBC X509_V_ERR_CERT_HAS_EXPIRED
NID_pbeWithSHA1AndRC2_CBC X509_V_ERR_CERT_NOT_YET_VALID
NID_pbe_WithSHA1And128BitRC2_CBC X509_V_ERR_CERT_REJECTED
NID_pbe_WithSHA1And128BitRC4 X509_V_ERR_CERT_REVOKED
NID_pbe_WithSHA1And2_Key_TripleDES_CBC X509_V_ERR_CERT_SIGNATURE_FAILURE
NID_pbe_WithSHA1And3_Key_TripleDES_CBC X509_V_ERR_CERT_UNTRUSTED
NID_pbe_WithSHA1And40BitRC2_CBC X509_V_ERR_CRL_HAS_EXPIRED
NID_pbe_WithSHA1And40BitRC4 X509_V_ERR_CRL_NOT_YET_VALID
NID_pbes2 X509_V_ERR_CRL_PATH_VALIDATION_ERROR
NID_pbmac1 X509_V_ERR_CRL_SIGNATURE_FAILURE
NID_pkcs X509_V_ERR_DANE_NO_MATCH
NID_pkcs3 X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT
NID_pkcs7 X509_V_ERR_DIFFERENT_CRL_SCOPE
NID_pkcs7_data X509_V_ERR_EC_KEY_EXPLICIT_PARAMS
NID_pkcs7_digest X509_V_ERR_EE_KEY_TOO_SMALL
NID_pkcs7_encrypted X509_V_ERR_EMAIL_MISMATCH
NID_pkcs7_enveloped X509_V_ERR_EMPTY_SUBJECT_ALT_NAME
NID_pkcs7_signed X509_V_ERR_EMPTY_SUBJECT_SAN_NOT_CRITICAL
NID_pkcs7_signedAndEnveloped X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD
NID_pkcs8ShroudedKeyBag X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD
NID_pkcs9 X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD
NID_pkcs9_challengePassword X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD
NID_pkcs9_contentType X509_V_ERR_EXCLUDED_VIOLATION
NID_pkcs9_countersignature X509_V_ERR_EXTENSIONS_REQUIRE_VERSION_3
NID_pkcs9_emailAddress X509_V_ERR_HOSTNAME_MISMATCH
NID_pkcs9_extCertAttributes X509_V_ERR_INVALID_CA
NID_pkcs9_messageDigest X509_V_ERR_INVALID_CALL
NID_pkcs9_signingTime X509_V_ERR_INVALID_EXTENSION
NID_pkcs9_unstructuredAddress X509_V_ERR_INVALID_NON_CA
NID_pkcs9_unstructuredName X509_V_ERR_INVALID_POLICY_EXTENSION
NID_private_key_usage_period X509_V_ERR_INVALID_PURPOSE
NID_rc2_40_cbc X509_V_ERR_IP_ADDRESS_MISMATCH
NID_rc2_64_cbc X509_V_ERR_ISSUER_NAME_EMPTY
NID_rc2_cbc X509_V_ERR_KEYUSAGE_NO_CERTSIGN
NID_rc2_cfb64 X509_V_ERR_KEYUSAGE_NO_CRL_SIGN
NID_rc2_ecb X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE
NID_rc2_ofb64 X509_V_ERR_KU_KEY_CERT_SIGN_INVALID_FOR_NON_CA
NID_rc4 X509_V_ERR_MISSING_AUTHORITY_KEY_IDENTIFIER
NID_rc4_40 X509_V_ERR_MISSING_SUBJECT_KEY_IDENTIFIER
NID_rc5_cbc X509_V_ERR_NO_EXPLICIT_POLICY
NID_rc5_cfb64 X509_V_ERR_NO_ISSUER_PUBLIC_KEY
NID_rc5_ecb X509_V_ERR_NO_VALID_SCTS
NID_rc5_ofb64 X509_V_ERR_OCSP_CERT_UNKNOWN
NID_ripemd160 X509_V_ERR_OCSP_VERIFY_FAILED
NID_ripemd160WithRSA X509_V_ERR_OCSP_VERIFY_NEEDED
NID_rle_compression X509_V_ERR_OUT_OF_MEM
NID_rsa X509_V_ERR_PATHLEN_INVALID_FOR_NON_CA
NID_rsaEncryption X509_V_ERR_PATHLEN_WITHOUT_KU_KEY_CERT_SIGN
NID_rsadsi X509_V_ERR_PATH_LENGTH_EXCEEDED
NID_safeContentsBag X509_V_ERR_PATH_LOOP
NID_sdsiCertificate X509_V_ERR_PERMITTED_VIOLATION
NID_secretBag X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED
NID_serialNumber X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED
NID_server_auth X509_V_ERR_PROXY_SUBJECT_NAME_VIOLATION
NID_sha X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN
NID_sha1 X509_V_ERR_SIGNATURE_ALGORITHM_INCONSISTENCY
NID_sha1WithRSA X509_V_ERR_SIGNATURE_ALGORITHM_MISMATCH
NID_sha1WithRSAEncryption X509_V_ERR_STORE_LOOKUP
NID_sha224 X509_V_ERR_SUBJECT_ISSUER_MISMATCH
NID_sha224WithRSAEncryption X509_V_ERR_SUBJECT_KEY_IDENTIFIER_CRITICAL
NID_sha256 X509_V_ERR_SUBJECT_NAME_EMPTY
NID_sha256WithRSAEncryption X509_V_ERR_SUBTREE_MINMAX
NID_sha384 X509_V_ERR_SUITE_B_CANNOT_SIGN_P_384_WITH_P_256
NID_sha384WithRSAEncryption X509_V_ERR_SUITE_B_INVALID_ALGORITHM
NID_sha3_224 X509_V_ERR_SUITE_B_INVALID_CURVE
NID_sha3_256 X509_V_ERR_SUITE_B_INVALID_SIGNATURE_ALGORITHM
NID_sha3_384 X509_V_ERR_SUITE_B_INVALID_VERSION
NID_sha3_512 X509_V_ERR_SUITE_B_LOS_NOT_ALLOWED
NID_sha512 X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY
NID_sha512WithRSAEncryption X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE
NID_sha512_224 X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE
NID_sha512_224WithRSAEncryption X509_V_ERR_UNABLE_TO_GET_CRL
NID_sha512_256 X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER
NID_sha512_256WithRSAEncryption X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT
NID_shaWithRSAEncryption X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY
NID_shake128 X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE
NID_shake256 X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION
NID_stateOrProvinceName X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION
NID_subject_alt_name X509_V_ERR_UNNESTED_RESOURCE
NID_subject_key_identifier X509_V_ERR_UNSPECIFIED
NID_surname X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX
NID_sxnet X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE
NID_time_stamp X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE
NID_title X509_V_ERR_UNSUPPORTED_NAME_SYNTAX
NID_undef X509_V_ERR_UNSUPPORTED_SIGNATURE_ALGORITHM
NID_uniqueIdentifier X509_V_FLAG_ALLOW_PROXY_CERTS
NID_x509Certificate X509_V_FLAG_CB_ISSUER_CHECK
NID_x509Crl X509_V_FLAG_CHECK_SS_SIGNATURE
NID_zlib_compression X509_V_FLAG_CRL_CHECK
NOTHING X509_V_FLAG_CRL_CHECK_ALL
OCSP_RESPONSE_STATUS_INTERNALERROR X509_V_FLAG_EXPLICIT_POLICY
OCSP_RESPONSE_STATUS_MALFORMEDREQUEST X509_V_FLAG_EXTENDED_CRL_SUPPORT
OCSP_RESPONSE_STATUS_SIGREQUIRED X509_V_FLAG_IGNORE_CRITICAL
OCSP_RESPONSE_STATUS_SUCCESSFUL X509_V_FLAG_INHIBIT_ANY
OCSP_RESPONSE_STATUS_TRYLATER X509_V_FLAG_INHIBIT_MAP
OCSP_RESPONSE_STATUS_UNAUTHORIZED X509_V_FLAG_LEGACY_VERIFY
OPENSSL_BUILT_ON X509_V_FLAG_NOTIFY_POLICY
OPENSSL_CFLAGS X509_V_FLAG_NO_ALT_CHAINS
OPENSSL_CPU_INFO X509_V_FLAG_NO_CHECK_TIME
OPENSSL_DIR X509_V_FLAG_PARTIAL_CHAIN
OPENSSL_ENGINES_DIR X509_V_FLAG_POLICY_CHECK
OPENSSL_FULL_VERSION_STRING X509_V_FLAG_POLICY_MASK
OPENSSL_INFO_CONFIG_DIR X509_V_FLAG_SUITEB_128_LOS
OPENSSL_INFO_CPU_SETTINGS X509_V_FLAG_SUITEB_128_LOS_ONLY
OPENSSL_INFO_DIR_FILENAME_SEPARATOR X509_V_FLAG_SUITEB_192_LOS
OPENSSL_INFO_DSO_EXTENSION X509_V_FLAG_TRUSTED_FIRST
OPENSSL_INFO_ENGINES_DIR X509_V_FLAG_USE_CHECK_TIME
OPENSSL_INFO_LIST_SEPARATOR X509_V_FLAG_USE_DELTAS
OPENSSL_INFO_MODULES_DIR X509_V_FLAG_X509_STRICT
OPENSSL_INFO_SEED_SOURCE X509_V_OK
OPENSSL_INIT_ADD_ALL_CIPHERS XN_FLAG_COMPAT
OPENSSL_INIT_ADD_ALL_DIGESTS XN_FLAG_DN_REV
OPENSSL_INIT_ASYNC XN_FLAG_DUMP_UNKNOWN_FIELDS
OPENSSL_INIT_ATFORK XN_FLAG_FN_ALIGN
OPENSSL_INIT_ENGINE_AFALG XN_FLAG_FN_LN
OPENSSL_INIT_ENGINE_CAPI XN_FLAG_FN_MASK
OPENSSL_INIT_ENGINE_CRYPTODEV XN_FLAG_FN_NONE
OPENSSL_INIT_ENGINE_DYNAMIC XN_FLAG_FN_OID
OPENSSL_INIT_ENGINE_OPENSSL XN_FLAG_FN_SN
OPENSSL_INIT_ENGINE_PADLOCK XN_FLAG_MULTILINE
OPENSSL_INIT_ENGINE_RDRAND XN_FLAG_ONELINE
OPENSSL_INIT_LOAD_CONFIG XN_FLAG_RFC2253
OPENSSL_INIT_LOAD_CRYPTO_STRINGS XN_FLAG_SEP_COMMA_PLUS
OPENSSL_INIT_LOAD_SSL_STRINGS XN_FLAG_SEP_CPLUS_SPC
OPENSSL_INIT_NO_ADD_ALL_CIPHERS XN_FLAG_SEP_MASK
OPENSSL_INIT_NO_ADD_ALL_DIGESTS XN_FLAG_SEP_MULTILINE
OPENSSL_INIT_NO_ATEXIT XN_FLAG_SEP_SPLUS_SPC
OPENSSL_INIT_NO_LOAD_CONFIG XN_FLAG_SPC_EQ
=
for
end_constants
=head2 INTERNAL ONLY functions (
do
not
use
these )
The following functions are not intended
for
use
from outside of L<Net::SSLeay> module.
They might be removed, renamed or changed without prior notice in future version.
Simply B<DO NOT USE THEM>!
=over
=item * hello
=item * blength
=item * constant
=back
=head1 EXAMPLES
One very good example to look at is the implementation of C<sslcat()> in the
C<SSLeay.pm> file.
The following is a simple SSLeay client (
with
too little error checking :-(
Net::SSLeay::load_error_strings();
Net::SSLeay::SSLeay_add_ssl_algorithms();
Net::SSLeay::randomize();
(
$dest_serv
,
$port
,
$msg
) =
@ARGV
;
$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);
$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));
$res
= Net::SSLeay::
connect
(
$ssl
) and die_if_ssl_error(
"ssl connect"
);
print
"Cipher `"
. Net::SSLeay::get_cipher(
$ssl
) .
"'\n"
;
$res
= Net::SSLeay::
write
(
$ssl
,
$msg
);
die_if_ssl_error(
"ssl write"
);
CORE::
shutdown
S, 1;
$got
= Net::SSLeay::
read
(
$ssl
);
die_if_ssl_error(
"ssl read"
);
print
$got
;
Net::SSLeay::free (
$ssl
);
Net::SSLeay::CTX_free (
$ctx
);
close
S;
The following is a simple SSLeay echo server (non forking):
Net::SSLeay::load_error_strings();
Net::SSLeay::SSLeay_add_ssl_algorithms();
Net::SSLeay::randomize();
$our_ip
=
"\0\0\0\0"
;
$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"
);
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);
(
$af
,
$client_port
,
$client_ip
) =
unpack
(
$sockaddr_template
,
$addr
);
@inetaddr
=
unpack
(
'C4'
,
$client_ip
);
print
"$af connection from "
.
join
(
'.'
,
@inetaddr
) .
":$client_port\n"
;
$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"
;
$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
);
close
NS;
}
Yet another echo server. This one runs from C</etc/inetd.conf> 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 C<STDIN> and C<STDOUT> are wired to SSL.
Net::SSLeay::load_error_strings();
Net::SSLeay::SSLeay_add_ssl_algorithms();
Net::SSLeay::randomize();
chdir
'/key/dir'
or
die
"chdir: $!"
;
$| = 1;
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"
);
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
);
Net::SSLeay::CTX_free (
$ctx
);
close
LOG;
There are also a number of example/test programs in the examples directory:
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)
=head1 INSTALLATION
See README and README.* in the distribution directory
for
installation guidance on a variety of platforms.
=head1 LIMITATIONS
C<Net::SSLeay::
read
()> 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:
$reply
=
''
;
while
(
$got
= Net::SSLeay::
read
(
$ssl
)) {
last
if
print_errs(
'SSL_read'
);
$reply
.=
$got
;
}
Although there is
no
built-in limit in C<Net::SSLeay::
write
()>, the network
packet size limitation applies here as well, thus
use
:
$written
= 0;
while
(
$written
<
length
(
$message
)) {
$written
+= Net::SSLeay::
write
(
$ssl
,
substr
(
$message
,
$written
));
last
if
print_errs(
'SSL_write'
);
}
Or alternatively you can just
use
the following convenience functions:
Net::SSLeay::ssl_write_all(
$ssl
,
$message
) or
die
"ssl write failure"
;
$got
= Net::SSLeay::ssl_read_all(
$ssl
) or
die
"ssl read failure"
;
=head1 KNOWN BUGS AND CAVEATS
LibreSSL versions in the 3.1 - 3.3 series contain a TLS 1.3 implementation that
is not fully compatible
with
the libssl API, but is still advertised during
protocol auto-negotiation. If you encounter problems or unexpected behaviour
with
SSL or SSL_CTX objects whose protocol version was automatically negotiated
and libssl is provided by any of these versions of LibreSSL, it could be because
the peers negotiated to
use
TLS 1.3 -
try
setting the maximum protocol version
to TLS 1.2 (via C<Net::SSLeay::set_max_proto_version()> or
C<Net::SSLeay::CTX_set_max_proto_version()>)
before
establishing the connection.
The first stable LibreSSL version
with
a fully libssl-compatible TLS 1.3
implementation is 3.4.1.
An OpenSSL bug CVE-2015-0290
"OpenSSL Multiblock Corrupted Pointer Issue"
can cause POST requests of over 90kB to fail or crash. This bug is reported to be fixed in
OpenSSL 1.0.2a.
Autoloader emits a
Argument
"xxx"
isn
't numeric in entersub at blib/lib/Net/SSLeay.pm'
warning
if
die_if_ssl_error is made autoloadable. If you figure out why,
drop me a line.
Callback set using C<SSL_set_verify()> does not appear to work. This may
well be an openssl problem (e.g. see C<ssl/ssl_lib.c> line 1029). Try using
C<SSL_CTX_set_verify()> instead and
do
not be surprised
if
even this stops
working in future versions.
Callback and certificate verification stuff is generally too little tested.
Random numbers are not initialized randomly enough, especially
if
you
do
not have C</dev/random> and/or C</dev/urandom> (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.
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
C </dev/random> or to operate insecurely
if
you
use
C </dev/urandom>. What happens is that
when
too much
randomness is drawn from the operating
system
's randomness pool
then randomness can temporarily be unavailable. C</dev/random> 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.
C</dev/urandom> solves this dilemma more pragmatically by simply returning
predictable
"random"
numbers. Some C</dev/urandom> emulation software
however actually seems to implement C</dev/random> semantics. Caveat emptor.
I've been pointed to two such daemons by Mik Firestone <mik@
@speed
.stdio._com>
who
has
used them on Solaris 8:
=over
=item 1
=item 2
Pseudo-random number generating daemon (PRNGD) at
=back
If you are using the low level API functions to communicate
with
other
SSL implementations, you would
do
well to call
Net::SSLeay::CTX_set_options(
$ctx
,
&Net::SSLeay::OP_ALL
)
or die_if_ssl_error(
"ssl ctx set options"
);
to cope
with
some well know bugs in some other SSL
implementations. The high level API functions always set all known
compatibility options.
Sometimes C<sslcat()> (and the high level HTTPS functions that build on it)
is too fast in signaling the EOF to legacy HTTPS servers. This causes
the server to
return
empty page. To work
around
this problem you can
set the global variable
$Net::SSLeay::slowly
= 1;
HTTP/1.1 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 SSL session cache on your server helps to
alleviate the CPU load somewhat.
As of version 1.09 many newer OpenSSL auxiliary functions were
added (from C<REM_AUTOMATICALLY_GENERATED_1_09> onwards in C<SSLeay.xs>).
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.
This module defaults to using OpenSSL automatic protocol negotiation
code
for
automatically detecting the version of the SSL/TLS 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.
$Net::SSLeay::ssl_version
= 2;
$Net::SSLeay::ssl_version
= 3;
$Net::SSLeay::ssl_version
= 10;
$Net::SSLeay::ssl_version
= 11;
$Net::SSLeay::ssl_version
= 12;
$Net::SSLeay::ssl_version
= 13;
Although the autonegotiation is nice to have, the SSL 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 SSL handshake level),
try
this option
before
mailing me.
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.
The high level API 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.
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 API functions
do
this, thus you would have to program it using the low level API. A
good place to start is to see how the C<Net::SSLeay::http_cat()> function
is implemented.
The high level API functions
use
a global file handle C<SSLCAT_S>
internally. This really should not be a problem because there is
no
way to interleave the high level API 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.
=head1 DIAGNOSTICS
=over
=item Random number generator not seeded!!!
B<(W)> This warning indicates that C<randomize()> was not able to
read
C</dev/random> or C</dev/urandom>, possibly because your
system
does not
have them or they are differently named. You can still
use
SSL , but
the encryption will not be as strong.
=item open_tcp_connection: destination host not found:`server' (port 123) ($!)
Name lookup
for
host named C<server> failed.
=item open_tcp_connection: failed `server', 123 ($!)
The name was resolved, but establishing the TCP connection failed.
=item msg 123: 1 - error:140770F8:SSL routines:SSL23_GET_SERVER_HELLO:unknown proto
SSLeay error string. The first number (123) is the PID, 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.
=item msg 123: 1 - error:02001002::lib(2) :func(1) :reason(2)
The same as above, but you didn't call load_error_strings() so SSLeay
couldn't verbosely explain the error. You can still find out what it
means
with
this command:
/usr/
local
/ssl/bin/ssleay errstr 02001002
=item Password is being asked
for
private key
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 FAQ that explains how to
do
this (or just
study
examples/makecert.pl which is used
during C<make test> to
do
just that).
=back
=head1 SECURITY
You can mitigate some of the security vulnerabilities that might be present in your SSL/TLS application:
=head2 BEAST Attack
=over
=back
The BEAST attack relies on a weakness in the way CBC mode is used in SSL/TLS.
In OpenSSL versions 0.9.6d and later, the protocol-level mitigation is enabled by
default
,
thus making it not vulnerable to the BEAST attack.
Solutions:
=over
=item * Compile
with
OpenSSL versions 0.9.6d or later, which enables SSL_OP_ALL by
default
=item * Ensure SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS is not enabled (its not enabled by
default
)
=item * Don't support SSLv2, SSLv3
=item * Actively control the ciphers your server supports
with
set_cipher_list:
=back
Net::SSLeay::set_cipher_list(
$ssl
,
'RC4-SHA:HIGH:!ADH'
);
=head2 Session Resumption
=over
=back
The SSL Labs vulnerability test on your SSL server might report in red:
Session resumption No (IDs assigned but not accepted)
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
, Net::SSLeay::SESS_CACHE_OFF());
=head2 Secure Renegotiation and DoS Attack
=over
=back
This is not a
"security flaw,"
it is more of a DoS vulnerability.
Solutions:
=over
=item * Do not support SSLv2
=item * Do not set the SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION option
=item * Compile
with
OpenSSL 0.9.8m or later
=back
=head1 BUGS
If you encounter a problem
with
this module that you believe is a bug, please
in the Net-SSLeay GitHub repository. Please make sure your bug report includes
the following information:
=over
=item * the code you are trying to run;
=item * your operating
system
name and version;
=item * the output of C<perl -V>;
=item * the version of OpenSSL or LibreSSL you are using.
=back
=head1 AUTHOR
Originally written by Sampo Kellomäki.
Maintained by Florian Ragwitz between November 2005 and January 2010.
Maintained by Mike McCauley between November 2005 and June 2018.
Maintained by Tuure Vartiainen between June 2018 and July 2018.
Maintained by Chris Novakovic and Heikki Vatiainen since June 2018.
=head1 COPYRIGHT
Copyright (c) 1996-2003 Sampo Kellomäki <sampo
@iki
.fi>
Copyright (c) 2005-2010 Florian Ragwitz <rafl
@debian
.org>
Copyright (c) 2005-2018 Mike McCauley <mikem
@airspayce
.com>
Copyright (c) 2018 Tuure Vartiainen <vartiait
@radiatorsoftware
.com>
Copyright (c) 2018- Chris Novakovic <chris
@chrisn
.me.uk>
Copyright (c) 2018- Heikki Vatiainen <hvn
@radiatorsoftware
.com>
All rights reserved.
=head1 LICENSE
This module is released under the terms of the Artistic License 2.0. For
details, see the C<LICENSE> file distributed
with
Net-SSLeay's source code.
=head1 SEE ALSO
Net::SSLeay::Handle - File handle interface
./examples - Example servers and a clients
openssl-users-request
@openssl
.org - General OpenSSL mailing list
perl(1)
perlref(1)
perllol(1)
perldoc ~openssl/doc/ssl/SSL_CTX_set_verify.pod