.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "Net::SSLeay 3pm" .TH Net::SSLeay 3pm "2017-01-10" "perl v5.24.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Net::SSLeay \- Perl extension for using OpenSSL .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Net::SSLeay qw(get_https post_https sslcat make_headers make_form); \& \& ($page) = get_https(\*(Aqwww.bacus.pt\*(Aq, 443, \*(Aq/\*(Aq); # Case 1 \& \& ($page, $response, %reply_headers) \& = get_https(\*(Aqwww.bacus.pt\*(Aq, 443, \*(Aq/\*(Aq, # Case 2 \& make_headers(User\-Agent => \*(AqCryptozilla/5.0b1\*(Aq, \& Referer => \*(Aqhttps://www.bacus.pt\*(Aq \& )); \& \& ($page, $result, %headers) = # Case 2b \& = get_https(\*(Aqwww.bacus.pt\*(Aq, 443, \*(Aq/protected.html\*(Aq, \& make_headers(Authorization => \& \*(AqBasic \*(Aq . MIME::Base64::encode("$user:$pass",\*(Aq\*(Aq)) \& ); \& \& ($page, $response, %reply_headers) \& = post_https(\*(Aqwww.bacus.pt\*(Aq, 443, \*(Aq/foo.cgi\*(Aq, \*(Aq\*(Aq, # Case 3 \& make_form(OK => \*(Aq1\*(Aq, \& name => \*(AqSampo\*(Aq \& )); \& \& $reply = sslcat($host, $port, $request); # Case 4 \& \& ($reply, $err, $server_cert) = sslcat($host, $port, $request); # Case 5 \& \& $Net::SSLeay::trace = 2; # 0=no debugging, 1=ciphers, 2=trace, 3=dump data \& \& Net::SSLeay::initialize(); # Initialize ssl library once .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Net::SSLeay module contains perl bindings to openssl () library. .PP \&\fB\s-1COMPATIBILITY NOTE:\s0\fR Net::SSLeay cannot be built with pre\-0.9.3 openssl. It is strongly recommended to use at least 0.9.7 (as older versions are not tested during development). Some low level \s-1API\s0 functions may be available with certain openssl versions. .PP It is compatible with OpenSSL 1.0 and 1.1. Some functions are not available under OpenSSL 1.1. .PP Net::SSLeay module basically comprise of: .IP "\(bu" 4 High level functions for accessing web servers (by using \s-1HTTP/HTTPS\s0) .IP "\(bu" 4 Low level \s-1API \s0(mostly mapped 1:1 to openssl's C functions) .IP "\(bu" 4 Convenience functions (related to low level \s-1API\s0 but with more perl friendly interface) .PP There is also a related module called Net::SSLeay::Handle included in this distribution that you might want to use instead. It has its own pod documentation. .SS "High level functions for accessing web servers" .IX Subsection "High level functions for accessing web servers" This module offers some high level convenience functions for accessing web pages on \s-1SSL\s0 servers (for symmetry, the same \s-1API\s0 is offered for accessing http servers, too), an \f(CW\*(C`sslcat()\*(C'\fR function for writing your own clients, and finally access to the \s-1SSL\s0 api of the SSLeay/OpenSSL package so you can write servers or clients for more complicated applications. .PP For high level functions it is most convenient to import them into your main namespace as indicated in the synopsis. .PP \fIBasic set of functions\fR .IX Subsection "Basic set of functions" .IP "\(bu" 4 get_https .IP "\(bu" 4 post_https .IP "\(bu" 4 put_https .IP "\(bu" 4 head_https .IP "\(bu" 4 do_https .IP "\(bu" 4 sslcat .IP "\(bu" 4 https_cat .IP "\(bu" 4 make_form .IP "\(bu" 4 make_headers .PP \&\fBCase 1 (in \s-1SYNOPSIS\s0)\fR demonstrates the typical invocation of \fIget_https()\fR to fetch an \s-1HTML\s0 page from secure server. The first argument provides the hostname or \s-1IP\s0 in dotted decimal notation of the remote server to contact. The second argument is the \s-1TCP\s0 port at the remote end (your own port is picked arbitrarily from high numbered ports as usual for \s-1TCP\s0). The third argument is the \s-1URL\s0 of the page without the host name part. If in doubt consult the \s-1HTTP\s0 specifications at . .PP \&\fBCase 2 (in \s-1SYNOPSIS\s0)\fR demonstrates full fledged use of \f(CW\*(C`get_https()\*(C'\fR. As can be seen, \&\f(CW\*(C`get_https()\*(C'\fR 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 \f(CW\*(C`get_https()\*(C'\fR is used to insert some additional headers in the request. \f(CW\*(C`make_headers()\*(C'\fR is a function that will convert a list or hash to such headers. By default \f(CW\*(C`get_https()\*(C'\fR supplies \f(CW\*(C`Host\*(C'\fR (to make virtual hosting easy) and \f(CW\*(C`Accept\*(C'\fR (reportedly needed by \s-1IIS\s0) headers. .PP \&\fBCase 2b (in \s-1SYNOPSIS\s0)\fR demonstrates how to get a password protected page. Refer to the \s-1HTTP\s0 protocol specifications for further details (e.g. \s-1RFC\-2617\s0). .PP \&\fBCase 3 (in \s-1SYNOPSIS\s0)\fR invokes \f(CW\*(C`post_https()\*(C'\fR to submit a \s-1HTML/CGI\s0 form to a secure server. The first four arguments are equal to \f(CW\*(C`get_https()\*(C'\fR (note that the empty string (\f(CW\*(Aq\*(Aq\fR) is passed as header argument). The fifth argument is the contents of the form formatted according to \s-1CGI\s0 specification. Do not post \s-1UTF\-8\s0 data as content: use utf8::downgrade first. In this case the helper function \f(CW\*(C`make_https()\*(C'\fR is used to do the formatting, but you could pass any string. \f(CW\*(C`post_https()\*(C'\fR automatically adds \&\f(CW\*(C`Content\-Type\*(C'\fR and \f(CW\*(C`Content\-Length\*(C'\fR headers to the request. .PP \&\fBCase 4 (in \s-1SYNOPSIS\s0)\fR shows the fundamental \f(CW\*(C`sslcat()\*(C'\fR function (inspired in spirit by the \f(CW\*(C`netcat\*(C'\fR 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 \- \&\f(CW\*(C`sslcat()\*(C'\fR is just a transport. .PP \&\fBCase 5 (in \s-1SYNOPSIS\s0)\fR is a full invocation of \f(CW\*(C`sslcat()\*(C'\fR which allows the return of errors as well as the server (peer) certificate. .PP The \f(CW$trace\fR 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. .PP \fIAlternate versions of high-level \s-1API\s0\fR .IX Subsection "Alternate versions of high-level API" .IP "\(bu" 4 get_https3 .IP "\(bu" 4 post_https3 .IP "\(bu" 4 put_https3 .IP "\(bu" 4 get_https4 .IP "\(bu" 4 post_https4 .IP "\(bu" 4 put_https4 .PP 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. .PP .Vb 4 \& ($page, $response, @headers) = get_https(\*(Aqwww.bacus.pt\*(Aq, 443, \*(Aq/\*(Aq); \& for ($i = 0; $i < $#headers; $i+=2) { \& print "$headers[$i] = " . $headers[$i+1] . "\en"; \& } \& \& ($page, $response, $headers, $server_cert) \& = get_https3(\*(Aqwww.bacus.pt\*(Aq, 443, \*(Aq/\*(Aq); \& print "$headers\en"; \& \& ($page, $response, $headers_ref) \& = get_https4(\*(Aqwww.bacus.pt\*(Aq, 443, \*(Aq/\*(Aq); \& for $k (sort keys %{$headers_ref}) { \& for $v (@{$$headers_ref{$k}}) { \& print "$k = $v\en"; \& } \& } .Ve .PP All of the above code fragments accomplish the same thing: display all values of all headers. The \s-1API\s0 functions ending in \*(L"3\*(R" return the headers simply as a scalar string and it is up to the application to split them up. The functions ending in \*(L"4\*(R" return a reference to a hash of arrays (see perlref and perllol if you are not familiar with complex perl data structures). To access a single value of such a header hash you would do something like .PP .Vb 1 \& print $$headers_ref{COOKIE}[0]; .Ve .PP Variants 3 and 4 also allow you to discover the server certificate in case you would like to store or display it, e.g. .PP .Vb 11 \& ($p, $resp, $hdrs, $server_cert) = get_https3(\*(Aqwww.bacus.pt\*(Aq, 443, \*(Aq/\*(Aq); \& if (!defined($server_cert) || ($server_cert == 0)) { \& warn "Subject Name: undefined, Issuer Name: undefined"; \& } else { \& warn \*(AqSubject Name: \*(Aq \& . Net::SSLeay::X509_NAME_oneline( \& Net::SSLeay::X509_get_subject_name($server_cert)) \& . \*(AqIssuer Name: \*(Aq \& . Net::SSLeay::X509_NAME_oneline( \& Net::SSLeay::X509_get_issuer_name($server_cert)); \& } .Ve .PP Beware that this method only allows after the fact verification of the certificate: by the time \f(CW\*(C`get_https3()\*(C'\fR 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 \s-1API\s0 to first connect and verify the certificate and only then send the http data. See the implementation of \f(CW\*(C`ds_https3()\*(C'\fR for guidance on how to do this. .PP \fIUsing client certificates\fR .IX Subsection "Using client certificates" .PP Secure web communications are encrypted using symmetric crypto keys exchanged using encryption based on the certificate of the server. Therefore in all \s-1SSL\s0 connections the server must have a certificate. This serves both to authenticate the server to the clients and to perform the key exchange. .PP Sometimes it is necessary to authenticate the client as well. Two options are available: \s-1HTTP\s0 basic authentication and a client side certificate. The basic authentication over \s-1HTTPS\s0 is actually quite safe because \s-1HTTPS\s0 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 \s-1SSL\s0 level using a certificate. For this to work, both the client and the server have certificates (which typically are different) and private keys. .PP The \s-1API\s0 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. .PP .Vb 5 \& ($page, $result, %headers) = # 2c \& = get_https(\*(Aqwww.bacus.pt\*(Aq, 443, \*(Aq/protected.html\*(Aq, \& make_headers(Authorization => \& \*(AqBasic \*(Aq . MIME::Base64::encode("$user:$pass",\*(Aq\*(Aq)), \& \*(Aq\*(Aq, $mime_type6, $path_to_crt7, $path_to_key8); \& \& ($page, $response, %reply_headers) \& = post_https(\*(Aqwww.bacus.pt\*(Aq, 443, \*(Aq/foo.cgi\*(Aq, # 3b \& make_headers(\*(AqAuthorization\*(Aq => \& \*(AqBasic \*(Aq . MIME::Base64::encode("$user:$pass",\*(Aq\*(Aq)), \& make_form(OK => \*(Aq1\*(Aq, name => \*(AqSampo\*(Aq), \& $mime_type6, $path_to_crt7, $path_to_key8); .Ve .PP \&\fBCase 2c (in \s-1SYNOPSIS\s0)\fR demonstrates getting a password protected page that also requires a client certificate, i.e. it is possible to use both authentication methods simultaneously. .PP \&\fBCase 3b (in \s-1SYNOPSIS\s0)\fR is a full blown \s-1POST\s0 to a secure server that requires both password authentication and a client certificate, just like in case 2c. .PP Note: The client will not send a certificate unless the server requests one. This is typically achieved by setting the verify mode to \f(CW\*(C`VERIFY_PEER\*(C'\fR on the server: .PP .Vb 1 \& Net::SSLeay::set_verify(ssl, Net::SSLeay::VERIFY_PEER, 0); .Ve .PP See \f(CW\*(C`perldoc ~openssl/doc/ssl/SSL_CTX_set_verify.pod\*(C'\fR for a full description. .PP \fIWorking through a web proxy\fR .IX Subsection "Working through a web proxy" .IP "\(bu" 4 set_proxy .PP \&\f(CW\*(C`Net::SSLeay\*(C'\fR can use a web proxy to make its connections. You need to first set the proxy host and port using \f(CW\*(C`set_proxy()\*(C'\fR and then just use the normal \s-1API\s0 functions, e.g: .PP .Vb 2 \& Net::SSLeay::set_proxy(\*(Aqgateway.myorg.com\*(Aq, 8080); \& ($page) = get_https(\*(Aqwww.bacus.pt\*(Aq, 443, \*(Aq/\*(Aq); .Ve .PP If your proxy requires authentication, you can supply a username and password as well .PP .Vb 6 \& Net::SSLeay::set_proxy(\*(Aqgateway.myorg.com\*(Aq, 8080, \*(Aqjoe\*(Aq, \*(Aqsalainen\*(Aq); \& ($page, $result, %headers) = \& = get_https(\*(Aqwww.bacus.pt\*(Aq, 443, \*(Aq/protected.html\*(Aq, \& make_headers(Authorization => \& \*(AqBasic \*(Aq . MIME::Base64::encode("susie:pass",\*(Aq\*(Aq)) \& ); .Ve .PP This example demonstrates the case where we authenticate to the proxy as \&\f(CW"joe"\fR and to the final web server as \f(CW"susie"\fR. Proxy authentication requires the \f(CW\*(C`MIME::Base64\*(C'\fR module to work. .PP \fI\s-1HTTP \s0(without S) \s-1API\s0\fR .IX Subsection "HTTP (without S) API" .IP "\(bu" 4 get_http .IP "\(bu" 4 post_http .IP "\(bu" 4 tcpcat .IP "\(bu" 4 get_httpx .IP "\(bu" 4 post_httpx .IP "\(bu" 4 tcpxcat .PP Over the years it has become clear that it would be convenient to use the light-weight flavour \s-1API\s0 of \f(CW\*(C`Net::SSLeay\*(C'\fR for normal \s-1HTTP\s0 as well (see \&\f(CW\*(C`LWP\*(C'\fR 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 \s-1HTTP\s0 support was evolved. .PP .Vb 3 \& use Net::SSLeay qw(get_http post_http tcpcat \& get_httpx post_httpx tcpxcat \& make_headers make_form); \& \& ($page, $result, %headers) \& = get_http(\*(Aqwww.bacus.pt\*(Aq, 443, \*(Aq/protected.html\*(Aq, \& make_headers(Authorization => \& \*(AqBasic \*(Aq . MIME::Base64::encode("$user:$pass",\*(Aq\*(Aq)) \& ); \& \& ($page, $response, %reply_headers) \& = post_http(\*(Aqwww.bacus.pt\*(Aq, 443, \*(Aq/foo.cgi\*(Aq, \*(Aq\*(Aq, \& make_form(OK => \*(Aq1\*(Aq, \& name => \*(AqSampo\*(Aq \& )); \& \& ($reply, $err) = tcpcat($host, $port, $request); \& \& ($page, $result, %headers) \& = get_httpx($usessl, \*(Aqwww.bacus.pt\*(Aq, 443, \*(Aq/protected.html\*(Aq, \& make_headers(Authorization => \& \*(AqBasic \*(Aq . MIME::Base64::encode("$user:$pass",\*(Aq\*(Aq)) \& ); \& \& ($page, $response, %reply_headers) \& = post_httpx($usessl, \*(Aqwww.bacus.pt\*(Aq, 443, \*(Aq/foo.cgi\*(Aq, \*(Aq\*(Aq, \& make_form(OK => \*(Aq1\*(Aq, name => \*(AqSampo\*(Aq )); \& \& ($reply, $err, $server_cert) = tcpxcat($usessl, $host, $port, $request); .Ve .PP As can be seen, the \f(CW"x"\fR family of APIs takes as the first argument a flag which indicates whether \s-1SSL\s0 is used or not. .SS "Certificate verification and Certificate Revocation Lists (CRLs)" .IX Subsection "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 (\s-1CRL\s0) from the certificates issuer. A \s-1CRL\s0 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 \s-1PEM\s0 format. .PP You can enable \f(CW\*(C`Net::SSLeay CRL\*(C'\fR checking like this: .PP .Vb 3 \& &Net::SSLeay::X509_STORE_set_flags \& (&Net::SSLeay::CTX_get_cert_store($ssl), \& &Net::SSLeay::X509_V_FLAG_CRL_CHECK); .Ve .PP After setting this flag, if OpenSSL checks a peer's certificate, then it will attempt to find a \s-1CRL\s0 for the issuer. It does this by looking for a specially named file in the search directory specified by CTX_load_verify_locations. \s-1CRL\s0 files are named with the hash of the issuer's subject name, followed by \f(CW\*(C`.r0\*(C'\fR, \f(CW\*(C`.r1\*(C'\fR etc. For example \&\f(CW\*(C`ab1331b2.r0\*(C'\fR, \f(CW\*(C`ab1331b2.r1\*(C'\fR. 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 \s-1CRL\s0 file., see below). You can find out the hash of the issuer subject name in a \s-1CRL\s0 with .PP .Vb 1 \& openssl crl \-in crl.pem \-hash \-noout .Ve .PP If the peer certificate does not pass the revocation list, or if no \&\s-1CRL\s0 is found, then the handshaking fails with an error. .PP You can also force OpenSSL to look for CRLs in one or more arbitrarily named files. .PP .Vb 9 \& my $bio = Net::SSLeay::BIO_new_file($crlfilename, \*(Aqr\*(Aq); \& my $crl = Net::SSLeay::PEM_read_bio_X509_CRL($bio); \& if ($crl) { \& Net::SSLeay::X509_STORE_add_crl( \& Net::SSLeay::CTX_get_cert_store($ssl, $crl) \& ); \& } else { \& error reading CRL.... \& } .Ve .PP Usually the URLs where you can download the CRLs is contained in the certificate itself and you can extract them with .PP .Vb 1 \& my @url = Net::SSLeay::P_X509_get_crl_distribution_points($cert) .Ve .PP 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 \s-1DER\s0 format which you need to convert to \s-1PEM\s0 before you can use it: .PP .Vb 1 \& openssl crl \-in crl.der \-inform der \-out crl.pem .Ve .PP So as an alternative for faster and timely revocation checks you better use the Online Status Revocation Protocol (\s-1OCSP\s0). .SS "Certificate verification and Online Status Revocation Protocol (\s-1OCSP\s0)" .IX Subsection "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. .PP A faster way is to ask the \s-1CA\s0 to check the revocation of just a single or a few certificates using \s-1OCSP.\s0 Basically you generate for each certificate an \&\s-1OCSP_CERTID\s0 based on the certificate itself and its issuer, put the ids togetether into an \s-1OCSP_REQUEST\s0 and send the request to the \s-1URL\s0 given in the certificate. .PP As a result you get back an \s-1OCSP_RESPONSE\s0 and need to check the status of the response, check that it is valid (e.g. signed by the \s-1CA\s0) and finally extract the information about each \s-1OCSP_CERTID\s0 to find out if the certificate is still valid or got revoked. .PP With Net::SSLeay this can be done like this: .PP .Vb 8 \& # get id(s) for given certs, like from get_peer_certificate \& # or get_peer_cert_chain. This will croak if \& # \- one tries to make an OCSP_CERTID for a self\-signed certificate \& # \- the issuer of the certificate cannot be found in the SSL objects \& # store, nor in the current certificate chain \& my $cert = Net::SSLeay::get_peer_certificate($ssl); \& my $id = eval { Net::SSLeay::OCSP_cert2ids($ssl,$cert) }; \& die "failed to make OCSP_CERTID: $@" if $@; \& \& # create OCSP_REQUEST from id(s) \& # Multiple can be put into the same request, if the same OCSP responder \& # is responsible for them. \& my $req = Net::SSLeay::OCSP_ids2req($id); \& \& # determine URI of OCSP responder \& my $uri = Net::SSLeay::P_X509_get_ocsp_uri($cert); \& \& # Send stringified OCSP_REQUEST with POST to $uri. \& # We can ignore certificate verification for https, because the OCSP \& # response itself is signed. \& my $ua = HTTP::Tiny\->new(verify_SSL => 0); \& my $res = $ua\->request( \*(AqPOST\*(Aq,$uri, { \& headers => { \*(AqContent\-type\*(Aq => \*(Aqapplication/ocsp\-request\*(Aq }, \& content => Net::SSLeay::i2d_OCSP_REQUEST($req) \& }); \& my $content = $res && $res\->{success} && $res\->{content} \& or die "query failed"; \& \& # Extract OCSP_RESPONSE. \& # this will croak if the string is not an OCSP_RESPONSE \& my $resp = eval { Net::SSLeay::d2i_OCSP_RESPONSE($content) }; \& \& # Check status of response. \& my $status = Net::SSLeay::OCSP_response_status($resp); \& if ($status != Net::SSLeay::OCSP_RESPONSE_STATUS_SUCCESSFUL()) \& die "OCSP response failed: ". \& Net::SSLeay::OCSP_response_status_str($status); \& } \& \& # Verify signature of response and if nonce matches request. \& # This will croak if there is a nonce in the response, but it does not match \& # the request. It will return false if the signature could not be verified, \& # in which case details can be retrieved with Net::SSLeay::ERR_get_error. \& # It will not complain if the response does not contain a nonce, which is \& # usually the case with pre\-signed responses. \& if ( ! eval { Net::SSLeay::OCSP_response_verify($ssl,$resp,$req) }) { \& die "OCSP response verification failed"; \& } \& \& # Extract information from OCSP_RESPONSE for each of the ids. \& \& # If called in scalar context it will return the time (as time_t), when the \& # next update is due (minimum of all successful responses inside $resp). It \& # will croak on the following problems: \& # \- response is expired or not yet valid \& # \- no response for given OCSP_CERTID \& # \- certificate status is not good (e.g. revoked or unknown) \& if ( my $nextupd = eval { Net::SSLeay::OCSP_response_results($resp,$id) }) { \& warn "certificate is valid, next update in ". \& ($nextupd\-time())." seconds\en"; \& } else { \& die "certificate is not valid: $@"; \& } \& \& # But in array context it will return detailed information about each given \& # OCSP_CERTID instead croaking on errors: \& # if no @ids are given it will return information about all single responses \& # in the OCSP_RESPONSE \& my @results = Net::SSLeay::OCSP_response_results($resp,@ids); \& for my $r (@results) { \& print Dumper($r); \& # @results are in the same order as the @ids and contain: \& # $r\->[0] \- OCSP_CERTID \& # $r\->[1] \- undef if no error (certificate good) OR error message as string \& # $r\->[2] \- hash with details: \& # thisUpdate \- time_t of this single response \& # nextUpdate \- time_t when update is expected \& # statusType \- integer: \& # V_OCSP_CERTSTATUS_GOOD(0) \& # V_OCSP_CERTSTATUS_REVOKED(1) \& # V_OCSP_CERTSTATUS_UNKNOWN(2) \& # revocationTime \- time_t (only if revoked) \& # revocationReason \- integer (only if revoked) \& # revocationReason_str \- reason as string (only if revoked) \& } .Ve .PP To further speed up certificate revocation checking one can use a \s-1TLS\s0 extension to instruct the server to staple the \s-1OCSP\s0 response: .PP .Vb 3 \& # set TLS extension before doing SSL_connect \& Net::SSLeay::set_tlsext_status_type($ssl, \& Net::SSLeay::TLSEXT_STATUSTYPE_ocsp()); \& \& # setup callback to verify OCSP response \& my $cert_valid = undef; \& Net::SSLeay::CTX_set_tlsext_status_cb($context,sub { \& my ($ssl,$resp) = @_; \& if (!$resp) { \& # Lots of servers don\*(Aqt return an OCSP response. \& # In this case we must check the OCSP status outside the SSL \& # handshake. \& warn "server did not return stapled OCSP response\en"; \& return 1; \& } \& # verify status \& my $status = Net::SSLeay::OCSP_response_status($resp); \& if ($status != Net::SSLeay::OCSP_RESPONSE_STATUS_SUCCESSFUL()) { \& warn "OCSP response failure: $status\en"; \& return 1; \& } \& # verify signature \- we have no OCSP_REQUEST here to check nonce \& if (!eval { Net::SSLeay::OCSP_response_verify($ssl,$resp) }) { \& warn "OCSP response verify failed\en"; \& return 1; \& } \& # check if the certificate is valid \& # we should check here against the peer_certificate \& my $cert = Net::SSLeay::get_peer_certificate(); \& my $certid = eval { Net::SSLeay::OCSP_cert2ids($ssl,$cert) } or do { \& warn "cannot get certid from cert: $@"; \& $cert_valid = \-1; \& return 1; \& }; \& \& if ( $nextupd = eval { \& Net::SSLeay::OCSP_response_results($resp,$certid) }) { \& warn "certificate not revoked\en"; \& $cert_valid = 1; \& } else { \& warn "certificate not valid: $@"; \& $cert_valid = 0; \& } \& }); \& \& # do SSL handshake here \& .... \& # check if certificate revocation was checked already \& if ( ! defined $cert_valid) { \& # check revocation outside of SSL handshake by asking OCSP responder \& ... \& } elsif ( ! $cert_valid ) { \& die "certificate not valid \- closing SSL connection"; \& } elsif ( $cert_valid<0 ) { \& die "cannot verify certificate revocation \- self\-signed ?"; \& } else { \& # everything fine \& ... \& } .Ve .SS "Using Net::SSLeay in multi-threaded applications" .IX Subsection "Using Net::SSLeay in multi-threaded applications" \&\fB\s-1IMPORTANT:\s0 versions 1.42 or earlier are not thread-safe!\fR .PP Net::SSLeay module implements all necessary stuff to be ready for multi-threaded environment \- it requires openssl\-0.9.7 or newer. The implementation fully follows thread safety related requirements of openssl library(see ). .PP 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: .PP \fIInitialization\fR .IX Subsection "Initialization" .PP Load and initialize Net::SSLeay module in the main thread: .PP .Vb 2 \& use threads; \& use Net::SSLeay; \& \& Net::SSLeay::load_error_strings(); \& Net::SSLeay::SSLeay_add_ssl_algorithms(); \& Net::SSLeay::randomize(); \& \& sub do_master_job { \& #... call whatever from Net::SSLeay \& } \& \& sub do_worker_job { \& #... call whatever from Net::SSLeay \& } \& \& #start threads \& my $master = threads\->new(\e&do_master_job, \*(Aqparam1\*(Aq, \*(Aqparam2\*(Aq); \& my @workers = threads\->new(\e&do_worker_job, \*(Aqarg1\*(Aq, \*(Aqarg2\*(Aq) for (1..10); \& \& #waiting for all threads to finish \& $_\->join() for (threads\->list); .Ve .PP \&\s-1NOTE:\s0 Openssl's \f(CW\*(C`int SSL_library_init(void)\*(C'\fR function (which is also aliased as \&\f(CW\*(C`SSLeay_add_ssl_algorithms\*(C'\fR, \f(CW\*(C`OpenSSL_add_ssl_algorithms\*(C'\fR and \f(CW\*(C`add_ssl_algorithms\*(C'\fR) 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 \fINet::SSLeay::SSLeay_add_ssl_algorithms()\fR should work without trouble. .PP \fIUsing callbacks\fR .IX Subsection "Using callbacks" .PP 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. .PP \fIUsing openssl elements\fR .IX Subsection "Using openssl elements" .PP All openssl elements (X509, \s-1SSL_CTX, ...\s0) can be directly passed between threads. .PP .Vb 2 \& use threads; \& use Net::SSLeay; \& \& Net::SSLeay::load_error_strings(); \& Net::SSLeay::SSLeay_add_ssl_algorithms(); \& Net::SSLeay::randomize(); \& \& sub do_job { \& my $context = shift; \& Net::SSLeay::CTX_set_default_passwd_cb($context, sub { "secret" }); \& #... \& } \& \& my $c = Net::SSLeay::CTX_new(); \& threads\->create(\e&do_job, $c); .Ve .PP Or: .PP .Vb 2 \& use threads; \& use Net::SSLeay; \& \& my $context; #does not need to be \*(Aqshared\*(Aq \& \& 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(\e&do_job); .Ve .PP \fIUsing other perl modules based on Net::SSLeay\fR .IX Subsection "Using other perl modules based on Net::SSLeay" .PP It should be fine to use any other module based on Net::SSLeay (like IO::Socket::SSL) in multi-threaded applications. It is generally recommended to do any global initialization of such a module in the main thread before calling \f(CW\*(C`threads\->new(..)\*(C'\fR or \&\f(CW\*(C`threads\->create(..)\*(C'\fR but it might differ module by module. .PP To be safe you can load and init Net::SSLeay explicitly in the main thread: .PP .Vb 2 \& use Net::SSLeay; \& use Other::SSLeay::Based::Module; \& \& Net::SSLeay::load_error_strings(); \& Net::SSLeay::SSLeay_add_ssl_algorithms(); \& Net::SSLeay::randomize(); .Ve .PP Or even safer: .PP .Vb 2 \& use Net::SSLeay; \& use Other::SSLeay::Based::Module; \& \& BEGIN { \& Net::SSLeay::load_error_strings(); \& Net::SSLeay::SSLeay_add_ssl_algorithms(); \& Net::SSLeay::randomize(); \& } .Ve .PP \fICombining Net::SSLeay with other modules linked with openssl\fR .IX Subsection "Combining Net::SSLeay with other modules linked with openssl" .PP \&\fB\s-1BEWARE:\s0 This might be a big trouble! This is not guaranteed be thread-safe!\fR .PP There are many other (\s-1XS\s0) modules linked directly to openssl library (like Crypt::SSLeay). .PP As it is expected that also \*(L"another\*(R" module will call \f(CW\*(C`SSLeay_add_ssl_algorithms\*(C'\fR at some point we have again a trouble with multiple openssl initialization by Net::SSLeay and \*(L"another\*(R" module. .PP As you can expect Net::SSLeay is not able to avoid multiple initialization of openssl library called by \*(L"another\*(R" module, thus you have to handle this on your own (in some cases it might not be possible at all to avoid this). .PP \fIThreading with get_https and friends\fR .IX Subsection "Threading with get_https and friends" .PP The convenience functions get_https, post_https etc all initialize the \s-1SSL\s0 library by calling Net::SSLeay::initialize which does the conventional library initialization: .PP .Vb 3 \& Net::SSLeay::load_error_strings(); \& Net::SSLeay::SSLeay_add_ssl_algorithms(); \& Net::SSLeay::randomize(); .Ve .PP Net::SSLeay::initialize initializes the \s-1SSL\s0 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. .SS "Convenience routines" .IX Subsection "Convenience routines" To be used with Low level \s-1API\s0 .PP .Vb 5 \& 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); .Ve .IP "\(bu" 4 randomize .Sp seeds the openssl \s-1PRNG\s0 with \f(CW\*(C`/dev/urandom\*(C'\fR (see the top of \f(CW\*(C`SSLeay.pm\*(C'\fR 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 \s-1API\s0 functions automatically call \f(CW\*(C`randomize()\*(C'\fR so it is not needed with them. See also caveats. .IP "\(bu" 4 set_cert_and_key .Sp 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. .IP "\(bu" 4 dump_peer_certificate .Sp allows you to get a plaintext description of the certificate the peer (usually the server) presented to us. .IP "\(bu" 4 ssl_read_all .Sp see ssl_write_all (below) .IP "\(bu" 4 ssl_write_all .Sp \&\f(CW\*(C`ssl_read_all()\*(C'\fR and \f(CW\*(C`ssl_write_all()\*(C'\fR provide true blocking semantics for these operations (see limitation, below, for explanation). These are much preferred to the low level \s-1API\s0 equivalents (which implement \s-1BSD\s0 blocking semantics). The message argument to \f(CW\*(C`ssl_write_all()\*(C'\fR can be a reference. This is helpful to avoid unnecessary copying when writing something big, e.g: .Sp .Vb 2 \& $data = \*(AqA\*(Aq x 1000000000; \& Net::SSLeay::ssl_write_all($ssl, \e$data) or die "ssl write failed"; .Ve .IP "\(bu" 4 ssl_read_CRLF .Sp uses \f(CW\*(C`ssl_read_all()\*(C'\fR to read in a line terminated with a carriage return followed by a linefeed (\s-1CRLF\s0). The \s-1CRLF\s0 is included in the returned scalar. .IP "\(bu" 4 ssl_read_until .Sp uses \f(CW\*(C`ssl_read_all()\*(C'\fR to read from the \s-1SSL\s0 input stream until it encounters a programmer specified delimiter. If the delimiter is undefined, \f(CW$/\fR is used. If \f(CW$/\fR is undefined, \&\f(CW\*(C`\en\*(C'\fR is used. One can optionally set a maximum length of bytes to read from the \s-1SSL\s0 input stream. .IP "\(bu" 4 ssl_write_CRLF .Sp writes \f(CW$message\fR and appends \s-1CRLF\s0 to the \s-1SSL\s0 output stream. .SS "Initialization" .IX Subsection "Initialization" In order to use the low level \s-1API\s0 you should start your programs with the following incantation: .PP .Vb 6 \& use Net::SSLeay qw(die_now die_if_ssl_error); \& Net::SSLeay::load_error_strings(); \& Net::SSLeay::SSLeay_add_ssl_algorithms(); # Important! \& Net::SSLeay::ENGINE_load_builtin_engines(); # If you want built\-in engines \& Net::SSLeay::ENGINE_register_all_complete(); # If you want built\-in engines \& Net::SSLeay::randomize(); .Ve .SS "Error handling functions" .IX Subsection "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. .IP "\(bu" 4 die_now .IP "\(bu" 4 die_if_ssl_error .Sp \&\f(CW\*(C`die_now()\*(C'\fR and \f(CW\*(C`die_if_ssl_error()\*(C'\fR are used to conveniently print the SSLeay error stack when something goes wrong: .Sp .Vb 1 \& Net::SSLeay::connect($ssl) or die_now("Failed SSL connect ($!)"); \& \& \& Net::SSLeay::write($ssl, "foo") or die_if_ssl_error("SSL write ($!)"); .Ve .IP "\(bu" 4 print_errs .Sp You can also use \f(CW\*(C`Net::SSLeay::print_errs()\*(C'\fR 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. .SS "Sockets" .IX Subsection "Sockets" Perl uses file handles for all I/O. While SSLeay has a quite flexible \s-1BIO\s0 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 \f(CW\*(C`fileno()\*(C'\fR to extract the underlying file descriptor: .PP .Vb 1 \& Net::SSLeay::set_fd($ssl, fileno(S)); # Must use fileno .Ve .PP You should also set \f(CW$|\fR to 1 to eliminate \s-1STDIO\s0 buffering so you do not get confused if you use perl I/O functions to manipulate your socket handle. .PP If you need to \f(CWselect(2)\fR 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). \f(CW\*(C`Net::SSLeay\*(C'\fR is no different from the C language OpenSSL in this respect. .SS "Callbacks" .IX Subsection "Callbacks" You can establish a per-context verify callback function something like this: .PP .Vb 6 \& sub verify { \& my ($ok, $x509_store_ctx) = @_; \& print "Verifying certificate...\en"; \& ... \& return $ok; \& } .Ve .PP It is used like this: .PP .Vb 1 \& Net::SSLeay::set_verify ($ssl, Net::SSLeay::VERIFY_PEER, \e&verify); .Ve .PP Per-context callbacks for decrypting private keys are implemented. .PP .Vb 5 \& 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); .Ve .PP 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. .PP Establish it like this: Net::SSLeay::set_session_secret_cb($ssl, \e&session_secret_cb, \f(CW$somedata\fR); .PP It will be called like this: .PP .Vb 4 \& sub session_secret_cb \& { \& my ($secret, \e@cipherlist, \e$preferredcipher, $somedata) = @_; \& } .Ve .PP 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. .PP 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. .PP If you want to use callback stuff, see examples/callback.pl! It's the only one I am able to make work reliably. .SS "Low level \s-1API\s0" .IX Subsection "Low level API" In addition to the high level functions outlined above, this module contains straight-forward access to \s-1CRYPTO\s0 and \s-1SSL\s0 parts of OpenSSL C \s-1API.\s0 .PP See the \f(CW\*(C`*.h\*(C'\fR 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 \f(CW"SSL_"\fR off of the SSLeay names. Generally you should use \f(CW\*(C`Net::SSLeay::\*(C'\fR in its place. .PP Note that some functions are prefixed with \f(CW"P_"\fR \- these are very close to the original \s-1API\s0 however contain some kind of a wrapper making its interface more perl friendly. .PP For example: .PP In C: .PP .Vb 1 \& #include \& \& err = SSL_set_verify (ssl, SSL_VERIFY_CLIENT_ONCE, \& &your_call_back_here); .Ve .PP In Perl: .PP .Vb 1 \& use Net::SSLeay; \& \& $err = Net::SSLeay::set_verify ($ssl, \& Net::SSLeay::VERIFY_CLIENT_ONCE, \& \e&your_call_back_here); .Ve .PP If the function does not start with \f(CW\*(C`SSL_\*(C'\fR you should use the full function name, e.g.: .PP .Vb 1 \& $err = Net::SSLeay::ERR_get_error; .Ve .PP The following new functions behave in perlish way: .PP .Vb 4 \& $got = Net::SSLeay::read($ssl); \& # Performs SSL_read, but returns $got \& # resized according to data received. \& # Returns undef on failure. \& \& Net::SSLeay::write($ssl, $foo) || die; \& # Performs SSL_write, but automatically \& # figures out the size of $foo .Ve .PP \fILow level \s-1API:\s0 Version related functions\fR .IX Subsection "Low level API: Version related functions" .IP "\(bu" 4 SSLeay .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.42 and before .Sp Gives version number (numeric) of underlaying openssl library. .Sp .Vb 10 \& my $ver_number = Net::SSLeay::SSLeay(); \& # returns: the number identifying the openssl release \& # \& # 0x00903100 => openssl\-0.9.3 \& # 0x00904100 => openssl\-0.9.4 \& # 0x00905100 => openssl\-0.9.5 \& # 0x0090600f => openssl\-0.9.6 \& # 0x0090601f => openssl\-0.9.6a \& # 0x0090602f => openssl\-0.9.6b \& # ... \& # 0x009060df => openssl\-0.9.6m \& # 0x0090700f => openssl\-0.9.7 \& # 0x0090701f => openssl\-0.9.7a \& # 0x0090702f => openssl\-0.9.7b \& # ... \& # 0x009070df => openssl\-0.9.7m \& # 0x0090800f => openssl\-0.9.8 \& # 0x0090801f => openssl\-0.9.8a \& # 0x0090802f => openssl\-0.9.8b \& # ... \& # 0x0090814f => openssl\-0.9.8t \& # 0x1000000f => openssl\-1.0.0 \& # 0x1000004f => openssl\-1.0.0d \& # 0x1000007f => openssl\-1.0.0g .Ve .Sp You can use it like this: .Sp .Vb 3 \& if (Net::SSLeay::SSLeay() < 0x0090800f) { \& die "you need openssl\-0.9.8 or higher"; \& } .Ve .IP "\(bu" 4 SSLeay_version .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.42 and before .Sp Gives version number (string) of underlaying openssl library. .Sp .Vb 8 \& my $ver_string = Net::SSLeay::SSLeay_version($type); \& # $type \& # 0 (=SSLEAY_VERSION) \- e.g. \*(AqOpenSSL 1.0.0d 8 Feb 2011\*(Aq \& # 2 (=SSLEAY_CFLAGS) \- e.g. \*(Aqcompiler: gcc \-D_WINDLL \-DOPENSSL_USE_APPLINK .....\*(Aq \& # 3 (=SSLEAY_BUILT_ON)\- e.g. \*(Aqbuilt on: Fri May 6 00:00:46 GMT 2011\*(Aq \& # 4 (=SSLEAY_PLATFORM)\- e.g. \*(Aqplatform: mingw\*(Aq \& # \& # returns: string \& \& Net::SSLeay::SSLeay_version(); \& #is equivalent to \& Net::SSLeay::SSLeay_version(0); .Ve .Sp Check openssl doc .PP \fILow level \s-1API:\s0 Initialization related functions\fR .IX Subsection "Low level API: Initialization related functions" .IP "\(bu" 4 library_init .Sp Initialize \s-1SSL\s0 library by registering algorithms. .Sp .Vb 1 \& my $rv = Net::SSLeay::library_init(); .Ve .Sp Check openssl doc .Sp 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. .IP "\(bu" 4 add_ssl_algorithms .Sp The alias for \*(L"library_init\*(R" .Sp .Vb 1 \& Net::SSLeay::add_ssl_algorithms(); .Ve .IP "\(bu" 4 OpenSSL_add_ssl_algorithms .Sp The alias for \*(L"library_init\*(R" .Sp .Vb 1 \& Net::SSLeay::OpenSSL_add_ssl_algorithms(); .Ve .IP "\(bu" 4 SSLeay_add_ssl_algorithms .Sp The alias for \*(L"library_init\*(R" .Sp .Vb 1 \& Net::SSLeay::SSLeay_add_ssl_algorithms(); .Ve .IP "\(bu" 4 load_error_strings .Sp Registers the error strings for all libcrypto + libssl related functions. .Sp .Vb 3 \& Net::SSLeay::load_error_strings(); \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 ERR_load_crypto_strings .Sp Registers the error strings for all libcrypto functions. No need to call this function if you have already called \*(L"load_error_strings\*(R". .Sp .Vb 3 \& Net::SSLeay::ERR_load_crypto_strings(); \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 ERR_load_RAND_strings .Sp Registers the error strings for \s-1RAND\s0 related functions. No need to call this function if you have already called \*(L"load_error_strings\*(R". .Sp .Vb 3 \& Net::SSLeay::ERR_load_RAND_strings(); \& # \& # returns: no return value .Ve .IP "\(bu" 4 ERR_load_SSL_strings .Sp Registers the error strings for \s-1SSL\s0 related functions. No need to call this function if you have already called \*(L"load_error_strings\*(R". .Sp .Vb 3 \& Net::SSLeay::ERR_load_SSL_strings(); \& # \& # returns: no return value .Ve .IP "\(bu" 4 OpenSSL_add_all_algorithms .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Add algorithms to internal table. .Sp .Vb 3 \& Net::SSLeay::OpenSSL_add_all_algorithms(); \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 OPENSSL_add_all_algorithms_conf .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Similar to \*(L"OpenSSL_add_all_algorithms\*(R" \- will \s-1ALWAYS\s0 load the config file .Sp .Vb 3 \& Net::SSLeay::OPENSSL_add_all_algorithms_conf(); \& # \& # returns: no return value .Ve .IP "\(bu" 4 OPENSSL_add_all_algorithms_noconf .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Similar to \*(L"OpenSSL_add_all_algorithms\*(R" \- will \s-1NEVER\s0 load the config file .Sp .Vb 3 \& Net::SSLeay::OPENSSL_add_all_algorithms_noconf(); \& # \& # returns: no return value .Ve .PP \fILow level \s-1API:\s0 ERR_* and SSL_alert_* related functions\fR .IX Subsection "Low level API: ERR_* and SSL_alert_* related functions" .PP \&\fB\s-1NOTE:\s0\fR Please note that SSL_alert_* function have \*(L"\s-1SSL_\*(R"\s0 part stripped from their names. .IP "\(bu" 4 ERR_clear_error .Sp Clear the error queue. .Sp .Vb 3 \& Net::SSLeay::ERR_clear_error(); \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 ERR_error_string .Sp Generates a human-readable string representing the error code \f(CW$error\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::ERR_error_string($error); \& # $error \- (unsigned integer) error code \& # \& # returns: string .Ve .Sp Check openssl doc .IP "\(bu" 4 ERR_get_error .Sp 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. .Sp .Vb 3 \& my $rv = Net::SSLeay::ERR_get_error(); \& # \& # returns: (unsigned integer) error code .Ve .Sp Check openssl doc .IP "\(bu" 4 ERR_peek_error .Sp Returns the earliest error code from the thread's error queue without modifying it. .Sp .Vb 3 \& my $rv = Net::SSLeay::ERR_peek_error(); \& # \& # returns: (unsigned integer) error code .Ve .Sp Check openssl doc .IP "\(bu" 4 ERR_put_error .Sp Adds an error code to the thread's error queue. It signals that the error of \f(CW$reason\fR code reason occurred in function \f(CW$func\fR of library \f(CW$lib\fR, in line number \f(CW$line\fR of \f(CW$file\fR. .Sp .Vb 8 \& Net::SSLeay::ERR_put_error($lib, $func, $reason, $file, $line); \& # $lib \- (integer) library id (check openssl/err.h for constants e.g. ERR_LIB_SSL) \& # $func \- (integer) function id (check openssl/ssl.h for constants e.g. SSL_F_SSL23_READ) \& # $reason \- (integer) reason id (check openssl/ssl.h for constants e.g. SSL_R_SSL_HANDSHAKE_FAILURE) \& # $file \- (string) file name \& # $line \- (integer) line number in $file \& # \& # returns: no return value .Ve .Sp Check openssl doc and .IP "\(bu" 4 alert_desc_string .Sp Returns a two letter string as a short form describing the reason of the alert specified by value. .Sp .Vb 4 \& my $rv = Net::SSLeay::alert_desc_string($value); \& # $value \- (integer) allert id (check openssl/ssl.h for SSL3_AD_* and TLS1_AD_* constants) \& # \& # returns: description string (2 letters) .Ve .Sp Check openssl doc .IP "\(bu" 4 alert_desc_string_long .Sp Returns a string describing the reason of the alert specified by value. .Sp .Vb 4 \& my $rv = Net::SSLeay::alert_desc_string_long($value); \& # $value \- (integer) allert id (check openssl/ssl.h for SSL3_AD_* and TLS1_AD_* constants) \& # \& # returns: description string .Ve .Sp Check openssl doc .IP "\(bu" 4 alert_type_string .Sp Returns a one letter string indicating the type of the alert specified by value. .Sp .Vb 4 \& my $rv = Net::SSLeay::alert_type_string($value); \& # $value \- (integer) allert id (check openssl/ssl.h for SSL3_AD_* and TLS1_AD_* constants) \& # \& # returns: string (1 letter) .Ve .Sp Check openssl doc .IP "\(bu" 4 alert_type_string_long .Sp Returns a string indicating the type of the alert specified by value. .Sp .Vb 4 \& my $rv = Net::SSLeay::alert_type_string_long($value); \& # $value \- (integer) allert id (check openssl/ssl.h for SSL3_AD_* and TLS1_AD_* constants) \& # \& # returns: string .Ve .Sp Check openssl doc .PP \fILow level \s-1API:\s0 SSL_METHOD_* related functions\fR .IX Subsection "Low level API: SSL_METHOD_* related functions" .IP "\(bu" 4 SSLv2_method .Sp Returns \s-1SSL_METHOD\s0 structure corresponding to SSLv2 method, the return value can be later used as a param of \*(L"CTX_new_with_method\*(R". Only available where supported by the underlying openssl. .Sp .Vb 3 \& my $rv = Net::SSLeay::SSLv2_method(); \& # \& # returns: value corresponding to openssl\*(Aqs SSL_METHOD structure (0 on failure) .Ve .IP "\(bu" 4 SSLv3_method .Sp Returns \s-1SSL_METHOD\s0 structure corresponding to SSLv3 method, the return value can be later used as a param of \*(L"CTX_new_with_method\*(R". .Sp .Vb 3 \& my $rv = Net::SSLeay::SSLv3_method(); \& # \& # returns: value corresponding to openssl\*(Aqs SSL_METHOD structure (0 on failure) .Ve .Sp Check openssl doc .IP "\(bu" 4 TLSv1_method .Sp Returns \s-1SSL_METHOD\s0 structure corresponding to TLSv1 method, the return value can be later used as a param of \*(L"CTX_new_with_method\*(R". .Sp .Vb 3 \& my $rv = Net::SSLeay::TLSv1_method(); \& # \& # returns: value corresponding to openssl\*(Aqs SSL_METHOD structure (0 on failure) .Ve .Sp Check openssl doc .IP "\(bu" 4 TLSv1_1_method .Sp Returns \s-1SSL_METHOD\s0 structure corresponding to TLSv1_1 method, the return value can be later used as a param of \*(L"CTX_new_with_method\*(R". Only available where supported by the underlying openssl. .Sp .Vb 3 \& my $rv = Net::SSLeay::TLSv1_\|_1method(); \& # \& # returns: value corresponding to openssl\*(Aqs SSL_METHOD structure (0 on failure) .Ve .Sp Check openssl doc .IP "\(bu" 4 TLSv1_2_method .Sp Returns \s-1SSL_METHOD\s0 structure corresponding to TLSv1_2 method, the return value can be later used as a param of \*(L"CTX_new_with_method\*(R". Only available where supported by the underlying openssl. .Sp .Vb 3 \& my $rv = Net::SSLeay::TLSv1_2_method(); \& # \& # returns: value corresponding to openssl\*(Aqs SSL_METHOD structure (0 on failure) .Ve .Sp Check openssl doc .PP \fILow level \s-1API:\s0 ENGINE_* related functions\fR .IX Subsection "Low level API: ENGINE_* related functions" .IP "\(bu" 4 ENGINE_load_builtin_engines .Sp Load all bundled ENGINEs into memory and make them visible. .Sp .Vb 3 \& Net::SSLeay::ENGINE_load_builtin_engines(); \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 ENGINE_register_all_complete .Sp Register all loaded ENGINEs for every algorithm they collectively implement. .Sp .Vb 3 \& Net::SSLeay::ENGINE_register_all_complete(); \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 ENGINE_set_default .Sp Set default engine to \f(CW$e\fR + set its flags to \f(CW$flags\fR. .Sp .Vb 10 \& my $rv = Net::SSLeay::ENGINE_set_default($e, $flags); \& # $e \- value corresponding to openssl\*(Aqs ENGINE structure \& # $flags \- (integer) engine flags \& # flags value can be made by bitwise "OR"ing: \& # 0x0001 \- ENGINE_METHOD_RSA \& # 0x0002 \- ENGINE_METHOD_DSA \& # 0x0004 \- ENGINE_METHOD_DH \& # 0x0008 \- ENGINE_METHOD_RAND \& # 0x0010 \- ENGINE_METHOD_ECDH \& # 0x0020 \- ENGINE_METHOD_ECDSA \& # 0x0040 \- ENGINE_METHOD_CIPHERS \& # 0x0080 \- ENGINE_METHOD_DIGESTS \& # 0x0100 \- ENGINE_METHOD_STORE \& # 0x0200 \- ENGINE_METHOD_PKEY_METHS \& # 0x0400 \- ENGINE_METHOD_PKEY_ASN1_METHS \& # Obvious all\-or\-nothing cases: \& # 0xFFFF \- ENGINE_METHOD_ALL \& # 0x0000 \- ENGINE_METHOD_NONE \& # \& # returns: 1 on success, 0 on failure .Ve .Sp Check openssl doc .IP "\(bu" 4 ENGINE_by_id .Sp Get \s-1ENGINE\s0 by its identification \f(CW$id\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::ENGINE_by_id($id); \& # $id \- (string) engine identification e.g. "dynamic" \& # \& # returns: value corresponding to openssl\*(Aqs ENGINE structure (0 on failure) .Ve .Sp Check openssl doc .PP \fILow level \s-1API:\s0 EVP_PKEY_* related functions\fR .IX Subsection "Low level API: EVP_PKEY_* related functions" .IP "\(bu" 4 EVP_PKEY_copy_parameters .Sp Copies the parameters from key \f(CW$from\fR to key \f(CW$to\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::EVP_PKEY_copy_parameters($to, $from); \& # $to \- value corresponding to openssl\*(Aqs EVP_PKEY structure \& # $from \- value corresponding to openssl\*(Aqs EVP_PKEY structure \& # \& # returns: 1 on success, 0 on failure .Ve .Sp Check openssl doc .IP "\(bu" 4 EVP_PKEY_new .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Creates a new \s-1EVP_PKEY\s0 structure. .Sp .Vb 3 \& my $rv = Net::SSLeay::EVP_PKEY_new(); \& # \& # returns: value corresponding to openssl\*(Aqs EVP_PKEY structure (0 on failure) .Ve .Sp Check openssl doc .IP "\(bu" 4 EVP_PKEY_free .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Free an allocated \s-1EVP_PKEY\s0 structure. .Sp .Vb 4 \& Net::SSLeay::EVP_PKEY_free($pkey); \& # $pkey \- value corresponding to openssl\*(Aqs EVP_PKEY structure \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 EVP_PKEY_assign_RSA .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Set the key referenced by \f(CW$pkey\fR to \f(CW$key\fR .Sp \&\fB\s-1NOTE:\s0\fR No reference counter will be increased, i.e. \f(CW$key\fR will be freed if \&\f(CW$pkey\fR is freed. .Sp .Vb 5 \& my $rv = Net::SSLeay::EVP_PKEY_assign_RSA($pkey, $key); \& # $pkey \- value corresponding to openssl\*(Aqs EVP_PKEY structure \& # $key \- value corresponding to openssl\*(Aqs RSA structure \& # \& # returns: 1 on success, 0 on failure .Ve .Sp Check openssl doc .IP "\(bu" 4 EVP_PKEY_assign_EC_KEY .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.74 and before .Sp Set the key referenced by \f(CW$pkey\fR to \f(CW$key\fR .Sp \&\fB\s-1NOTE:\s0\fR No reference counter will be increased, i.e. \f(CW$key\fR will be freed if \&\f(CW$pkey\fR is freed. .Sp .Vb 5 \& my $rv = Net::SSLeay::EVP_PKEY_assign_EC_KEY($pkey, $key); \& # $pkey \- value corresponding to openssl\*(Aqs EVP_PKEY structure \& # $key \- value corresponding to openssl\*(Aqs EC_KEY structure \& # \& # returns: 1 on success, 0 on failure .Ve .Sp Check openssl doc .IP "\(bu" 4 EVP_PKEY_bits .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Returns the size of the key \f(CW$pkey\fR in bits. .Sp .Vb 4 \& my $rv = Net::SSLeay::EVP_PKEY_bits($pkey); \& # $pkey \- value corresponding to openssl\*(Aqs EVP_PKEY structure \& # \& # returns: size in bits .Ve .IP "\(bu" 4 EVP_PKEY_size .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Returns the maximum size of a signature in bytes. The actual signature may be smaller. .Sp .Vb 4 \& my $rv = Net::SSLeay::EVP_PKEY_size($pkey); \& # $pkey \- value corresponding to openssl\*(Aqs EVP_PKEY structure \& # \& # returns: the maximum size in bytes .Ve .Sp Check openssl doc .IP "\(bu" 4 EVP_PKEY_id .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before; requires at least openssl\-1.0.0 .Sp Returns \f(CW$pkey\fR type (integer value of corresponding \s-1NID\s0). .Sp .Vb 4 \& my $rv = Net::SSLeay::EVP_PKEY_id($pkey); \& # $pkey \- value corresponding to openssl\*(Aqs EVP_PKEY structure \& # \& # returns: (integer) key type .Ve .Sp Example: .Sp .Vb 3 \& my $pubkey = Net::SSLeay::X509_get_pubkey($x509); \& my $type = Net::SSLeay::EVP_PKEY_id($pubkey); \& print Net::SSLeay::OBJ_nid2sn($type); #prints e.g. \*(AqrsaEncryption\*(Aq .Ve .PP \fILow level \s-1API:\s0 PEM_* related functions\fR .IX Subsection "Low level API: PEM_* related functions" .PP Check openssl doc .IP "\(bu" 4 PEM_read_bio_X509 .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Loads \s-1PEM\s0 formatted X509 certificate via given \s-1BIO\s0 structure. .Sp .Vb 4 \& my $rv = Net::SSLeay::PEM_read_bio_X509($bio); \& # $bio \- value corresponding to openssl\*(Aqs BIO structure \& # \& # returns: value corresponding to openssl\*(Aqs X509 structure (0 on failure) .Ve .Sp Example: .Sp .Vb 3 \& my $bio = Net::SSLeay::BIO_new_file($filename, \*(Aqr\*(Aq); \& my $x509 = Net::SSLeay::PEM_read_bio_X509($bio); \& Net::SSLeay::BIO_free($bio); .Ve .IP "\(bu" 4 PEM_read_bio_X509_REQ .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Loads \s-1PEM\s0 formatted X509_REQ object via given \s-1BIO\s0 structure. .Sp .Vb 4 \& my $rv = Net::SSLeay::PEM_read_bio_X509_REQ($bio, $x=NULL, $cb=NULL, $u=NULL); \& # $bio \- value corresponding to openssl\*(Aqs BIO structure \& # \& # returns: value corresponding to openssl\*(Aqs X509_REQ structure (0 on failure) .Ve .Sp Example: .Sp .Vb 3 \& my $bio = Net::SSLeay::BIO_new_file($filename, \*(Aqr\*(Aq); \& my $x509_req = Net::SSLeay::PEM_read_bio_X509_REQ($bio); \& Net::SSLeay::BIO_free($bio); .Ve .IP "\(bu" 4 PEM_read_bio_DHparams .Sp Reads \s-1DH\s0 structure from \s-1BIO.\s0 .Sp .Vb 4 \& my $rv = Net::SSLeay::PEM_read_bio_DHparams($bio); \& # $bio \- value corresponding to openssl\*(Aqs BIO structure \& # \& # returns: value corresponding to openssl\*(Aqs DH structure (0 on failure) .Ve .IP "\(bu" 4 PEM_read_bio_X509_CRL .Sp Reads X509_CRL structure from \s-1BIO.\s0 .Sp .Vb 4 \& my $rv = Net::SSLeay::PEM_read_bio_X509_CRL($bio); \& # $bio \- value corresponding to openssl\*(Aqs BIO structure \& # \& # returns: value corresponding to openssl\*(Aqs X509_CRL structure (0 on failure) .Ve .IP "\(bu" 4 PEM_read_bio_PrivateKey .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Loads \s-1PEM\s0 formatted private key via given \s-1BIO\s0 structure. .Sp .Vb 6 \& my $rv = Net::SSLeay::PEM_read_bio_PrivateKey($bio, $cb, $data); \& # $bio \- value corresponding to openssl\*(Aqs BIO structure \& # $cb \- reference to perl callback function \& # $data \- data that will be passed to callback function (see examples below) \& # \& # returns: value corresponding to openssl\*(Aqs EVP_PKEY structure (0 on failure) .Ve .Sp Example: .Sp .Vb 3 \& my $bio = Net::SSLeay::BIO_new_file($filename, \*(Aqr\*(Aq); \& my $privkey = Net::SSLeay::PEM_read_bio_PrivateKey($bio); #ask for password if needed \& Net::SSLeay::BIO_free($bio); .Ve .Sp To use password you have the following options: .Sp .Vb 4 \& $privkey = Net::SSLeay::PEM_read_bio_PrivateKey($bio, \e&callback_func); # use callback func for getting password \& $privkey = Net::SSLeay::PEM_read_bio_PrivateKey($bio, \e&callback_func, $data); # use callback_func + pass $data to callback_func \& $privkey = Net::SSLeay::PEM_read_bio_PrivateKey($bio, undef, "secret"); # use password "secret" \& $privkey = Net::SSLeay::PEM_read_bio_PrivateKey($bio, undef, ""); # use empty password .Ve .Sp Callback function signature: .Sp .Vb 5 \& sub callback_func { \& my ($max_passwd_size, $rwflag, $data) = @_; \& # $max_passwd_size \- maximum size of returned password (longer values will be discarded) \& # $rwflag \- indicates whether we are loading (0) or storing (1) \- for PEM_read_bio_PrivateKey always 0 \& # $data \- the data passed to PEM_read_bio_PrivateKey as 3rd parameter \& \& return "secret"; \& } .Ve .IP "\(bu" 4 PEM_get_string_X509 .Sp \&\fB\s-1NOTE:\s0\fR Does not exactly correspond to any low level \s-1API\s0 function .Sp Converts/exports X509 certificate to string (\s-1PEM\s0 format). .Sp .Vb 4 \& Net::SSLeay::PEM_get_string_X509($x509); \& # $x509 \- value corresponding to openssl\*(Aqs X509 structure \& # \& # returns: string with $x509 in PEM format .Ve .IP "\(bu" 4 PEM_get_string_PrivateKey .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Converts public key \f(CW$pk\fR into \s-1PEM\s0 formatted string (optionally protected with password). .Sp .Vb 6 \& my $rv = Net::SSLeay::PEM_get_string_PrivateKey($pk, $passwd, $enc_alg); \& # $pk \- value corresponding to openssl\*(Aqs EVP_PKEY structure \& # $passwd \- [optional] (string) password to use for key encryption \& # $enc_alg \- [optional] algorithm to use for key encryption (default: DES_CBC) \- value corresponding to openssl\*(Aqs EVP_CIPHER structure \& # \& # returns: PEM formatted string .Ve .Sp Examples: .Sp .Vb 3 \& $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")); .Ve .IP "\(bu" 4 PEM_get_string_X509_CRL .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Converts X509_CRL object \f(CW$x509_crl\fR into \s-1PEM\s0 formatted string. .Sp .Vb 4 \& Net::SSLeay::PEM_get_string_X509_CRL($x509_crl); \& # $x509_crl \- value corresponding to openssl\*(Aqs X509_CRL structure \& # \& # returns: no return value .Ve .IP "\(bu" 4 PEM_get_string_X509_REQ .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Converts X509_REQ object \f(CW$x509_crl\fR into \s-1PEM\s0 formatted string. .Sp .Vb 4 \& Net::SSLeay::PEM_get_string_X509_REQ($x509_req); \& # $x509_req \- value corresponding to openssl\*(Aqs X509_REQ structure \& # \& # returns: no return value .Ve .PP \fILow level \s-1API:\s0 d2i_* (\s-1DER\s0 format) related functions\fR .IX Subsection "Low level API: d2i_* (DER format) related functions" .IP "\(bu" 4 d2i_X509_bio .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Loads \s-1DER\s0 formatted X509 certificate via given \s-1BIO\s0 structure. .Sp .Vb 4 \& my $rv = Net::SSLeay::d2i_X509_bio($bp); \& # $bp \- value corresponding to openssl\*(Aqs BIO structure \& # \& # returns: value corresponding to openssl\*(Aqs X509 structure (0 on failure) .Ve .Sp Example: .Sp .Vb 3 \& my $bio = Net::SSLeay::BIO_new_file($filename, \*(Aqrb\*(Aq); \& my $x509 = Net::SSLeay::d2i_X509_bio($bio); \& Net::SSLeay::BIO_free($bio); .Ve .Sp Check openssl doc .IP "\(bu" 4 d2i_X509_CRL_bio .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Loads \s-1DER\s0 formatted X509_CRL object via given \s-1BIO\s0 structure. .Sp .Vb 4 \& my $rv = Net::SSLeay::d2i_X509_CRL_bio($bp); \& # $bp \- value corresponding to openssl\*(Aqs BIO structure \& # \& # returns: value corresponding to openssl\*(Aqs X509_CRL structure (0 on failure) .Ve .Sp Example: .Sp .Vb 3 \& my $bio = Net::SSLeay::BIO_new_file($filename, \*(Aqrb\*(Aq); \& my $x509_crl = Net::SSLeay::d2i_X509_CRL_bio($bio); \& Net::SSLeay::BIO_free($bio); .Ve .IP "\(bu" 4 d2i_X509_REQ_bio .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Loads \s-1DER\s0 formatted X509_REQ object via given \s-1BIO\s0 structure. .Sp .Vb 4 \& my $rv = Net::SSLeay::d2i_X509_REQ_bio($bp); \& # $bp \- value corresponding to openssl\*(Aqs BIO structure \& # \& # returns: value corresponding to openssl\*(Aqs X509_REQ structure (0 on failure) .Ve .Sp Example: .Sp .Vb 3 \& my $bio = Net::SSLeay::BIO_new_file($filename, \*(Aqrb\*(Aq); \& my $x509_req = Net::SSLeay::d2i_X509_REQ_bio($bio); \& Net::SSLeay::BIO_free($bio); .Ve .PP \fILow level \s-1API: PKCS12\s0 related functions\fR .IX Subsection "Low level API: PKCS12 related functions" .IP "\(bu" 4 P_PKCS12_load_file .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Loads X509 certificate + private key + certificates of \s-1CA\s0 chain (if present in \s-1PKCS12\s0 file). .Sp .Vb 9 \& my ($privkey, $cert, @cachain) = Net::SSLeay::P_PKCS12_load_file($filename, $load_chain, $password); \& # $filename \- name of PKCS12 file \& # $load_chain \- [optional] whether load (1) or not(0) CA chain (default: 0) \& # $password \- [optional] password for private key \& # \& # returns: triplet ($privkey, $cert, @cachain) \& # $privkey \- value corresponding to openssl\*(Aqs EVP_PKEY structure \& # $cert \- value corresponding to openssl\*(Aqs X509 structure \& # @cachain \- array of values corresponding to openssl\*(Aqs X509 structure (empty if no CA chain in PKCS12) .Ve .Sp \&\fB\s-1IMPORTANT NOTE:\s0\fR after you do the job you need to call \fIX509_free()\fR on \f(CW$privkey\fR + all members of \f(CW@cachain\fR and \fIEVP_PKEY_free()\fR on \f(CW$privkey\fR. .Sp Examples: .Sp .Vb 7 \& my ($privkey, $cert) = Net::SSLeay::P_PKCS12_load_file($filename); \& #or \& my ($privkey, $cert) = Net::SSLeay::P_PKCS12_load_file($filename, 0, $password); \& #or \& my ($privkey, $cert, @cachain) = Net::SSLeay::P_PKCS12_load_file($filename, 1); \& #or \& my ($privkey, $cert, @cachain) = Net::SSLeay::P_PKCS12_load_file($filename, 1, $password); \& \& #BEWARE: THIS IS WRONG \- MEMORY LEAKS! (you cannot free @cachain items) \& my ($privkey, $cert) = Net::SSLeay::P_PKCS12_load_file($filename, 1, $password); .Ve .Sp \&\fB\s-1NOTE\s0\fR With some combinations of Windows, perl, compiler and compiler options, you may see a runtime error \*(L"no OPENSSL_Applink\*(R", when calling Net::SSLeay::P_PKCS12_load_file. See \s-1README\s0.Win32 for more details. .PP \fILow level \s-1API:\s0 SESSION_* related functions\fR .IX Subsection "Low level API: SESSION_* related functions" .IP "\(bu" 4 d2i_SSL_SESSION .Sp Transforms the external \s-1ASN1\s0 representation of an \s-1SSL/TLS\s0 session, stored as binary data at location pp with length of \f(CW$length\fR, into an \s-1SSL_SESSION\s0 object. .Sp ??? (does this function really work?) .Sp .Vb 6 \& my $rv = Net::SSLeay::d2i_SSL_SESSION($a, $pp, $length); \& # $a \- value corresponding to openssl\*(Aqs SSL_SESSION structure \& # $pp \- pointer/buffer ??? \& # $length \- ??? \& # \& # returns: ??? .Ve .Sp Check openssl doc .IP "\(bu" 4 i2d_SSL_SESSION .Sp Transforms the \s-1SSL_SESSION\s0 object in into the \s-1ASN1\s0 representation and stores it into the memory location pointed to by pp. The length of the resulting \s-1ASN1\s0 representation is returned. .Sp ??? (does this function really work?) .Sp .Vb 5 \& my $rv = Net::SSLeay::i2d_SSL_SESSION($in, $pp); \& # $in \- value corresponding to openssl\*(Aqs SSL_SESSION structure \& # $pp \- pointer/data ??? \& # \& # returns: 1 on success, 0 .Ve .Sp Check openssl doc .IP "\(bu" 4 SESSION_new .Sp Creates a new \s-1SSL_SESSION\s0 structure. .Sp .Vb 3 \& my $rv = Net::SSLeay::SESSION_new(); \& # \& # returns: value corresponding to openssl\*(Aqs SSL_SESSION structure (0 on failure) .Ve .IP "\(bu" 4 SESSION_free .Sp Free an allocated \s-1SSL_SESSION\s0 structure. .Sp .Vb 4 \& Net::SSLeay::SESSION_free($ses); \& # $ses \- value corresponding to openssl\*(Aqs SSL_SESSION structure \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 SESSION_cmp .Sp Compare two \s-1SSL_SESSION\s0 structures. .Sp .Vb 5 \& my $rv = Net::SSLeay::SESSION_cmp($sesa, $sesb); \& # $sesa \- value corresponding to openssl\*(Aqs SSL_SESSION structure \& # $sesb \- value corresponding to openssl\*(Aqs SSL_SESSION structure \& # \& # returns: 0 if the two structures are the same .Ve .Sp \&\fB\s-1NOTE:\s0\fR Not available in openssl 1.0 or later .IP "\(bu" 4 SESSION_get_app_data .Sp Can be used to get application defined value/data. .Sp .Vb 4 \& my $rv = Net::SSLeay::SESSION_get_app_data($ses); \& # $ses \- value corresponding to openssl\*(Aqs SSL_SESSION structure \& # \& # returns: string/buffer/pointer ??? .Ve .IP "\(bu" 4 SESSION_set_app_data .Sp Can be used to set some application defined value/data. .Sp .Vb 5 \& my $rv = Net::SSLeay::SESSION_set_app_data($s, $a); \& # $s \- value corresponding to openssl\*(Aqs SSL_SESSION structure \& # $a \- (string/buffer/pointer ???) data \& # \& # returns: ??? .Ve .IP "\(bu" 4 SESSION_get_ex_data .Sp Is used to retrieve the information for \f(CW$idx\fR from session \f(CW$ses\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::SESSION_get_ex_data($ses, $idx); \& # $ses \- value corresponding to openssl\*(Aqs SSL_SESSION structure \& # $idx \- (integer) index for application specific data \& # \& # returns: pointer to ??? .Ve .Sp Check openssl doc .IP "\(bu" 4 SESSION_set_ex_data .Sp Is used to store application data at arg for idx into the session object. .Sp .Vb 6 \& my $rv = Net::SSLeay::SESSION_set_ex_data($ss, $idx, $data); \& # $ss \- value corresponding to openssl\*(Aqs SSL_SESSION structure \& # $idx \- (integer) ??? \& # $data \- (pointer) ??? \& # \& # returns: 1 on success, 0 on failure .Ve .Sp Check openssl doc .IP "\(bu" 4 SESSION_get_ex_new_index .Sp Is used to register a new index for application specific data. .Sp .Vb 8 \& my $rv = Net::SSLeay::SESSION_get_ex_new_index($argl, $argp, $new_func, $dup_func, $free_func); \& # $argl \- (long) ??? \& # $argp \- (pointer) ??? \& # $new_func \- function pointer ??? (CRYPTO_EX_new *) \& # $dup_func \- function pointer ??? (CRYPTO_EX_dup *) \& # $free_func \- function pointer ??? (CRYPTO_EX_free *) \& # \& # returns: (integer) ??? .Ve .Sp Check openssl doc .IP "\(bu" 4 SESSION_get_master_key .Sp \&\fB\s-1NOTE:\s0\fR Does not exactly correspond to any low level \s-1API\s0 function .Sp Returns 'master_key' value from \s-1SSL_SESSION\s0 structure \f(CW$s\fR .Sp .Vb 4 \& Net::SSLeay::SESSION_get_master_key($s); \& # $s \- value corresponding to openssl\*(Aqs SSL_SESSION structure \& # \& # returns: master key (binary data) .Ve .IP "\(bu" 4 SESSION_set_master_key .Sp Sets 'master_key' value for \s-1SSL_SESSION\s0 structure \f(CW$s\fR .Sp .Vb 5 \& Net::SSLeay::SESSION_set_master_key($s, $key); \& # $s \- value corresponding to openssl\*(Aqs SSL_SESSION structure \& # $key \- master key (binary data) \& # \& # returns: no return value .Ve .Sp Not available with OpenSSL 1.1 and later. Code that previously used SESSION_set_master_key must now set \f(CW$secret\fR in the session_secret callback set with SSL_set_session_secret_cb. .IP "\(bu" 4 SESSION_get_time .Sp Returns the time at which the session s was established. The time is given in seconds since 1.1.1970. .Sp .Vb 4 \& my $rv = Net::SSLeay::SESSION_get_time($s); \& # $s \- value corresponding to openssl\*(Aqs SSL_SESSION structure \& # \& # returns: timestamp (seconds since 1.1.1970) .Ve .Sp Check openssl doc .IP "\(bu" 4 get_time .Sp Technically the same functionality as \*(L"SESSION_get_time\*(R". .Sp .Vb 1 \& my $rv = Net::SSLeay::get_time($s); .Ve .IP "\(bu" 4 SESSION_get_timeout .Sp Returns the timeout value set for session \f(CW$s\fR in seconds. .Sp .Vb 4 \& my $rv = Net::SSLeay::SESSION_get_timeout($s); \& # $s \- value corresponding to openssl\*(Aqs SSL_SESSION structure \& # \& # returns: timeout (in seconds) .Ve .Sp Check openssl doc .IP "\(bu" 4 get_timeout .Sp Technically the same functionality as \*(L"SESSION_get_timeout\*(R". .Sp .Vb 1 \& my $rv = Net::SSLeay::get_timeout($s); .Ve .IP "\(bu" 4 SESSION_print .Sp \&\fB\s-1NOTE:\s0\fR Does not exactly correspond to any low level \s-1API\s0 function .Sp Prints session details (e.g. protocol version, cipher, session-id ...) to \s-1BIO.\s0 .Sp .Vb 5 \& my $rv = Net::SSLeay::SESSION_print($fp, $ses); \& # $fp \- value corresponding to openssl\*(Aqs BIO structure \& # $ses \- value corresponding to openssl\*(Aqs SSL_SESSION structure \& # \& # returns: 1 on success, 0 on failure .Ve .Sp You have to use necessary \s-1BIO\s0 functions like this: .Sp .Vb 5 \& # let us have $ssl corresponding to openssl\*(Aqs SSL structure \& my $ses = Net::SSLeay::get_session($ssl); \& my $bio = Net::SSLeay::BIO_new(&Net::SSLeay::BIO_s_mem); \& Net::SSLeay::SESSION_print($bio, $ses); \& print Net::SSLeay::BIO_read($bio); .Ve .IP "\(bu" 4 SESSION_print_fp .Sp Prints session details (e.g. protocol version, cipher, session-id ...) to file handle. .Sp .Vb 5 \& my $rv = Net::SSLeay::SESSION_print_fp($fp, $ses); \& # $fp \- perl file handle \& # $ses \- value corresponding to openssl\*(Aqs SSL_SESSION structure \& # \& # returns: 1 on success, 0 on failure .Ve .Sp Example: .Sp .Vb 4 \& # let us have $ssl corresponding to openssl\*(Aqs SSL structure \& my $ses = Net::SSLeay::get_session($ssl); \& open my $fh, ">", "output.txt"; \& Net::SSLeay::SESSION_print_fp($fh,$ses); .Ve .IP "\(bu" 4 SESSION_set_time .Sp Replaces the creation time of the session s with the chosen value \f(CW$t\fR (seconds since 1.1.1970). .Sp .Vb 5 \& my $rv = Net::SSLeay::SESSION_set_time($ses, $t); \& # $ses \- value corresponding to openssl\*(Aqs SSL_SESSION structure \& # $t \- time value \& # \& # returns: 1 on success .Ve .Sp Check openssl doc .IP "\(bu" 4 set_time .Sp Technically the same functionality as \*(L"SESSION_set_time\*(R". .Sp .Vb 1 \& my $rv = Net::SSLeay::set_time($ses, $t); .Ve .IP "\(bu" 4 SESSION_set_timeout .Sp Sets the timeout value for session s in seconds to \f(CW$t\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::SESSION_set_timeout($s, $t); \& # $s \- value corresponding to openssl\*(Aqs SSL_SESSION structure \& # $t \- timeout (in seconds) \& # \& # returns: 1 on success .Ve .Sp Check openssl doc .IP "\(bu" 4 set_timeout .Sp Technically the same functionality as \*(L"SESSION_set_timeout\*(R". .Sp .Vb 1 \& my $rv = Net::SSLeay::set_timeout($ses, $t); .Ve .PP \fILow level \s-1API:\s0 SSL_CTX_* related functions\fR .IX Subsection "Low level API: SSL_CTX_* related functions" .PP \&\fB\s-1NOTE:\s0\fR Please note that the function described in this chapter have \*(L"\s-1SSL_\*(R"\s0 part stripped from their original openssl names. .IP "\(bu" 4 CTX_add_client_CA .Sp Adds the \s-1CA\s0 name extracted from \f(CW$cacert\fR to the list of CAs sent to the client when requesting a client certificate for \f(CW$ctx\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::CTX_add_client_CA($ctx, $cacert); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $cacert \- value corresponding to openssl\*(Aqs X509 structure \& # \& # returns: 1 on success, 0 on failure .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_add_extra_chain_cert .Sp Adds the certificate \f(CW$x509\fR to the certificate chain presented together with the certificate. Several certificates can be added one after the other. .Sp .Vb 5 \& my $rv = Net::SSLeay::CTX_add_extra_chain_cert($ctx, $x509); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $x509 \- value corresponding to openssl\*(Aqs X509 structure \& # \& # returns: 1 on success, check out the error stack to find out the reason for failure otherwise .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_add_session .Sp Adds the session \f(CW$ses\fR to the context \f(CW$ctx\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::CTX_add_session($ctx, $ses); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $ses \- value corresponding to openssl\*(Aqs SSL_SESSION structure \& # \& # returns: 1 on success, 0 on failure .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_callback_ctrl .Sp ??? (more info needed) .Sp .Vb 6 \& my $rv = Net::SSLeay::CTX_callback_ctrl($ctx, $cmd, $fp); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $cmd \- (integer) command id \& # $fp \- (function pointer) ??? \& # \& # returns: ??? .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_check_private_key .Sp Checks the consistency of a private key with the corresponding certificate loaded into \f(CW$ctx\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::CTX_check_private_key($ctx); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # \& # returns: 1 on success, otherwise check out the error stack to find out the reason .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_ctrl .Sp Internal handling function for \s-1SSL_CTX\s0 objects. .Sp \&\fB\s-1BEWARE:\s0\fR openssl doc says: This function should never be called directly! .Sp .Vb 7 \& my $rv = Net::SSLeay::CTX_ctrl($ctx, $cmd, $larg, $parg); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $cmd \- (integer) command id \& # $larg \- (integer) long ??? \& # $parg \- (string/pointer) ??? \& # \& # returns: (long) result of given command ??? \& \& #valid $cmd values \& 1 \- SSL_CTRL_NEED_TMP_RSA \& 2 \- SSL_CTRL_SET_TMP_RSA \& 3 \- SSL_CTRL_SET_TMP_DH \& 4 \- SSL_CTRL_SET_TMP_ECDH \& 5 \- SSL_CTRL_SET_TMP_RSA_CB \& 6 \- SSL_CTRL_SET_TMP_DH_CB \& 7 \- SSL_CTRL_SET_TMP_ECDH_CB \& 8 \- SSL_CTRL_GET_SESSION_REUSED \& 9 \- SSL_CTRL_GET_CLIENT_CERT_REQUEST \& 10 \- SSL_CTRL_GET_NUM_RENEGOTIATIONS \& 11 \- SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS \& 12 \- SSL_CTRL_GET_TOTAL_RENEGOTIATIONS \& 13 \- SSL_CTRL_GET_FLAGS \& 14 \- SSL_CTRL_EXTRA_CHAIN_CERT \& 15 \- SSL_CTRL_SET_MSG_CALLBACK \& 16 \- SSL_CTRL_SET_MSG_CALLBACK_ARG \& 17 \- SSL_CTRL_SET_MTU \& 20 \- SSL_CTRL_SESS_NUMBER \& 21 \- SSL_CTRL_SESS_CONNECT \& 22 \- SSL_CTRL_SESS_CONNECT_GOOD \& 23 \- SSL_CTRL_SESS_CONNECT_RENEGOTIATE \& 24 \- SSL_CTRL_SESS_ACCEPT \& 25 \- SSL_CTRL_SESS_ACCEPT_GOOD \& 26 \- SSL_CTRL_SESS_ACCEPT_RENEGOTIATE \& 27 \- SSL_CTRL_SESS_HIT \& 28 \- SSL_CTRL_SESS_CB_HIT \& 29 \- SSL_CTRL_SESS_MISSES \& 30 \- SSL_CTRL_SESS_TIMEOUTS \& 31 \- SSL_CTRL_SESS_CACHE_FULL \& 32 \- SSL_CTRL_OPTIONS \& 33 \- SSL_CTRL_MODE \& 40 \- SSL_CTRL_GET_READ_AHEAD \& 41 \- SSL_CTRL_SET_READ_AHEAD \& 42 \- SSL_CTRL_SET_SESS_CACHE_SIZE \& 43 \- SSL_CTRL_GET_SESS_CACHE_SIZE \& 44 \- SSL_CTRL_SET_SESS_CACHE_MODE \& 45 \- SSL_CTRL_GET_SESS_CACHE_MODE \& 50 \- SSL_CTRL_GET_MAX_CERT_LIST \& 51 \- SSL_CTRL_SET_MAX_CERT_LIST \& 52 \- SSL_CTRL_SET_MAX_SEND_FRAGMENT \& 53 \- SSL_CTRL_SET_TLSEXT_SERVERNAME_CB \& 54 \- SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG \& 55 \- SSL_CTRL_SET_TLSEXT_HOSTNAME \& 56 \- SSL_CTRL_SET_TLSEXT_DEBUG_CB \& 57 \- SSL_CTRL_SET_TLSEXT_DEBUG_ARG \& 58 \- SSL_CTRL_GET_TLSEXT_TICKET_KEYS \& 59 \- SSL_CTRL_SET_TLSEXT_TICKET_KEYS \& 60 \- SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT \& 61 \- SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB \& 62 \- SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB_ARG \& 63 \- SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB \& 64 \- SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG \& 65 \- SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE \& 66 \- SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS \& 67 \- SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS \& 68 \- SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS \& 69 \- SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS \& 70 \- SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP \& 71 \- SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP \& 72 \- SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB \& 73 \- DTLS_CTRL_GET_TIMEOUT \& 74 \- DTLS_CTRL_HANDLE_TIMEOUT \& 75 \- DTLS_CTRL_LISTEN \& 76 \- SSL_CTRL_GET_RI_SUPPORT \& 77 \- SSL_CTRL_CLEAR_OPTIONS \& 78 \- SSL_CTRL_CLEAR_MODE \& \& 82 \- SSL_CTRL_GET_EXTRA_CHAIN_CERTS \& 83 \- SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS \& \& 88 \- SSL_CTRL_CHAIN \& 89 \- SSL_CTRL_CHAIN_CERT \& \& 90 \- SSL_CTRL_GET_CURVES \& 91 \- SSL_CTRL_SET_CURVES \& 92 \- SSL_CTRL_SET_CURVES_LIST \& 93 \- SSL_CTRL_GET_SHARED_CURVE \& 94 \- SSL_CTRL_SET_ECDH_AUTO \& 97 \- SSL_CTRL_SET_SIGALGS \& 98 \- SSL_CTRL_SET_SIGALGS_LIST \& 99 \- SSL_CTRL_CERT_FLAGS \& 100 \- SSL_CTRL_CLEAR_CERT_FLAGS \& 101 \- SSL_CTRL_SET_CLIENT_SIGALGS \& 102 \- SSL_CTRL_SET_CLIENT_SIGALGS_LIST \& 103 \- SSL_CTRL_GET_CLIENT_CERT_TYPES \& 104 \- SSL_CTRL_SET_CLIENT_CERT_TYPES \& 105 \- SSL_CTRL_BUILD_CERT_CHAIN \& 106 \- SSL_CTRL_SET_VERIFY_CERT_STORE \& 107 \- SSL_CTRL_SET_CHAIN_CERT_STORE \& 108 \- SSL_CTRL_GET_PEER_SIGNATURE_NID \& 109 \- SSL_CTRL_GET_SERVER_TMP_KEY \& 110 \- SSL_CTRL_GET_RAW_CIPHERLIST \& 111 \- SSL_CTRL_GET_EC_POINT_FORMATS \& 112 \- SSL_CTRL_GET_TLSA_RECORD \& 113 \- SSL_CTRL_SET_TLSA_RECORD \& 114 \- SSL_CTRL_PULL_TLSA_RECORD .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_flush_sessions .Sp Causes a run through the session cache of \f(CW$ctx\fR to remove sessions expired at time \f(CW$tm\fR. .Sp .Vb 5 \& Net::SSLeay::CTX_flush_sessions($ctx, $tm); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $tm \- specifies the time which should be used for the expiration test (seconds since 1.1.1970) \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_free .Sp Free an allocated \s-1SSL_CTX\s0 object. .Sp .Vb 4 \& Net::SSLeay::CTX_free($ctx); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_get_app_data .Sp Can be used to get application defined value/data. .Sp .Vb 4 \& my $rv = Net::SSLeay::CTX_get_app_data($ctx); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # \& # returns: string/buffer/pointer ??? .Ve .IP "\(bu" 4 CTX_set_app_data .Sp Can be used to set some application defined value/data. .Sp .Vb 5 \& my $rv = Net::SSLeay::CTX_set_app_data($ctx, $arg); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $arg \- (string/buffer/pointer ???) data \& # \& # returns: ??? .Ve .IP "\(bu" 4 CTX_get_cert_store .Sp Returns the current certificate verification storage. .Sp .Vb 4 \& my $rv = Net::SSLeay::CTX_get_cert_store($ctx); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # \& # returns: value corresponding to openssl\*(Aqs X509_STORE structure (0 on failure) .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_get_client_CA_list .Sp Returns the list of client CAs explicitly set for \f(CW$ctx\fR using \*(L"CTX_set_client_CA_list\*(R". .Sp .Vb 4 \& my $rv = Net::SSLeay::CTX_get_client_CA_list($ctx); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # \& # returns: value corresponding to openssl\*(Aqs X509_NAME_STACK structure (0 on failure) .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_get_ex_data .Sp Is used to retrieve the information for index \f(CW$idx\fR from \f(CW$ctx\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::CTX_get_ex_data($ssl, $idx); \& # $ssl \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $idx \- (integer) index for application specific data \& # \& # returns: pointer to ??? .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_get_ex_new_index .Sp Is used to register a new index for application specific data. .Sp .Vb 8 \& my $rv = Net::SSLeay::CTX_get_ex_new_index($argl, $argp, $new_func, $dup_func, $free_func); \& # $argl \- (long) ??? \& # $argp \- (pointer) ??? \& # $new_func \- function pointer ??? (CRYPTO_EX_new *) \& # $dup_func \- function pointer ??? (CRYPTO_EX_dup *) \& # $free_func \- function pointer ??? (CRYPTO_EX_free *) \& # \& # returns: (integer) ??? .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_get_mode .Sp Returns the mode set for ctx. .Sp .Vb 4 \& my $rv = Net::SSLeay::CTX_get_mode($ctx); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # \& # returns: mode (bitmask) \& \& #to decode the return value (bitmask) use: \& 0x00000001 corresponds to SSL_MODE_ENABLE_PARTIAL_WRITE \& 0x00000002 corresponds to SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER \& 0x00000004 corresponds to SSL_MODE_AUTO_RETRY \& 0x00000008 corresponds to SSL_MODE_NO_AUTO_CHAIN \& 0x00000010 corresponds to SSL_MODE_RELEASE_BUFFERS \& (note: some of the bits might not be supported by older openssl versions) .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_set_mode .Sp Adds the mode set via bitmask in \f(CW$mode\fR to \f(CW$ctx\fR. Options already set before are not cleared. .Sp .Vb 5 \& my $rv = Net::SSLeay::CTX_set_mode($ctx, $mode); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $mode \- mode bitmask \& # \& # returns: the new mode bitmask after adding $mode .Ve .Sp For bitmask details see \*(L"CTX_get_mode\*(R" (above). .Sp Check openssl doc .IP "\(bu" 4 CTX_get_options .Sp Returns the options (bitmask) set for \f(CW$ctx\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::CTX_get_options($ctx); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # \& # returns: options (bitmask) \& \& #to decode the return value (bitmask) use: \& 0x00000001 corresponds to SSL_OP_MICROSOFT_SESS_ID_BUG \& 0x00000002 corresponds to SSL_OP_NETSCAPE_CHALLENGE_BUG \& 0x00000004 corresponds to SSL_OP_LEGACY_SERVER_CONNECT \& 0x00000008 corresponds to SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG \& 0x00000010 corresponds to SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG \& 0x00000020 corresponds to SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER \& 0x00000040 corresponds to SSL_OP_MSIE_SSLV2_RSA_PADDING \& 0x00000080 corresponds to SSL_OP_SSLEAY_080_CLIENT_DH_BUG \& 0x00000100 corresponds to SSL_OP_TLS_D5_BUG \& 0x00000200 corresponds to SSL_OP_TLS_BLOCK_PADDING_BUG \& 0x00000800 corresponds to SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS \& 0x80000FFF corresponds to SSL_OP_ALL \& 0x00001000 corresponds to SSL_OP_NO_QUERY_MTU \& 0x00002000 corresponds to SSL_OP_COOKIE_EXCHANGE \& 0x00004000 corresponds to SSL_OP_NO_TICKET \& 0x00008000 corresponds to SSL_OP_CISCO_ANYCONNECT \& 0x00010000 corresponds to SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION \& 0x00020000 corresponds to SSL_OP_NO_COMPRESSION \& 0x00040000 corresponds to SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION \& 0x00080000 corresponds to SSL_OP_SINGLE_ECDH_USE \& 0x00100000 corresponds to SSL_OP_SINGLE_DH_USE \& 0x00200000 corresponds to SSL_OP_EPHEMERAL_RSA \& 0x00400000 corresponds to SSL_OP_CIPHER_SERVER_PREFERENCE \& 0x00800000 corresponds to SSL_OP_TLS_ROLLBACK_BUG \& 0x01000000 corresponds to SSL_OP_NO_SSLv2 \& 0x02000000 corresponds to SSL_OP_NO_SSLv3 \& 0x04000000 corresponds to SSL_OP_NO_TLSv1 \& 0x08000000 corresponds to SSL_OP_PKCS1_CHECK_1 \& 0x10000000 corresponds to SSL_OP_PKCS1_CHECK_2 \& 0x20000000 corresponds to SSL_OP_NETSCAPE_CA_DN_BUG \& 0x40000000 corresponds to SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG \& 0x80000000 corresponds to SSL_OP_CRYPTOPRO_TLSEXT_BUG \& (note: some of the bits might not be supported by older openssl versions) .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_set_options .Sp Adds the options set via bitmask in \f(CW$options\fR to ctx. Options already set before are not cleared. .Sp .Vb 5 \& Net::SSLeay::CTX_set_options($ctx, $options); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $options \- options bitmask \& # \& # returns: the new options bitmask after adding $options .Ve .Sp For bitmask details see \*(L"CTX_get_options\*(R" (above). .Sp Check openssl doc .IP "\(bu" 4 CTX_get_quiet_shutdown .Sp Returns the 'quiet shutdown' setting of \f(CW$ctx\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::CTX_get_quiet_shutdown($ctx); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # \& # returns: (integer) the current setting .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_get_read_ahead .Sp .Vb 4 \& my $rv = Net::SSLeay::CTX_get_read_ahead($ctx); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # \& # returns: (integer) read_ahead value .Ve .IP "\(bu" 4 CTX_get_session_cache_mode .Sp Returns the currently used cache mode (bitmask). .Sp .Vb 4 \& my $rv = Net::SSLeay::CTX_get_session_cache_mode($ctx); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # \& # returns: mode (bitmask) \& \& #to decode the return value (bitmask) use: \& 0x0000 corresponds to SSL_SESS_CACHE_OFF \& 0x0001 corresponds to SSL_SESS_CACHE_CLIENT \& 0x0002 corresponds to SSL_SESS_CACHE_SERVER \& 0x0080 corresponds to SSL_SESS_CACHE_NO_AUTO_CLEAR \& 0x0100 corresponds to SSL_SESS_CACHE_NO_INTERNAL_LOOKUP \& 0x0200 corresponds to SSL_SESS_CACHE_NO_INTERNAL_STORE \& (note: some of the bits might not be supported by older openssl versions) .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_set_session_cache_mode .Sp Enables/disables session caching by setting the operational mode for \f(CW$ctx\fR to \f(CW$mode\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::CTX_set_session_cache_mode($ctx, $mode); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $mode \- mode (bitmask) \& # \& # returns: previously set cache mode .Ve .Sp For bitmask details see \*(L"CTX_get_session_cache_mode\*(R" (above). .Sp Check openssl doc .IP "\(bu" 4 CTX_get_timeout .Sp Returns the currently set timeout value for \f(CW$ctx\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::CTX_get_timeout($ctx); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # \& # returns: timeout in seconds .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_get_verify_depth .Sp Returns the verification depth limit currently set in \f(CW$ctx\fR. If no limit has been explicitly set, \-1 is returned and the default value will be used.", .Sp .Vb 4 \& my $rv = Net::SSLeay::CTX_get_verify_depth($ctx); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # \& # returns: depth limit currently set in $ctx, \-1 if no limit has been explicitly set .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_get_verify_mode .Sp Returns the verification mode (bitmask) currently set in \f(CW$ctx\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::CTX_get_verify_mode($ctx); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # \& # returns: mode (bitmask) \& \& #to decode the return value (bitmask) use: \& 0x00 corresponds to SSL_VERIFY_NONE \& 0x01 corresponds to SSL_VERIFY_PEER \& 0x02 corresponds to SSL_VERIFY_FAIL_IF_NO_PEER_CERT \& 0x04 corresponds to SSL_VERIFY_CLIENT_ONCE \& (note: some of the bits might not be supported by older openssl versions) .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_set_verify .Sp Sets the verification flags for \f(CW$ctx\fR to be \f(CW$mode\fR and specifies the verify_callback function to be used. .Sp .Vb 6 \& Net::SSLeay::CTX_set_verify($ctx, $mode, $callback); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $mode \- mode (bitmask) \& # $callback \- [optional] reference to perl callback function \& # \& # returns: no return value .Ve .Sp For bitmask details see \*(L"CTX_get_verify_mode\*(R" (above). .Sp Check openssl doc .IP "\(bu" 4 CTX_load_verify_locations .Sp Specifies the locations for \f(CW$ctx\fR, at which \s-1CA\s0 certificates for verification purposes are located. The certificates available via \f(CW$CAfile\fR and \f(CW$CApath\fR are trusted. .Sp .Vb 6 \& my $rv = Net::SSLeay::CTX_load_verify_locations($ctx, $CAfile, $CApath); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $CAfile \- (string) file of CA certificates in PEM format, the file can contain several CA certificates (or \*(Aq\*(Aq) \& # $CApath \- (string) directory containing CA certificates in PEM format (or \*(Aq\*(Aq) \& # \& # returns: 1 on success, 0 on failure (check the error stack to find out the reason) .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_need_tmp_RSA .Sp Return the result of \f(CW\*(C`SSL_CTX_ctrl(ctx,SSL_CTRL_NEED_TMP_RSA,0,NULL)\*(C'\fR .Sp .Vb 4 \& my $rv = Net::SSLeay::CTX_need_tmp_RSA($ctx); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # \& # returns: result of SSL_CTRL_NEED_TMP_RSA command .Ve .Sp Not available with OpenSSL 1.1 and later. .IP "\(bu" 4 CTX_new .Sp The same as \*(L"CTX_v23_new\*(R" .Sp .Vb 3 \& my $rv = Net::SSLeay::CTX_new(); \& # \& # returns: value corresponding to openssl\*(Aqs SSL_CTX structure (0 on failure) .Ve .Sp Check openssl doc .Sp Not available with OpenSSL 1.1 and later. .IP "\(bu" 4 CTX_v2_new .Sp Creates a new \s-1SSL_CTX\s0 object \- based on \fISSLv2_method()\fR \- as framework to establish \s-1TLS/SSL\s0 enabled connections. .Sp .Vb 3 \& my $rv = Net::SSLeay::CTX_v2_new(); \& # \& # returns: value corresponding to openssl\*(Aqs SSL_CTX structure (0 on failure) .Ve .IP "\(bu" 4 CTX_v23_new .Sp Creates a new \s-1SSL_CTX\s0 object \- based on \fISSLv23_method()\fR \- as framework to establish \s-1TLS/SSL\s0 enabled connections. .Sp .Vb 3 \& my $rv = Net::SSLeay::CTX_v23_new(); \& # \& # returns: value corresponding to openssl\*(Aqs SSL_CTX structure (0 on failure) .Ve .IP "\(bu" 4 CTX_v3_new .Sp Creates a new \s-1SSL_CTX\s0 object \- based on \fISSLv3_method()\fR \- as framework to establish \s-1TLS/SSL\s0 enabled connections. .Sp .Vb 3 \& my $rv = Net::SSLeay::CTX_v3_new(); \& # \& # returns: value corresponding to openssl\*(Aqs SSL_CTX structure (0 on failure) .Ve .IP "\(bu" 4 CTX_tlsv1_new .Sp Creates a new \s-1SSL_CTX\s0 object \- based on \fITLSv1_method()\fR \- as framework to establish \s-1TLS/SSL\s0 enabled connections. .Sp .Vb 3 \& my $rv = Net::SSLeay::CTX_tlsv1_new(); \& # \& # returns: value corresponding to openssl\*(Aqs SSL_CTX structure (0 on failure) .Ve .IP "\(bu" 4 CTX_tlsv1_1_new .Sp Creates a new \s-1SSL_CTX\s0 object \- based on \fITLSv1_1_method()\fR \- as framework to establish \s-1TLS/SSL \s0 enabled connections. Only available where supported by the underlying openssl. .Sp .Vb 3 \& my $rv = Net::SSLeay::CTX_tlsv1_1_new(); \& # \& # returns: value corresponding to openssl\*(Aqs SSL_CTX structure (0 on failure) .Ve .IP "\(bu" 4 CTX_tlsv1_2_new .Sp Creates a new \s-1SSL_CTX\s0 object \- based on \fITLSv1_2_method()\fR \- as framework to establish \s-1TLS/SSL \s0 enabled connections. Only available where supported by the underlying openssl. .Sp .Vb 3 \& my $rv = Net::SSLeay::CTX_tlsv1_2_new(); \& # \& # returns: value corresponding to openssl\*(Aqs SSL_CTX structure (0 on failure) .Ve .IP "\(bu" 4 CTX_new_with_method .Sp Creates a new \s-1SSL_CTX\s0 object based on \f(CW$meth\fR method .Sp .Vb 4 \& my $rv = Net::SSLeay::CTX_new_with_method($meth); \& # $meth \- value corresponding to openssl\*(Aqs SSL_METHOD structure \& # \& # returns: value corresponding to openssl\*(Aqs SSL_CTX structure (0 on failure) \& \& #example \& my $ctx = Net::SSLeay::CTX_new_with_method(&Net::SSLeay::TLSv1_method); .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_remove_session .Sp Removes the session \f(CW$ses\fR from the context \f(CW$ctx\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::CTX_remove_session($ctx, $ses); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $ses \- value corresponding to openssl\*(Aqs SSL_SESSION structure \& # \& # returns: 1 on success, 0 on failure .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_sess_accept .Sp .Vb 4 \& my $rv = Net::SSLeay::CTX_sess_accept($ctx); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # \& # returns: number of started SSL/TLS handshakes in server mode .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_sess_accept_good .Sp .Vb 4 \& my $rv = Net::SSLeay::CTX_sess_accept_good($ctx); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # \& # returns: number of successfully established SSL/TLS sessions in server mode .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_sess_accept_renegotiate .Sp .Vb 4 \& my $rv = Net::SSLeay::CTX_sess_accept_renegotiate($ctx); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # \& # returns: number of start renegotiations in server mode .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_sess_cache_full .Sp .Vb 4 \& my $rv = Net::SSLeay::CTX_sess_cache_full($ctx); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # \& # returns: number of sessions that were removed because the maximum session cache size was exceeded .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_sess_cb_hits .Sp .Vb 4 \& my $rv = Net::SSLeay::CTX_sess_cb_hits($ctx); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # \& # returns: number of successfully retrieved sessions from the external session cache in server mode .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_sess_connect .Sp .Vb 4 \& my $rv = Net::SSLeay::CTX_sess_connect($ctx); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # \& # returns: number of started SSL/TLS handshakes in client mode .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_sess_connect_good .Sp .Vb 4 \& my $rv = Net::SSLeay::CTX_sess_connect_good($ctx); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # \& # returns: number of successfully established SSL/TLS sessions in client mode .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_sess_connect_renegotiate .Sp .Vb 4 \& my $rv = Net::SSLeay::CTX_sess_connect_renegotiate($ctx); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # \& # returns: number of start renegotiations in client mode .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_sess_get_cache_size .Sp Returns the currently valid session cache size. .Sp .Vb 4 \& my $rv = Net::SSLeay::CTX_sess_get_cache_size($ctx); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # \& # returns: current size .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_sess_hits .Sp .Vb 4 \& my $rv = Net::SSLeay::CTX_sess_hits($ctx); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # \& # returns: number of successfully reused sessions .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_sess_misses .Sp .Vb 4 \& my $rv = Net::SSLeay::CTX_sess_misses($ctx); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # \& # returns: number of sessions proposed by clients that were not found in the internal session cache in server mode .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_sess_number .Sp .Vb 4 \& my $rv = Net::SSLeay::CTX_sess_number($ctx); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # \& # returns: current number of sessions in the internal session cache .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_sess_set_cache_size .Sp Sets the size of the internal session cache of context \f(CW$ctx\fR to \f(CW$size\fR. .Sp .Vb 5 \& Net::SSLeay::CTX_sess_set_cache_size($ctx, $size); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $size \- cache size (0 = unlimited) \& # \& # returns: previously valid size .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_sess_timeouts .Sp 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. .Sp .Vb 4 \& my $rv = Net::SSLeay::CTX_sess_timeouts($ctx); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # \& # returns: number of sessions .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_sessions .Sp Returns a pointer to the lhash databases containing the internal session cache for ctx. .Sp .Vb 4 \& my $rv = Net::SSLeay::CTX_sessions($ctx); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # \& # returns: value corresponding to openssl\*(Aqs LHASH structure (0 on failure) .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_set1_param .Sp Applies X509 verification parameters \f(CW$vpm\fR on \f(CW$ctx\fR .Sp .Vb 5 \& my $rv = Net::SSLeay::CTX_set1_param($ctx, $vpm); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $vpm \- value corresponding to openssl\*(Aqs X509_VERIFY_PARAM structure \& # \& # returns: 1 on success, 0 on failure .Ve .IP "\(bu" 4 CTX_set_cert_store .Sp Sets/replaces the certificate verification storage of \f(CW$ctx\fR to/with \f(CW$store\fR. .Sp .Vb 5 \& Net::SSLeay::CTX_set_cert_store($ctx, $store); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $store \- value corresponding to openssl\*(Aqs X509_STORE structure \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_set_cert_verify_callback .Sp Sets the verification callback function for \f(CW$ctx\fR. \s-1SSL\s0 objects that are created from \f(CW$ctx\fR inherit the setting valid at the time when \f(CW\*(C`Net::SSLeay::new($ctx)\*(C'\fR is called. .Sp .Vb 6 \& Net::SSLeay::CTX_set_cert_verify_callback($ctx, $func, $data); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $func \- perl reference to callback function \& # $data \- [optional] data that will be passed to callback function when invoked \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_set_cipher_list .Sp Sets the list of available ciphers for \f(CW$ctx\fR using the control string \f(CW$str\fR. The list of ciphers is inherited by all ssl objects created from \f(CW$ctx\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::CTX_set_cipher_list($s, $str); \& # $s \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $str \- (string) cipher list e.g. \*(Aq3DES:+RSA\*(Aq \& # \& # returns: 1 if any cipher could be selected and 0 on complete failure .Ve .Sp The format of \f(CW$str\fR is described in .Sp Check openssl doc .IP "\(bu" 4 CTX_set_client_CA_list .Sp Sets the list of CAs sent to the client when requesting a client certificate for \f(CW$ctx\fR. .Sp .Vb 5 \& Net::SSLeay::CTX_set_client_CA_list($ctx, $list); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $list \- value corresponding to openssl\*(Aqs X509_NAME_STACK structure \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_set_default_passwd_cb .Sp Sets the default password callback called when loading/storing a \s-1PEM\s0 certificate with encryption. .Sp .Vb 5 \& Net::SSLeay::CTX_set_default_passwd_cb($ctx, $func); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $func \- perl reference to callback function \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_set_default_passwd_cb_userdata .Sp Sets a pointer to userdata which will be provided to the password callback on invocation. .Sp .Vb 5 \& Net::SSLeay::CTX_set_default_passwd_cb_userdata($ctx, $userdata); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $userdata \- data that will be passed to callback function when invoked \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_set_default_verify_paths .Sp ??? (more info needed) .Sp .Vb 4 \& my $rv = Net::SSLeay::CTX_set_default_verify_paths($ctx); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # \& # returns: 1 on success, 0 on failure .Ve .IP "\(bu" 4 CTX_set_ex_data .Sp Is used to store application data at \f(CW$data\fR for \f(CW$idx\fR into the \f(CW$ctx\fR object. .Sp .Vb 6 \& my $rv = Net::SSLeay::CTX_set_ex_data($ssl, $idx, $data); \& # $ssl \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $idx \- (integer) ??? \& # $data \- (pointer) ??? \& # \& # returns: 1 on success, 0 on failure .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_set_purpose .Sp .Vb 5 \& my $rv = Net::SSLeay::CTX_set_purpose($s, $purpose); \& # $s \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $purpose \- (integer) purpose identifier \& # \& # returns: 1 on success, 0 on failure \& \& #avainable purpose identifier \& 1 \- X509_PURPOSE_SSL_CLIENT \& 2 \- X509_PURPOSE_SSL_SERVER \& 3 \- X509_PURPOSE_NS_SSL_SERVER \& 4 \- X509_PURPOSE_SMIME_SIGN \& 5 \- X509_PURPOSE_SMIME_ENCRYPT \& 6 \- X509_PURPOSE_CRL_SIGN \& 7 \- X509_PURPOSE_ANY \& 8 \- X509_PURPOSE_OCSP_HELPER \& 9 \- X509_PURPOSE_TIMESTAMP_SIGN \& \& #or use corresponding constants \& $purpose = &Net::SSLeay::X509_PURPOSE_SSL_CLIENT; \& ... \& $purpose = &Net::SSLeay::X509_PURPOSE_TIMESTAMP_SIGN; .Ve .IP "\(bu" 4 CTX_set_quiet_shutdown .Sp Sets the 'quiet shutdown' flag for \f(CW$ctx\fR to be mode. \s-1SSL\s0 objects created from \f(CW$ctx\fR inherit the mode valid at the time \f(CW\*(C`Net::SSLeay::new($ctx)\*(C'\fR is called. .Sp .Vb 5 \& Net::SSLeay::CTX_set_quiet_shutdown($ctx, $mode); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $mode \- 0 or 1 \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_set_read_ahead .Sp .Vb 5 \& my $rv = Net::SSLeay::CTX_set_read_ahead($ctx, $val); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $val \- read_ahead value to be set \& # \& # returns: the original read_ahead value .Ve .IP "\(bu" 4 CTX_set_session_id_context .Sp Sets the context \f(CW$sid_ctx\fR of length \f(CW$sid_ctx_len\fR within which a session can be reused for the \f(CW$ctx\fR object. .Sp .Vb 6 \& my $rv = Net::SSLeay::CTX_set_session_id_context($ctx, $sid_ctx, $sid_ctx_len); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $sid_ctx \- data buffer \& # $sid_ctx_len \- length of data in $sid_ctx \& # \& # returns: 1 on success, 0 on failure (the error is logged to the error stack) .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_set_ssl_version .Sp Sets a new default \s-1TLS/SSL\s0 method for \s-1SSL\s0 objects newly created from this \f(CW$ctx\fR. \&\s-1SSL\s0 objects already created with \f(CW\*(C`Net::SSLeay::new($ctx)\*(C'\fR are not affected, except when \f(CW\*(C`Net::SSLeay:clear($ssl)\*(C'\fR is being called. .Sp .Vb 5 \& my $rv = Net::SSLeay::CTX_set_ssl_version($ctx, $meth); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $meth \- value corresponding to openssl\*(Aqs SSL_METHOD structure \& # \& # returns: 1 on success, 0 on failure .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_set_timeout .Sp Sets the timeout for newly created sessions for \f(CW$ctx\fR to \f(CW$t\fR. The timeout value \f(CW$t\fR must be given in seconds. .Sp .Vb 5 \& my $rv = Net::SSLeay::CTX_set_timeout($ctx, $t); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $t \- timeout in seconds \& # \& # returns: previously set timeout value .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_set_tmp_dh .Sp Sets \s-1DH\s0 parameters to be used to be \f(CW$dh\fR. The key is inherited by all ssl objects created from \f(CW$ctx\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::CTX_set_tmp_dh($ctx, $dh); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $dh \- value corresponding to openssl\*(Aqs DH structure \& # \& # returns: 1 on success, 0 on failure .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_set_tmp_dh_callback .Sp Sets the callback function for \f(CW$ctx\fR to be used when a \s-1DH\s0 parameters are required to \f(CW$tmp_dh_callback\fR. .Sp .Vb 5 \& Net::SSLeay::CTX_set_tmp_dh_callback($ctx, $tmp_dh_callback); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # tmp_dh_callback \- (function pointer) ??? \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_set_tmp_rsa .Sp Sets the temporary/ephemeral \s-1RSA\s0 key to be used to be \f(CW$rsa\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::CTX_set_tmp_rsa($ctx, $rsa); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $rsa \- value corresponding to openssl\*(Aqs RSA structure \& # \& # returns: 1 on success, 0 on failure .Ve .Sp Check openssl doc .Sp Not available with OpenSSL 1.1 and later. .IP "\(bu" 4 CTX_set_tmp_rsa_callback .Sp Sets the callback function for ctx to be used when a temporary/ephemeral \s-1RSA\s0 key is required to \f(CW$tmp_rsa_callback\fR. .Sp ??? (does this function really work?) .Sp .Vb 5 \& Net::SSLeay::CTX_set_tmp_rsa_callback($ctx, $tmp_rsa_callback); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $tmp_rsa_callback \- (function pointer) ??? \& # \& # returns: no return value .Ve .Sp Check openssl doc .Sp Not available with OpenSSL 1.1 and later. .IP "\(bu" 4 CTX_set_trust .Sp .Vb 5 \& my $rv = Net::SSLeay::CTX_set_trust($s, $trust); \& # $s \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $trust \- (integer) trust identifier \& # \& # returns: the original value \& \& #available trust identifiers \& 1 \- X509_TRUST_COMPAT \& 2 \- X509_TRUST_SSL_CLIENT \& 3 \- X509_TRUST_SSL_SERVER \& 4 \- X509_TRUST_EMAIL \& 5 \- X509_TRUST_OBJECT_SIGN \& 6 \- X509_TRUST_OCSP_SIGN \& 7 \- X509_TRUST_OCSP_REQUEST \& 8 \- X509_TRUST_TSA \& \& #or use corresponding constants \& $trust = &Net::SSLeay::X509_TRUST_COMPAT; \& ... \& $trust = &Net::SSLeay::X509_TRUST_TSA; .Ve .IP "\(bu" 4 CTX_set_verify_depth .Sp Sets the maximum depth for the certificate chain verification that shall be allowed for ctx. .Sp .Vb 5 \& Net::SSLeay::CTX_set_verify_depth($ctx, $depth); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $depth \- max. depth \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_use_PKCS12_file .Sp Adds the certificate and private key from \s-1PKCS12\s0 file \f(CW$p12filename\fR to \f(CW$ctx\fR. .Sp .Vb 6 \& my $rv = Net::SSLeay::CTX_use_PKCS12_file($ctx, $p12filename, $password); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $p12filename \- (string) filename \& # $password \- (string) password to decrypt private key \& # \& # returns: 1 on success, 0 on failure .Ve .IP "\(bu" 4 CTX_use_PrivateKey .Sp Adds the private key \f(CW$pkey\fR to \f(CW$ctx\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::CTX_use_PrivateKey($ctx, $pkey); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $pkey \- value corresponding to openssl\*(Aqs EVP_PKEY structure \& # \& # returns: 1 on success, otherwise check out the error stack to find out the reason .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_use_PrivateKey_file .Sp Adds the first private key found in \f(CW$file\fR to \f(CW$ctx\fR. .Sp .Vb 6 \& my $rv = Net::SSLeay::CTX_use_PrivateKey_file($ctx, $file, $type); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $file \- (string) file name \& # $type \- (integer) type \- use constants &Net::SSLeay::FILETYPE_PEM or &Net::SSLeay::FILETYPE_ASN1 \& # \& # returns: 1 on success, otherwise check out the error stack to find out the reason .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_use_RSAPrivateKey .Sp Adds the \s-1RSA\s0 private key \f(CW$rsa\fR to \f(CW$ctx\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::CTX_use_RSAPrivateKey($ctx, $rsa); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $rsa \- value corresponding to openssl\*(Aqs RSA structure \& # \& # returns: 1 on success, otherwise check out the error stack to find out the reason .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_use_RSAPrivateKey_file .Sp Adds the first \s-1RSA\s0 private key found in \f(CW$file\fR to \f(CW$ctx\fR. .Sp .Vb 6 \& my $rv = Net::SSLeay::CTX_use_RSAPrivateKey_file($ctx, $file, $type); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $file \- (string) file name \& # $type \- (integer) type \- use constants &Net::SSLeay::FILETYPE_PEM or &Net::SSLeay::FILETYPE_ASN1 \& # \& # returns: 1 on success, otherwise check out the error stack to find out the reason .Ve .IP "\(bu" 4 CTX_use_certificate .Sp Loads the certificate \f(CW$x\fR into \f(CW$ctx\fR .Sp .Vb 5 \& my $rv = Net::SSLeay::CTX_use_certificate($ctx, $x); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $x \- value corresponding to openssl\*(Aqs X509 structure \& # \& # returns: 1 on success, otherwise check out the error stack to find out the reason .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_use_certificate_chain_file .Sp Loads a certificate chain from \f(CW$file\fR into \f(CW$ctx\fR. The certificates must be in \s-1PEM\s0 format and must be sorted starting with the subject's certificate (actual client or server certificate), followed by intermediate \&\s-1CA\s0 certificates if applicable, and ending at the highest level (root) \s-1CA.\s0 .Sp .Vb 5 \& my $rv = Net::SSLeay::CTX_use_certificate_chain_file($ctx, $file); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $file \- (string) file name \& # \& # returns: 1 on success, otherwise check out the error stack to find out the reason .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_use_certificate_file .Sp Loads the first certificate stored in \f(CW$file\fR into \f(CW$ctx\fR. .Sp .Vb 6 \& my $rv = Net::SSLeay::CTX_use_certificate_file($ctx, $file, $type); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $file \- (string) file name \& # $type \- (integer) type \- use constants &Net::SSLeay::FILETYPE_PEM or &Net::SSLeay::FILETYPE_ASN1 \& # \& # returns: 1 on success, otherwise check out the error stack to find out the reason .Ve .Sp Check openssl doc .PP \fILow level \s-1API:\s0 SSL_* related functions\fR .IX Subsection "Low level API: SSL_* related functions" .PP \&\fB\s-1NOTE:\s0\fR Please note that the function described in this chapter have \*(L"\s-1SSL_\*(R"\s0 part stripped from their original openssl names. .IP "\(bu" 4 new .Sp Creates a new \s-1SSL\s0 structure which is needed to hold the data for a \s-1TLS/SSL\s0 connection. The new structure inherits the settings of the underlying context \f(CW$ctx:\fR connection method (SSLv2/v3/TLSv1), options, verification settings, timeout settings. .Sp .Vb 4 \& my $rv = Net::SSLeay::new($ctx); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # \& # returns: value corresponding to openssl\*(Aqs SSL structure (0 on failure) .Ve .Sp Check openssl doc .IP "\(bu" 4 accept .Sp Waits for a \s-1TLS/SSL\s0 client to initiate the \s-1TLS/SSL\s0 handshake. The communication channel must already have been set and assigned to the ssl by setting an underlying \s-1BIO.\s0 .Sp .Vb 4 \& my $rv = Net::SSLeay::accept($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: 1 = success, 0 = handshake not successful, <0 = fatal error during handshake .Ve .Sp Check openssl doc .IP "\(bu" 4 add_client_CA .Sp Adds the \s-1CA\s0 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 \s-1SSL_CTX\s0 object. .Sp .Vb 5 \& my $rv = Net::SSLeay::add_client_CA($ssl, $x); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $x \- value corresponding to openssl\*(Aqs X509 structure \& # \& # returns: 1 on success, 0 on failure .Ve .Sp Check openssl doc .IP "\(bu" 4 callback_ctrl .Sp ??? (more info needed) .Sp .Vb 6 \& my $rv = Net::SSLeay::callback_ctrl($ssl, $cmd, $fp); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $cmd \- (integer) command id \& # $fp \- (function pointer) ??? \& # \& # returns: ??? .Ve .Sp Check openssl doc .IP "\(bu" 4 check_private_key .Sp Checks the consistency of a private key with the corresponding certificate loaded into \f(CW$ssl\fR .Sp .Vb 4 \& my $rv = Net::SSLeay::check_private_key($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: 1 on success, otherwise check out the error stack to find out the reason .Ve .Sp Check openssl doc .IP "\(bu" 4 clear .Sp Reset \s-1SSL\s0 object to allow another connection. .Sp .Vb 4 \& Net::SSLeay::clear($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 connect .Sp Initiate the \s-1TLS/SSL\s0 handshake with an \s-1TLS/SSL\s0 server. .Sp .Vb 4 \& my $rv = Net::SSLeay::connect($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: 1 = success, 0 = handshake not successful, <0 = fatal error during handshake .Ve .Sp Check openssl doc .IP "\(bu" 4 copy_session_id .Sp Copies the session structure fro \f(CW$from\fR to \f(CW$to\fR (+ also the private key and certificate associated with \f(CW$from\fR). .Sp .Vb 5 \& Net::SSLeay::copy_session_id($to, $from); \& # $to \- value corresponding to openssl\*(Aqs SSL structure \& # $from \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: no return value .Ve .IP "\(bu" 4 ctrl .Sp Internal handling function for \s-1SSL\s0 objects. .Sp \&\fB\s-1BEWARE:\s0\fR openssl doc says: This function should never be called directly! .Sp .Vb 7 \& my $rv = Net::SSLeay::ctrl($ssl, $cmd, $larg, $parg); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $cmd \- (integer) command id \& # $larg \- (integer) long ??? \& # $parg \- (string/pointer) ??? \& # \& # returns: (long) result of given command ??? .Ve .Sp For more details about valid \f(CW$cmd\fR values check \*(L"CTX_ctrl\*(R". .Sp Check openssl doc .IP "\(bu" 4 do_handshake .Sp Will wait for a \s-1SSL/TLS\s0 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 \fISSL_set_accept_state\fR\|(3). .Sp .Vb 4 \& my $rv = Net::SSLeay::do_handshake($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: 1 = success, 0 = handshake not successful, <0 = fatal error during handshake .Ve .Sp Check openssl doc .IP "\(bu" 4 dup .Sp Returns a duplicate of \f(CW$ssl\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::dup($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: value corresponding to openssl\*(Aqs SSL structure (0 on failure) .Ve .IP "\(bu" 4 free .Sp Free an allocated \s-1SSL\s0 structure. .Sp .Vb 4 \& Net::SSLeay::free($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 get_SSL_CTX .Sp Returns a pointer to the \s-1SSL_CTX\s0 object, from which \f(CW$ssl\fR was created with Net::SSLeay::new. .Sp .Vb 4 \& my $rv = Net::SSLeay::get_SSL_CTX($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: value corresponding to openssl\*(Aqs SSL_CTX structure (0 on failure) .Ve .Sp Check openssl doc .IP "\(bu" 4 set_SSL_CTX .Sp Sets the \s-1SSL_CTX\s0 the corresponds to an \s-1SSL\s0 session. .Sp .Vb 5 \& my $the_ssl_ctx = Net::SSLeay::set_SSL_CTX($ssl, $ssl_ctx); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $ssl_ctx \- Change the ssl object to the given ssl_ctx \& # \& # returns \- the ssl_ctx .Ve .IP "\(bu" 4 get_app_data .Sp Can be used to get application defined value/data. .Sp .Vb 4 \& my $rv = Net::SSLeay::get_app_data($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: string/buffer/pointer ??? .Ve .IP "\(bu" 4 set_app_data .Sp Can be used to set some application defined value/data. .Sp .Vb 5 \& my $rv = Net::SSLeay::set_app_data($ssl, $arg); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $arg \- (string/buffer/pointer ???) data \& # \& # returns: ??? .Ve .IP "\(bu" 4 get_certificate .Sp Gets X509 certificate from an established \s-1SSL\s0 connection. .Sp .Vb 4 \& my $rv = Net::SSLeay::get_certificate($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: value corresponding to openssl\*(Aqs X509 structure (0 on failure) .Ve .IP "\(bu" 4 get_cipher .Sp Obtains the name of the currently used cipher. .Sp .Vb 4 \& my $rv = Net::SSLeay::get_cipher($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: (string) cipher name e.g. \*(AqDHE\-RSA\-AES256\-SHA\*(Aq or \*(Aq\*(Aq, when no session has been established. .Ve .Sp Check openssl doc .IP "\(bu" 4 get_cipher_bits .Sp Obtain the number of secret/algorithm bits used. .Sp .Vb 4 \& my $rv = Net::SSLeay::get_cipher_bits($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: number of secret bits used by current cipher .Ve .Sp Check openssl doc and .IP "\(bu" 4 get_cipher_list .Sp Returns the name (string) of the \s-1SSL_CIPHER\s0 listed for \f(CW$ssl\fR with priority \f(CW$n\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::get_cipher_list($ssl, $n); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $n \- (integer) priority \& # \& # returns: (string) cipher name e.g. \*(AqEDH\-DSS\-DES\-CBC3\-SHA\*(Aq or \*(Aq\*(Aq in case of error .Ve .Sp Call Net::SSLeay::get_cipher_list with priority starting from 0 to obtain the sorted list of available ciphers, until '' is returned: .Sp .Vb 5 \& my $priority = 0; \& while (my $c = Net::SSLeay::get_cipher_list($ssl, $priority)) { \& print "cipher[$priority] = $c\en"; \& $priority++; \& } .Ve .Sp Check openssl doc .IP "\(bu" 4 get_client_CA_list .Sp Returns the list of client CAs explicitly set for \f(CW$ssl\fR using \f(CW\*(C`Net::SSleay::set_client_CA_list\*(C'\fR or \f(CW$ssl\fR's \s-1SSL_CTX\s0 object with \f(CW\*(C`Net::SSLeay::CTX_set_client_CA_list\*(C'\fR, when in server mode. .Sp In client mode, returns the list of client CAs sent from the server, if any. .Sp .Vb 4 \& my $rv = Net::SSLeay::get_client_CA_list($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: value corresponding to openssl\*(Aqs STACK_OF(X509_NAME) structure (0 on failure) .Ve .Sp Check openssl doc .IP "\(bu" 4 get_current_cipher .Sp Returns the cipher actually used. .Sp .Vb 4 \& my $rv = Net::SSLeay::get_current_cipher($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: value corresponding to openssl\*(Aqs SSL_CIPHER structure (0 on failure) .Ve .Sp Check openssl doc .IP "\(bu" 4 get_default_timeout .Sp Returns the default timeout value assigned to \s-1SSL_SESSION\s0 objects negotiated for the protocol valid for \f(CW$ssl\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::get_default_timeout($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: (long) timeout in seconds .Ve .Sp Check openssl doc .IP "\(bu" 4 get_error .Sp Returns a result code for a preceding call to \f(CW\*(C`connect\*(C'\fR, \f(CW\*(C`accept\*(C'\fR, \f(CW\*(C`do_handshake\*(C'\fR, \f(CW\*(C`read\*(C'\fR, \f(CW\*(C`peek\*(C'\fR or \f(CW\*(C`write\*(C'\fR on \f(CW$ssl\fR. .Sp .Vb 10 \& my $rv = Net::SSLeay::get_error($ssl, $ret); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $ret \- return value of preceding TLS/SSL I/O operation \& # \& # returns: result code, which is one of the following values: \& # 0 \- SSL_ERROR_NONE \& # 1 \- SSL_ERROR_SSL \& # 2 \- SSL_ERROR_WANT_READ \& # 3 \- SSL_ERROR_WANT_WRITE \& # 4 \- SSL_ERROR_WANT_X509_LOOKUP \& # 5 \- SSL_ERROR_SYSCALL \& # 6 \- SSL_ERROR_ZERO_RETURN \& # 7 \- SSL_ERROR_WANT_CONNECT \& # 8 \- SSL_ERROR_WANT_ACCEPT .Ve .Sp Check openssl doc .IP "\(bu" 4 get_ex_data .Sp Is used to retrieve the information for \f(CW$idx\fR from \f(CW$ssl\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::get_ex_data($ssl, $idx); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $idx \- (integer) index for application specific data \& # \& # returns: pointer to ??? .Ve .Sp Check openssl doc .IP "\(bu" 4 set_ex_data .Sp Is used to store application data at \f(CW$data\fR for \f(CW$idx\fR into the \f(CW$ssl\fR object. .Sp .Vb 6 \& my $rv = Net::SSLeay::set_ex_data($ssl, $idx, $data); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $idx \- (integer) ??? \& # $data \- (pointer) ??? \& # \& # returns: 1 on success, 0 on failure .Ve .Sp Check openssl doc .IP "\(bu" 4 get_ex_new_index .Sp Is used to register a new index for application specific data. .Sp .Vb 8 \& my $rv = Net::SSLeay::get_ex_new_index($argl, $argp, $new_func, $dup_func, $free_func); \& # $argl \- (long) ??? \& # $argp \- (pointer) ??? \& # $new_func \- function pointer ??? (CRYPTO_EX_new *) \& # $dup_func \- function pointer ??? (CRYPTO_EX_dup *) \& # $free_func \- function pointer ??? (CRYPTO_EX_free *) \& # \& # returns: (integer) ??? .Ve .Sp Check openssl doc .IP "\(bu" 4 get_fd .Sp Returns the file descriptor which is linked to \f(CW$ssl\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::get_fd($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: file descriptor (>=0) or \-1 on failure .Ve .Sp Check openssl doc .IP "\(bu" 4 get_finished .Sp Obtains the latest 'Finished' message sent to the peer. .Sp ??? (does this function really work?) .Sp .Vb 6 \& my $rv = Net::SSLeay::get_finished($ssl, $buf, $count); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $buf \- buffer where the returned data will be stored (pointer ???, pre\-allocated ???) \& # $count \- max. size of return data \& # \& # returns: actual size of the returned data in $buf .Ve .IP "\(bu" 4 get_peer_finished .Sp Obtains the latest 'Finished' message expected from the peer. .Sp ??? (does this function really work?) .Sp .Vb 6 \& my $rv = Net::SSLeay::get_peer_finished($ssl, $buf, $count); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $buf \- buffer where the returned data will be stored (pointer ???, pre\-allocated ???) \& # $count \- max. size of the return data \& # \& # returns: actual size of the returned data in $buf .Ve .IP "\(bu" 4 get_keyblock_size .Sp Gets the length of the \s-1TLS\s0 keyblock. .Sp \&\fB\s-1NOTE:\s0\fR Does not exactly correspond to any low level \s-1API\s0 function. .Sp .Vb 4 \& my $rv = Net::SSLeay::get_keyblock_size($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: keyblock size, \-1 on error .Ve .IP "\(bu" 4 get_mode .Sp Returns the mode (bitmask) set for \f(CW$ssl\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::get_mode($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: mode (bitmask) .Ve .Sp To decode the return value (bitmask) see documentation for \*(L"CTX_get_mode\*(R". .Sp Check openssl doc .IP "\(bu" 4 set_mode .Sp Adds the mode set via bitmask in \f(CW$mode\fR to \f(CW$ssl\fR. Options already set before are not cleared. .Sp .Vb 5 \& my $rv = Net::SSLeay::set_mode($ssl, $mode); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $mode \- mode (bitmask) \& # \& # returns: the new mode bitmask after adding $mode .Ve .Sp For \f(CW$mode\fR bitmask details see \*(L"CTX_get_mode\*(R". .Sp Check openssl doc .IP "\(bu" 4 get_options .Sp Returns the options (bitmask) set for \f(CW$ssl\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::get_options($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: options (bitmask) .Ve .Sp To decode the return value (bitmask) see documentation for \*(L"CTX_get_options\*(R". .Sp Check openssl doc .IP "\(bu" 4 set_options .Sp Adds the options set via bitmask in \f(CW$options\fR to \f(CW$ssl\fR. Options already set before are not cleared! .Sp .Vb 5 \& Net::SSLeay::set_options($ssl, $options); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $options \- options (bitmask) \& # \& # returns: the new options bitmask after adding $options .Ve .Sp For \f(CW$options\fR bitmask details see \*(L"CTX_get_options\*(R". .Sp Check openssl doc .IP "\(bu" 4 get_peer_certificate .Sp Get the X509 certificate of the peer. .Sp .Vb 4 \& my $rv = Net::SSLeay::get_peer_certificate($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: value corresponding to openssl\*(Aqs X509 structure (0 on failure) .Ve .Sp Check openssl doc .IP "\(bu" 4 get_peer_cert_chain .Sp Get the certificate chain of the peer as an array of X509 structures. .Sp .Vb 4 \& my @rv = Net::SSLeay::get_peer_cert_chain($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: list of X509 structures .Ve .Sp Check openssl doc .IP "\(bu" 4 get_quiet_shutdown .Sp Returns the 'quiet shutdown' setting of ssl. .Sp .Vb 4 \& my $rv = Net::SSLeay::get_quiet_shutdown($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: (integer) current \*(Aqquiet shutdown\*(Aq value .Ve .Sp Check openssl doc .IP "\(bu" 4 get_rbio .Sp Get 'read' \s-1BIO\s0 linked to an \s-1SSL\s0 object \f(CW$ssl\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::get_rbio($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: value corresponding to openssl\*(Aqs BIO structure (0 on failure) .Ve .Sp Check openssl doc .IP "\(bu" 4 get_read_ahead .Sp .Vb 4 \& my $rv = Net::SSLeay::get_read_ahead($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: (integer) read_ahead value .Ve .IP "\(bu" 4 set_read_ahead .Sp .Vb 5 \& Net::SSLeay::set_read_ahead($ssl, $val); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $val \- read_ahead value to be set \& # \& # returns: the original read_ahead value .Ve .IP "\(bu" 4 get_server_random .Sp Returns internal SSLv3 server_random value. .Sp .Vb 4 \& Net::SSLeay::get_server_random($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: server_random value (binary data) .Ve .IP "\(bu" 4 get_client_random .Sp \&\fB\s-1NOTE:\s0\fR Does not exactly correspond to any low level \s-1API\s0 function .Sp Returns internal SSLv3 client_random value. .Sp .Vb 4 \& Net::SSLeay::get_client_random($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: client_random value (binary data) .Ve .IP "\(bu" 4 export_keying_material .Sp Returns a buffer of \f(CW$req_len\fR bytes of keying material based on the constant string \f(CW$label\fR using the masterkey and client and server random strings as described in draft\-ietf\-pppext\-eap\-ttls\-01.txt and See rfc2716 If p is present, it will be concatenated before generating the keying material Returns undef on error .Sp .Vb 1 \& my $out = Net::SSLeay::export_keying_material($ssl, $req_len, $label, $p); .Ve .IP "\(bu" 4 get_session .Sp Retrieve \s-1TLS/SSL\s0 session data used in \f(CW$ssl\fR. The reference count of the \s-1SSL_SESSION\s0 is \s-1NOT\s0 incremented. .Sp .Vb 4 \& my $rv = Net::SSLeay::get_session($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: value corresponding to openssl\*(Aqs SSL_SESSION structure (0 on failure) .Ve .Sp Check openssl doc .IP "\(bu" 4 SSL_get0_session .Sp The alias for \*(L"get_session\*(R" (note that the name is \f(CW\*(C`SSL_get0_session\*(C'\fR \s-1NOT \s0\f(CW\*(C`get0_session\*(C'\fR). .Sp .Vb 1 \& my $rv = Net::SSLeay::SSL_get0_session(); .Ve .IP "\(bu" 4 get1_session .Sp Returns a pointer to the \s-1SSL_SESSION\s0 actually used in \f(CW$ssl\fR. The reference count of the \s-1SSL_SESSION\s0 is incremented by 1. .Sp .Vb 4 \& my $rv = Net::SSLeay::get1_session($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: value corresponding to openssl\*(Aqs SSL_SESSION structure (0 on failure) .Ve .Sp Check openssl doc .IP "\(bu" 4 get_shared_ciphers .Sp Returns string with a list (colon ':' separated) of ciphers shared between client and server within \s-1SSL\s0 session \f(CW$ssl\fR. .Sp .Vb 3 \& my $rv = Net::SSLeay::get_shared_ciphers() \& # \& # returns: string like \*(AqECDHE\-RSA\-AES256\-SHA:ECDHE\-ECDSA\-AES256\-SHA:DHE\-RSA\-AES256\-SHA:DHE\-DSS\-AES256\-SHA:...\*(Aq .Ve .IP "\(bu" 4 get_shutdown .Sp Returns the shutdown mode of \f(CW$ssl\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::get_shutdown($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: shutdown mode (bitmask) of ssl \& \& #to decode the return value (bitmask) use: \& 0 \- No shutdown setting, yet \& 1 \- SSL_SENT_SHUTDOWN \& 2 \- SSL_RECEIVED_SHUTDOWN .Ve .Sp Check openssl doc .IP "\(bu" 4 get_ssl_method .Sp Returns a function pointer to the \s-1TLS/SSL\s0 method set in \f(CW$ssl\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::get_ssl_method($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: value corresponding to openssl\*(Aqs SSL_METHOD structure (0 on failure) .Ve .Sp Check openssl doc .IP "\(bu" 4 get_state .Sp Returns the \s-1SSL\s0 connection state. .Sp .Vb 9 \& my $rv = Net::SSLeay::get_state($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: (integer) state value \& # to decode the returned state check: \& # SSL_ST_* constants in openssl/ssl.h \& # SSL2_ST_* constants in openssl/ssl2.h \& # SSL23_ST_* constants in openssl/ssl23.h \& # SSL3_ST_* + DTLS1_ST_* constants in openssl/ssl3.h .Ve .IP "\(bu" 4 state .Sp Exactly the same as \*(L"get_state\*(R". .Sp .Vb 1 \& my $rv = Net::SSLeay::state($ssl); .Ve .IP "\(bu" 4 set_state .Sp Sets the \s-1SSL\s0 connection state. .Sp .Vb 1 \& Net::SSLeay::set_state($ssl,Net::SSLeay::SSL_ST_ACCEPT()); .Ve .Sp Not available with OpenSSL 1.1 and later. .IP "\(bu" 4 get_verify_depth .Sp Returns the verification depth limit currently set in \f(CW$ssl\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::get_verify_depth($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: current depth or \-1 if no limit has been explicitly set .Ve .Sp Check openssl doc .IP "\(bu" 4 set_verify_depth .Sp Sets the maximum depth for the certificate chain verification that shall be allowed for \f(CW$ssl\fR. .Sp .Vb 5 \& Net::SSLeay::set_verify_depth($ssl, $depth); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $depth \- (integer) depth \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 get_verify_mode .Sp Returns the verification mode (bitmask) currently set in \f(CW$ssl\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::get_verify_mode($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: mode (bitmask) .Ve .Sp To decode the return value (bitmask) see documentation for \*(L"CTX_get_verify_mode\*(R". .Sp Check openssl doc .IP "\(bu" 4 set_verify .Sp Sets the verification flags for \f(CW$ssl\fR to be \f(CW$mode\fR and specifies the \f(CW$verify_callback\fR function to be used. .Sp .Vb 6 \& Net::SSLeay::set_verify($ssl, $mode, $callback); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $mode \- mode (bitmask) \& # $callback \- [optional] reference to perl callback function \& # \& # returns: no return value .Ve .Sp For \f(CW$mode\fR bitmask details see \*(L"CTX_get_verify_mode\*(R". .Sp Check openssl doc .IP "\(bu" 4 get_verify_result .Sp Returns the result of the verification of the X509 certificate presented by the peer, if any. .Sp .Vb 10 \& my $rv = Net::SSLeay::get_verify_result($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: (integer) \& # 0 \- X509_V_OK: ok \& # 2 \- X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: unable to get issuer certificate \& # 3 \- X509_V_ERR_UNABLE_TO_GET_CRL: unable to get certificate CRL \& # 4 \- X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE: unable to decrypt certificate\*(Aqs signature \& # 5 \- X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE: unable to decrypt CRL\*(Aqs signature \& # 6 \- X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY: unable to decode issuer public key \& # 7 \- X509_V_ERR_CERT_SIGNATURE_FAILURE: certificate signature failure \& # 8 \- X509_V_ERR_CRL_SIGNATURE_FAILURE: CRL signature failure \& # 9 \- X509_V_ERR_CERT_NOT_YET_VALID: certificate is not yet valid \& # 10 \- X509_V_ERR_CERT_HAS_EXPIRED: certificate has expired \& # 11 \- X509_V_ERR_CRL_NOT_YET_VALID: CRL is not yet valid \& # 12 \- X509_V_ERR_CRL_HAS_EXPIRED: CRL has expired \& # 13 \- X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD: format error in certificate\*(Aqs notBefore field \& # 14 \- X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD: format error in certificate\*(Aqs notAfter field \& # 15 \- X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD: format error in CRL\*(Aqs lastUpdate field \& # 16 \- X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD: format error in CRL\*(Aqs nextUpdate field \& # 17 \- X509_V_ERR_OUT_OF_MEM: out of memory \& # 18 \- X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT: self signed certificate \& # 19 \- X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN: self signed certificate in certificate chain \& # 20 \- X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY: unable to get local issuer certificate \& # 21 \- X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE: unable to verify the first certificate \& # 22 \- X509_V_ERR_CERT_CHAIN_TOO_LONG: certificate chain too long \& # 23 \- X509_V_ERR_CERT_REVOKED: certificate revoked \& # 24 \- X509_V_ERR_INVALID_CA: invalid CA certificate \& # 25 \- X509_V_ERR_PATH_LENGTH_EXCEEDED: path length constraint exceeded \& # 26 \- X509_V_ERR_INVALID_PURPOSE: unsupported certificate purpose \& # 27 \- X509_V_ERR_CERT_UNTRUSTED: certificate not trusted \& # 28 \- X509_V_ERR_CERT_REJECTED: certificate rejected \& # 29 \- X509_V_ERR_SUBJECT_ISSUER_MISMATCH: subject issuer mismatch \& # 30 \- X509_V_ERR_AKID_SKID_MISMATCH: authority and subject key identifier mismatch \& # 31 \- X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH: authority and issuer serial number mismatch \& # 32 \- X509_V_ERR_KEYUSAGE_NO_CERTSIGN:key usage does not include certificate signing \& # 50 \- X509_V_ERR_APPLICATION_VERIFICATION: application verification failure .Ve .Sp Check openssl doc .IP "\(bu" 4 set_verify_result .Sp Override result of peer certificate verification. .Sp .Vb 5 \& Net::SSLeay::set_verify_result($ssl, $v); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $v \- (integer) result value \& # \& # returns: no return value .Ve .Sp For more info about valid return values see \*(L"get_verify_result\*(R" .Sp Check openssl doc .IP "\(bu" 4 get_wbio .Sp Get 'write' \s-1BIO\s0 linked to an \s-1SSL\s0 object \f(CW$ssl\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::get_wbio($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: value corresponding to openssl\*(Aqs BIO structure (0 on failure) .Ve .Sp Check openssl doc .IP "\(bu" 4 load_client_CA_file .Sp Load X509 certificates from file (\s-1PEM\s0 formatted). .Sp .Vb 4 \& my $rv = Net::SSLeay::load_client_CA_file($file); \& # $file \- (string) file name \& # \& # returns: value corresponding to openssl\*(Aqs STACK_OF(X509_NAME) structure (0 on failure) .Ve .Sp Check openssl doc .IP "\(bu" 4 clear_num_renegotiations .Sp Executes \s-1SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS\s0 command on \f(CW$ssl\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::clear_num_renegotiations($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: command result .Ve .IP "\(bu" 4 need_tmp_RSA .Sp Executes \s-1SSL_CTRL_NEED_TMP_RSA\s0 command on \f(CW$ssl\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::need_tmp_RSA($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: command result .Ve .Sp Not available with OpenSSL 1.1 and later. .IP "\(bu" 4 num_renegotiations .Sp Executes \s-1SSL_CTRL_GET_NUM_RENEGOTIATIONS\s0 command on \f(CW$ssl\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::num_renegotiations($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: command result .Ve .IP "\(bu" 4 total_renegotiations .Sp Executes \s-1SSL_CTRL_GET_TOTAL_RENEGOTIATIONS\s0 command on \f(CW$ssl\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::total_renegotiations($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: command result .Ve .IP "\(bu" 4 peek .Sp Copies \f(CW$max\fR bytes from the specified \f(CW$ssl\fR into the returned value. In contrast to the \f(CW\*(C`Net::SSLeay::read()\*(C'\fR function, the data in the \s-1SSL\s0 buffer is unmodified after the \fISSL_peek()\fR operation. .Sp .Vb 7 \& Net::SSLeay::peek($ssl, $max); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $max \- [optional] max bytes to peek (integer) \- default is 32768 \& # \& # in scalar context: data read from the TLS/SSL connection, undef on error \& # in list context: two\-item array consisting of data read (undef on error), \& # and return code from SSL_read(). .Ve .IP "\(bu" 4 pending .Sp Obtain number of readable bytes buffered in \f(CW$ssl\fR object. .Sp .Vb 4 \& my $rv = Net::SSLeay::pending($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: the number of bytes pending .Ve .Sp Check openssl doc .IP "\(bu" 4 read .Sp Tries to read \f(CW$max\fR bytes from the specified \f(CW$ssl\fR. .Sp .Vb 9 \& my $got = Net::SSLeay::read($ssl, $max); \& my($got, $rv) = Net::SSLeay::read($ssl, $max); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $max \- [optional] max bytes to read (integer) \- default is 32768 \& # \& # returns: \& # in scalar context: data read from the TLS/SSL connection, undef on error \& # in list context: two\-item array consisting of data read (undef on error), \& # and return code from SSL_read(). .Ve .Sp Check openssl doc .IP "\(bu" 4 renegotiate .Sp Turn on flags for renegotiation so that renegotiation will happen .Sp .Vb 4 \& my $rv = Net::SSLeay::renegotiate($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: 1 on success, 0 on failure .Ve .IP "\(bu" 4 rstate_string .Sp Returns a 2 letter string indicating the current read state of the \s-1SSL\s0 object \f(CW$ssl\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::rstate_string($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: 2\-letter string .Ve .Sp Check openssl doc .IP "\(bu" 4 rstate_string_long .Sp Returns a string indicating the current read state of the \s-1SSL\s0 object ssl. .Sp .Vb 4 \& my $rv = Net::SSLeay::rstate_string_long($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: string with current state .Ve .Sp Check openssl doc .IP "\(bu" 4 session_reused .Sp Query whether a reused session was negotiated during handshake. .Sp .Vb 4 \& my $rv = Net::SSLeay::session_reused($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: 0 \- new session was negotiated; 1 \- session was reused. .Ve .Sp Check openssl doc .IP "\(bu" 4 set1_param .Sp Applies X509 verification parameters \f(CW$vpm\fR on \f(CW$ssl\fR .Sp .Vb 5 \& my $rv = Net::SSLeay::set1_param($ssl, $vpm); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $vpm \- value corresponding to openssl\*(Aqs X509_VERIFY_PARAM structure \& # \& # returns: 1 on success, 0 on failure .Ve .IP "\(bu" 4 set_accept_state .Sp Sets \f(CW$ssl\fR to work in server mode. .Sp .Vb 4 \& Net::SSLeay::set_accept_state($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 set_bio .Sp Connects the BIOs \f(CW$rbio\fR and \f(CW$wbio\fR for the read and write operations of the \s-1TLS/SSL \s0(encrypted) side of \f(CW$ssl\fR. .Sp .Vb 6 \& Net::SSLeay::set_bio($ssl, $rbio, $wbio); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $rbio \- value corresponding to openssl\*(Aqs BIO structure \& # $wbio \- value corresponding to openssl\*(Aqs BIO structure \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 set_cipher_list .Sp Sets the list of ciphers only for ssl. .Sp .Vb 5 \& my $rv = Net::SSLeay::set_cipher_list($ssl, $str); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $str \- (string) cipher list e.g. \*(Aq3DES:+RSA\*(Aq \& # \& # returns: 1 if any cipher could be selected and 0 on complete failure .Ve .Sp Check openssl doc .IP "\(bu" 4 set_client_CA_list .Sp Sets the list of CAs sent to the client when requesting a client certificate for the chosen \f(CW$ssl\fR, overriding the setting valid for \f(CW$ssl\fR's \s-1SSL_CTX\s0 object. .Sp .Vb 5 \& my $rv = Net::SSLeay::set_client_CA_list($ssl, $list); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $list \- value corresponding to openssl\*(Aqs STACK_OF(X509_NAME) structure \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 set_connect_state .Sp Sets \f(CW$ssl\fR to work in client mode. .Sp .Vb 4 \& Net::SSLeay::set_connect_state($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 set_fd .Sp Sets the file descriptor \f(CW$fd\fR as the input/output facility for the \s-1TLS/SSL \s0(encrypted) side of \f(CW$ssl\fR, \f(CW$fd\fR will typically be the socket file descriptor of a network connection. .Sp .Vb 5 \& my $rv = Net::SSLeay::set_fd($ssl, $fd); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $fd \- (integer) file handle (got via perl\*(Aqs fileno) \& # \& # returns: 1 on success, 0 on failure .Ve .Sp Check openssl doc .IP "\(bu" 4 set_rfd .Sp Sets the file descriptor \f(CW$fd\fR as the input (read) facility for the \s-1TLS/SSL \s0(encrypted) side of \f(CW$ssl\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::set_rfd($ssl, $fd); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $fd \- (integer) file handle (got via perl\*(Aqs fileno) \& # \& # returns: 1 on success, 0 on failure .Ve .Sp Check openssl doc .IP "\(bu" 4 set_wfd .Sp .Vb 5 \& my $rv = Net::SSLeay::set_wfd($ssl, $fd); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $fd \- (integer) file handle (got via perl\*(Aqs fileno) \& # \& # returns: 1 on success, 0 on failure .Ve .Sp Check openssl doc .IP "\(bu" 4 set_info_callback .Sp Sets the callback function, that can be used to obtain state information for \f(CW$ssl\fR during connection setup and use. When callback is undef, the callback setting currently valid for ctx is used. .Sp .Vb 5 \& Net::SSLeay::set_info_callback($ssl, $cb, [$data]); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $cb \- sub { my ($ssl,$where,$ret,$data) = @_; ... } \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 CTX_set_info_callback .Sp 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. .Sp .Vb 5 \& Net::SSLeay::CTX_set_info_callback($ssl, $cb, [$data]); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $cb \- sub { my ($ssl,$where,$ret,$data) = @_; ... } \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 set_pref_cipher .Sp Sets the list of available ciphers for \f(CW$ssl\fR using the control string \f(CW$str\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::set_pref_cipher($ssl, $str); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $str \- (string) cipher list e.g. \*(Aq3DES:+RSA\*(Aq \& # \& # returns: 1 if any cipher could be selected and 0 on complete failure .Ve .Sp Check openssl doc .IP "\(bu" 4 set_purpose .Sp .Vb 5 \& my $rv = Net::SSLeay::set_purpose($ssl, $purpose); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $purpose \- (integer) purpose identifier \& # \& # returns: 1 on success, 0 on failure .Ve .Sp For more info about available \f(CW$purpose\fR identifiers see \*(L"CTX_set_purpose\*(R". .IP "\(bu" 4 set_quiet_shutdown .Sp Sets the 'quiet shutdown' flag for \f(CW$ssl\fR to be \f(CW$mode\fR. .Sp .Vb 5 \& Net::SSLeay::set_quiet_shutdown($ssl, $mode); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $mode \- 0 or 1 \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 set_session .Sp Set a \s-1TLS/SSL\s0 session to be used during \s-1TLS/SSL\s0 connect. .Sp .Vb 5 \& my $rv = Net::SSLeay::set_session($to, $ses); \& # $to \- value corresponding to openssl\*(Aqs SSL structure \& # $ses \- value corresponding to openssl\*(Aqs SSL_SESSION structure \& # \& # returns: 1 on success, 0 on failure .Ve .Sp Check openssl doc .IP "\(bu" 4 set_session_id_context .Sp Sets the context \f(CW$sid_ctx\fR of length \f(CW$sid_ctx_len\fR within which a session can be reused for the \f(CW$ssl\fR object. .Sp .Vb 6 \& my $rv = Net::SSLeay::set_session_id_context($ssl, $sid_ctx, $sid_ctx_len); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $sid_ctx \- data buffer \& # $sid_ctx_len \- length of data in $sid_ctx \& # \& # returns: 1 on success, 0 on failure .Ve .Sp Check openssl doc .IP "\(bu" 4 set_session_secret_cb .Sp Setup pre-shared secret session resumption function. .Sp .Vb 6 \& Net::SSLeay::set_session_secret_cb($ssl, $func, $data); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $func \- perl reference to callback function \& # $data \- [optional] data that will be passed to callback function when invoked \& # \& # returns: no return value .Ve .Sp The callback function will be called like: callback_function($secret, \f(CW$ciphers\fR, \f(CW$pref_cipher\fR, \f(CW$data\fR); .Sp # \f(CW$secret\fR is the current master session key, usually all 0s at the beginning of a session # \f(CW$ciphers\fR is ref to an array of peer cipher names # \f(CW$pref_cipher\fR is a ref to an index into the list of cipher names of # the preferred cipher. Set it if you want to specify a preferred cipher # \f(CW$data\fR is the data passed to set_session_secret_cb .Sp 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). .Sp With OpenSSL 1.1 and later, callback_function can change the master key for the session by altering \f(CW$secret\fR and returning 1. .IP "\(bu" 4 CTX_set_tlsext_ticket_getkey_cb .Sp Setup encryption for \s-1TLS\s0 session tickets (stateless session reuse). .Sp .Vb 6 \& Net::SSLeay::CTX_set_tlsext_ticket_getkey_cb($ctx, $func, $data); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $func \- perl reference to callback function \& # $data \- [optional] data that will be passed to callback function when invoked \& # \& # returns: no return value .Ve .Sp The callback function will be called like: getkey($data,[$key_name]) \-> ($key,$current_key_name) .Sp # \f(CW$data\fR is the data passed to set_session_secret_cb # \f(CW$key_name\fR is the name of the key OpenSSL has extracted from the session ticket # \f(CW$key\fR is the requested key for ticket encryption + \s-1HMAC\s0 # \f(CW$current_key_name\fR is the name for the currently valid key .Sp 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. .Sp 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. .Sp 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 \s-1AES\-128\s0 encryption while the next 16 byte are used for the \s-1SHA\-256 HMAC.\s0 The key name are binary data and must be exactly 16 byte long. .Sp Example: .Sp .Vb 4 \& Net::SSLeay::RAND_bytes(my $oldkey,32); \& Net::SSLeay::RAND_bytes(my $newkey,32); \& my $oldkey_name = pack("a16",\*(Aqoldsecret\*(Aq); \& my $newkey_name = pack("a16",\*(Aqnewsecret\*(Aq); \& \& my @keys = ( \& [ $newkey_name, $newkey ], # current active key \& [ $oldkey_name, $oldkey ], # already expired \& ); \& \& Net::SSLeay::CTX_set_tlsext_ticket_getkey_cb($server2\->_ctx, sub { \& my ($mykeys,$name) = @_; \& \& # return (current_key, current_key_name) if no name given \& return ($mykeys\->[0][1],$mykeys\->[0][0]) if ! $name; \& \& # return (matching_key, current_key_name) if we find a key matching \& # the given name \& for(my $i = 0; $i<@$mykeys; $i++) { \& next if $name ne $mykeys\->[$i][0]; \& return ($mykeys\->[$i][1],$mykeys\->[0][0]); \& } \& \& # no matching key found \& return; \& },\e@keys); .Ve .Sp 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 .IP "\(bu" 4 set_shutdown .Sp Sets the shutdown state of \f(CW$ssl\fR to \f(CW$mode\fR. .Sp .Vb 9 \& Net::SSLeay::set_shutdown($ssl, $mode); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $mode \- (integer) shutdown mode: \& # 0 \- No shutdown \& # 1 \- SSL_SENT_SHUTDOWN \& # 2 \- SSL_RECEIVED_SHUTDOWN \& # 3 \- SSL_RECEIVED_SHUTDOWN+SSL_SENT_SHUTDOWN \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 set_ssl_method .Sp Sets a new \s-1TLS/SSL\s0 method for a particular \f(CW$ssl\fR object. .Sp .Vb 5 \& my $rv = Net::SSLeay::set_ssl_method($ssl, $method); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $method \- value corresponding to openssl\*(Aqs SSL_METHOD structure \& # \& # returns: 1 on success, 0 on failure .Ve .Sp Check openssl doc .IP "\(bu" 4 set_tmp_dh .Sp Sets \s-1DH\s0 parameters to be used to be \f(CW$dh\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::set_tmp_dh($ssl, $dh); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $dh \- value corresponding to openssl\*(Aqs DH structure \& # \& # returns: 1 on success, 0 on failure .Ve .Sp Check openssl doc .IP "\(bu" 4 set_tmp_dh_callback .Sp Sets the callback function for \f(CW$ssl\fR to be used when a \s-1DH\s0 parameters are required to \f(CW$dh_cb\fR. .Sp ??? (does this function really work?) .Sp .Vb 5 \& Net::SSLeay::set_tmp_dh_callback($ssl, $dh); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $dh_cb \- pointer to function ??? \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 set_tmp_rsa .Sp Sets the temporary/ephemeral \s-1RSA\s0 key to be used in \f(CW$ssl\fR to be \f(CW$rsa\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::set_tmp_rsa($ssl, $rsa); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $rsa \- value corresponding to openssl\*(Aqs RSA structure \& # \& # returns: 1 on success, 0 on failure .Ve .Sp Example: .Sp .Vb 3 \& $rsakey = Net::SSLeay::RSA_generate_key(); \& Net::SSLeay::set_tmp_rsa($ssl, $rsakey); \& Net::SSLeay::RSA_free($rsakey); .Ve .Sp Check openssl doc .IP "\(bu" 4 set_tmp_rsa_callback .Sp Sets the callback function for \f(CW$ssl\fR to be used when a temporary/ephemeral \s-1RSA\s0 key is required to \f(CW$tmp_rsa_callback\fR. .Sp ??? (does this function really work?) .Sp .Vb 5 \& Net::SSLeay::set_tmp_rsa_callback($ssl, $tmp_rsa_callback); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $tmp_rsa_callback \- (function pointer) ??? \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 set_trust .Sp .Vb 5 \& my $rv = Net::SSLeay::set_trust($ssl, $trust); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $trust \- (integer) trust identifier \& # \& # returns: the original value .Ve .Sp For more details about \f(CW$trust\fR values see \*(L"CTX_set_trust\*(R". .IP "\(bu" 4 shutdown .Sp Shuts down an active \s-1TLS/SSL\s0 connection. It sends the 'close notify' shutdown alert to the peer. .Sp .Vb 6 \& my $rv = Net::SSLeay::shutdown($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: 1 \- shutdown was successfully completed \& # 0 \- shutdown is not yet finished, \& # \-1 \- shutdown was not successful .Ve .Sp Check openssl doc .IP "\(bu" 4 state_string .Sp Returns a 6 letter string indicating the current state of the \s-1SSL\s0 object \f(CW$ssl\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::state_string($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: 6\-letter string .Ve .Sp Check openssl doc .IP "\(bu" 4 state_string_long .Sp Returns a string indicating the current state of the \s-1SSL\s0 object \f(CW$ssl\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::state_string_long($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: state strings .Ve .Sp Check openssl doc .IP "\(bu" 4 use_PrivateKey .Sp Adds \f(CW$pkey\fR as private key to \f(CW$ssl\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::use_PrivateKey($ssl, $pkey); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $pkey \- value corresponding to openssl\*(Aqs EVP_PKEY structure \& # \& # returns: 1 on success, otherwise check out the error stack to find out the reason .Ve .Sp Check openssl doc .IP "\(bu" 4 use_PrivateKey_ASN1 .Sp Adds the private key of type \f(CW$pk\fR stored in \f(CW$data\fR to \f(CW$ssl\fR. .Sp .Vb 7 \& my $rv = Net::SSLeay::use_PrivateKey_ASN1($pk, $ssl, $d, $len); \& # $pk \- (integer) key type, NID of corresponding algorithm \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $data \- key data (binary) \& # $len \- length of $data \& # \& # returns: 1 on success, otherwise check out the error stack to find out the reason .Ve .Sp Check openssl doc .IP "\(bu" 4 use_PrivateKey_file .Sp Adds the first private key found in \f(CW$file\fR to \f(CW$ssl\fR. .Sp .Vb 6 \& my $rv = Net::SSLeay::use_PrivateKey_file($ssl, $file, $type); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $file \- (string) file name \& # $type \- (integer) type \- use constants &Net::SSLeay::FILETYPE_PEM or &Net::SSLeay::FILETYPE_ASN1 \& # \& # returns: 1 on success, otherwise check out the error stack to find out the reason .Ve .Sp Check openssl doc .IP "\(bu" 4 use_RSAPrivateKey .Sp Adds \f(CW$rsa\fR as \s-1RSA\s0 private key to \f(CW$ssl\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::use_RSAPrivateKey($ssl, $rsa); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $rsa \- value corresponding to openssl\*(Aqs RSA structure \& # \& # returns: 1 on success, otherwise check out the error stack to find out the reason .Ve .Sp Check openssl doc .IP "\(bu" 4 use_RSAPrivateKey_ASN1 .Sp Adds \s-1RSA\s0 private key stored in \f(CW$data\fR to \f(CW$ssl\fR. .Sp .Vb 6 \& my $rv = Net::SSLeay::use_RSAPrivateKey_ASN1($ssl, $data, $len); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $data \- key data (binary) \& # $len \- length of $data \& # \& # returns: 1 on success, otherwise check out the error stack to find out the reason .Ve .Sp Check openssl doc .IP "\(bu" 4 use_RSAPrivateKey_file .Sp Adds the first \s-1RSA\s0 private key found in \f(CW$file\fR to \f(CW$ssl\fR. .Sp .Vb 6 \& my $rv = Net::SSLeay::use_RSAPrivateKey_file($ssl, $file, $type); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $file \- (string) file name \& # $type \- (integer) type \- use constants &Net::SSLeay::FILETYPE_PEM or &Net::SSLeay::FILETYPE_ASN1 \& # \& # returns: 1 on success, otherwise check out the error stack to find out the reason .Ve .Sp Check openssl doc .IP "\(bu" 4 use_certificate .Sp Loads the certificate \f(CW$x\fR into \f(CW$ssl\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::use_certificate($ssl, $x); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $x \- value corresponding to openssl\*(Aqs X509 structure \& # \& # returns: 1 on success, otherwise check out the error stack to find out the reason .Ve .Sp Check openssl doc .IP "\(bu" 4 use_certificate_ASN1 .Sp Loads the \s-1ASN1\s0 encoded certificate from \f(CW$data\fR to \f(CW$ssl\fR. .Sp .Vb 6 \& my $rv = Net::SSLeay::use_certificate_ASN1($ssl, $data, $len); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $data \- certificate data (binary) \& # $len \- length of $data \& # \& # returns: 1 on success, otherwise check out the error stack to find out the reason .Ve .Sp Check openssl doc .IP "\(bu" 4 use_certificate_file .Sp Loads the first certificate stored in \f(CW$file\fR into \f(CW$ssl\fR. .Sp .Vb 6 \& my $rv = Net::SSLeay::use_certificate_file($ssl, $file, $type); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $file \- (string) file name \& # $type \- (integer) type \- use constants &Net::SSLeay::FILETYPE_PEM or &Net::SSLeay::FILETYPE_ASN1 \& # \& # returns: 1 on success, otherwise check out the error stack to find out the reason .Ve .Sp Check openssl doc .IP "\(bu" 4 version .Sp Returns \s-1SSL/TLS\s0 protocol version .Sp .Vb 8 \& my $rv = Net::SSLeay::version($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: (integer) protocol version \& # 0x0002 \- SSL2_VERSION (SSLv2) \& # 0x0300 \- SSL3_VERSION (SSLv3) \& # 0x0301 \- TLS1_VERSION (TLSv1) \& # 0xFEFF \- DTLS1_VERSION (DTLSv1) .Ve .IP "\(bu" 4 want .Sp Returns state information for the \s-1SSL\s0 object \f(CW$ssl\fR. .Sp .Vb 8 \& my $rv = Net::SSLeay::want($ssl); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: state \& # 1 \- SSL_NOTHING \& # 2 \- SSL_WRITING \& # 3 \- SSL_READING \& # 4 \- SSL_X509_LOOKUP .Ve .Sp Check openssl doc .IP "\(bu" 4 write .Sp Writes data from the buffer \f(CW$data\fR into the specified \f(CW$ssl\fR connection. .Sp .Vb 7 \& my $rv = Net::SSLeay::write($ssl, $data); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $data \- data to be written \& # \& # returns: >0 \- (success) number of bytes actually written to the TLS/SSL connection \& # 0 \- write not successful, probably the underlying connection was closed \& # <0 \- error .Ve .Sp Check openssl doc .IP "\(bu" 4 write_partial .Sp \&\fB\s-1NOTE:\s0\fR Does not exactly correspond to any low level \s-1API\s0 function .Sp Writes a fragment of data in \f(CW$data\fR from the buffer \f(CW$data\fR into the specified \f(CW$ssl\fR connection. .Sp .Vb 9 \& my $rv = Net::SSLeay::write_partial($ssl, $from, $count, $data); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $from \- (integer) offset from the beginning of $data \& # $count \- (integer) length of data to be written \& # $data \- data buffer \& # \& # returns: >0 \- (success) number of bytes actually written to the TLS/SSL connection \& # 0 \- write not successful, probably the underlying connection was closed \& # <0 \- error .Ve .IP "\(bu" 4 set_tlsext_host_name .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before; requires at least openssl\-0.9.8f .Sp Sets \s-1TLS\s0 servername extension on \s-1SLL\s0 object \f(CW$ssl\fR to value \f(CW$name\fR. .Sp .Vb 5 \& my $rv = set_tlsext_host_name($ssl, $name); \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # $name \- (string) name to be set \& # \& # returns: 1 on success, 0 on failure .Ve .PP \fILow level \s-1API:\s0 RAND_* related functions\fR .IX Subsection "Low level API: RAND_* related functions" .PP Check openssl doc related to \s-1RAND\s0 stuff .IP "\(bu" 4 RAND_add .Sp Mixes the \f(CW$num\fR bytes at \f(CW$buf\fR into the \s-1PRNG\s0 state. .Sp .Vb 6 \& Net::SSLeay::RAND_add($buf, $num, $entropy); \& # $buf \- buffer with data to be mixed into the PRNG state \& # $num \- number of bytes in $buf \& # $entropy \- estimate of how much randomness is contained in $buf (in bytes) \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 RAND_seed .Sp Equivalent to \*(L"RAND_add\*(R" when \f(CW$num\fR == \f(CW$entropy\fR. .Sp .Vb 5 \& Net::SSLeay::RAND_seed($buf); # Perlishly figures out buf size \& # $buf \- buffer with data to be mixed into the PRNG state \& # $num \- number of bytes in $buf \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 RAND_status .Sp Gives \s-1PRNG\s0 status (seeded enough or not). .Sp .Vb 2 \& my $rv = Net::SSLeay::RAND_status(); \& #returns: 1 if the PRNG has been seeded with enough data, 0 otherwise .Ve .Sp Check openssl doc .IP "\(bu" 4 RAND_bytes .Sp Puts \f(CW$num\fR cryptographically strong pseudo-random bytes into \f(CW$buf\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::RAND_bytes($buf, $num); \& # $buf \- buffer where the random data will be stored \& # $num \- the size (in bytes) of requested random data \& # \& # returns: 1 on success, 0 otherwise .Ve .Sp Check openssl doc .IP "\(bu" 4 RAND_pseudo_bytes .Sp Puts \f(CW$num\fR pseudo-random (not necessarily unpredictable) bytes into \f(CW$buf\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::RAND_pseudo_bytes($buf, $num); \& # $buf \- buffer where the random data will be stored \& # $num \- the size (in bytes) of requested random data \& # \& # returns: 1 if the bytes generated are cryptographically strong, 0 otherwise .Ve .Sp Check openssl doc .IP "\(bu" 4 RAND_cleanup .Sp Erase the \s-1PRNG\s0 state. .Sp .Vb 2 \& Net::SSLeay::RAND_cleanup(); \& # no args, no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 RAND_egd_bytes .Sp Queries the entropy gathering daemon \s-1EGD\s0 on socket \f(CW$path\fR for \f(CW$bytes\fR bytes. .Sp .Vb 5 \& my $rv = Net::SSLeay::RAND_egd_bytes($path, $bytes); \& # $path \- path to a socket of entropy gathering daemon EGD \& # $bytes \- number of bytes we want from EGD \& # \& # returns: the number of bytes read from the daemon on success, and \-1 on failure .Ve .Sp Check openssl doc .IP "\(bu" 4 RAND_file_name .Sp Generates a default path for the random seed file. .Sp .Vb 4 \& my $file = Net::SSLeay::RAND_file_name($num); \& # $num \- maximum size of returned file name \& # \& # returns: string with file name on success, \*(Aq\*(Aq (empty string) on failure .Ve .Sp Check openssl doc .IP "\(bu" 4 RAND_load_file .Sp Reads \f(CW$max_bytes\fR of bytes from \f(CW$file_name\fR and adds them to the \s-1PRNG.\s0 .Sp .Vb 5 \& my $rv = Net::SSLeay::RAND_load_file($file_name, $max_bytes); \& # $file_name \- the name of file \& # $max_bytes \- bytes to read from $file_name; \-1 => the complete file is read \& # \& # returns: the number of bytes read .Ve .Sp Check openssl doc .IP "\(bu" 4 RAND_write_file .Sp Writes 1024 random bytes to \f(CW$file_name\fR which can be used to initialize the \s-1PRNG\s0 by calling \*(L"RAND_load_file\*(R" in a later session. .Sp .Vb 4 \& my $rv = Net::SSLeay::RAND_write_file($file_name); \& # $file_name \- the name of file \& # \& # returns: the number of bytes written, and \-1 if the bytes written were generated without appropriate seed .Ve .Sp Check openssl doc .IP "\(bu" 4 RAND_poll .Sp Collects some entropy from operating system and adds it to the \s-1PRNG.\s0 .Sp .Vb 2 \& my $rv = Net::SSLeay::RAND_poll(); \& # returns: 1 on success, 0 on failure (unable to gather reasonable entropy) .Ve .PP \fILow level \s-1API:\s0 OBJ_* related functions\fR .IX Subsection "Low level API: OBJ_* related functions" .IP "\(bu" 4 OBJ_cmp .Sp Compares \s-1ASN1_OBJECT\s0 \f(CW$a\fR to \s-1ASN1_OBJECT\s0 \f(CW$b\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::OBJ_cmp($a, $b); \& # $a \- value corresponding to openssl\*(Aqs ASN1_OBJECT structure \& # $b \- value corresponding to openssl\*(Aqs ASN1_OBJECT structure \& # \& # returns: if the two are identical 0 is returned .Ve .Sp Check openssl doc .IP "\(bu" 4 OBJ_dup .Sp Returns a copy/duplicate of \f(CW$o\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::OBJ_dup($o); \& # $o \- value corresponding to openssl\*(Aqs ASN1_OBJECT structure \& # \& # returns: value corresponding to openssl\*(Aqs ASN1_OBJECT structure (0 on failure) .Ve .Sp Check openssl doc .IP "\(bu" 4 OBJ_nid2ln .Sp Returns long name for given \s-1NID\s0 \f(CW$n\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::OBJ_nid2ln($n); \& # $n \- (integer) NID \& # \& # returns: (string) long name e.g. \*(AqcommonName\*(Aq .Ve .Sp Check openssl doc .IP "\(bu" 4 OBJ_ln2nid .Sp Returns \s-1NID\s0 corresponding to given long name \f(CW$n\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::OBJ_ln2nid($s); \& # $s \- (string) long name e.g. \*(AqcommonName\*(Aq \& # \& # returns: (integer) NID .Ve .IP "\(bu" 4 OBJ_nid2sn .Sp Returns short name for given \s-1NID\s0 \f(CW$n\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::OBJ_nid2sn($n); \& # $n \- (integer) NID \& # \& # returns: (string) short name e.g. \*(AqCN\*(Aq .Ve .Sp Example: .Sp .Vb 1 \& print Net::SSLeay::OBJ_nid2sn(&Net::SSLeay::NID_commonName); .Ve .IP "\(bu" 4 OBJ_sn2nid .Sp Returns \s-1NID\s0 corresponding to given short name \f(CW$s\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::OBJ_sn2nid($s); \& # $s \- (string) short name e.g. \*(AqCN\*(Aq \& # \& # returns: (integer) NID .Ve .Sp Example: .Sp .Vb 2 \& print "NID_commonName constant=", &Net::SSLeay::NID_commonName; \& print "OBJ_sn2nid(\*(AqCN\*(Aq)=", Net::SSLeay::OBJ_sn2nid(\*(AqCN\*(Aq); .Ve .IP "\(bu" 4 OBJ_nid2obj .Sp Returns \s-1ASN1_OBJECT\s0 for given \s-1NID\s0 \f(CW$n\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::OBJ_nid2obj($n); \& # $n \- (integer) NID \& # \& # returns: value corresponding to openssl\*(Aqs ASN1_OBJECT structure (0 on failure) .Ve .Sp Check openssl doc .IP "\(bu" 4 OBJ_obj2nid .Sp Returns \s-1NID\s0 corresponding to given \s-1ASN1_OBJECT\s0 \f(CW$o\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::OBJ_obj2nid($o); \& # $o \- value corresponding to openssl\*(Aqs ASN1_OBJECT structure \& # \& # returns: (integer) NID .Ve .Sp Check openssl doc .IP "\(bu" 4 OBJ_txt2obj .Sp Converts the text string s into an \s-1ASN1_OBJECT\s0 structure. If \f(CW$no_name\fR is 0 then long names (e.g. 'commonName') and short names (e.g. '\s-1CN\s0') will be interpreted as well as numerical forms (e.g. '2.5.4.3'). If \f(CW$no_name\fR is 1 only the numerical form is acceptable. .Sp .Vb 5 \& my $rv = Net::SSLeay::OBJ_txt2obj($s, $no_name); \& # $s \- text string to be converted \& # $no_name \- (integer) 0 or 1 \& # \& # returns: value corresponding to openssl\*(Aqs ASN1_OBJECT structure (0 on failure) .Ve .Sp Check openssl doc .IP "\(bu" 4 OBJ_obj2txt .Sp Converts the \s-1ASN1_OBJECT\s0 a into a textual representation. .Sp .Vb 5 \& Net::SSLeay::OBJ_obj2txt($a, $no_name); \& # $a \- value corresponding to openssl\*(Aqs ASN1_OBJECT structure \& # $no_name \- (integer) 0 or 1 \& # \& # returns: textual representation e.g. \*(AqcommonName\*(Aq ($no_name=0), \*(Aq2.5.4.3\*(Aq ($no_name=1) .Ve .Sp Check openssl doc .IP "\(bu" 4 OBJ_txt2nid .Sp Returns \s-1NID\s0 corresponding to text string \f(CW$s\fR which can be a long name, a short name or the numerical representation of an object. .Sp .Vb 4 \& my $rv = Net::SSLeay::OBJ_txt2nid($s); \& # $s \- (string) e.g. \*(AqcommonName\*(Aq or \*(AqCN\*(Aq or \*(Aq2.5.4.3\*(Aq \& # \& # returns: (integer) NID .Ve .Sp Example: .Sp .Vb 2 \& my $nid = Net::SSLeay::OBJ_txt2nid(\*(Aq2.5.4.3\*(Aq); \& Net::SSLeay::OBJ_nid2sn($n); .Ve .Sp Check openssl doc .PP \fILow level \s-1API:\s0 ASN1_INTEGER_* related functions\fR .IX Subsection "Low level API: ASN1_INTEGER_* related functions" .IP "\(bu" 4 ASN1_INTEGER_new .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Creates a new \s-1ASN1_INTEGER\s0 structure. .Sp .Vb 3 \& my $rv = Net::SSLeay::ASN1_INTEGER_new(); \& # \& # returns: value corresponding to openssl\*(Aqs ASN1_INTEGER structure (0 on failure) .Ve .IP "\(bu" 4 ASN1_INTEGER_free .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Free an allocated \s-1ASN1_INTEGER\s0 structure. .Sp .Vb 4 \& Net::SSLeay::ASN1_INTEGER_free($i); \& # $i \- value corresponding to openssl\*(Aqs ASN1_INTEGER structure \& # \& # returns: no return value .Ve .IP "\(bu" 4 ASN1_INTEGER_get .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Returns integer value of given \s-1ASN1_INTEGER\s0 object. .Sp \&\fB\s-1BEWARE:\s0\fR If the value stored in \s-1ASN1_INTEGER\s0 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 \s-1ASN1_INTEGER\s0 values consider using \*(L"P_ASN1_INTEGER_get_dec\*(R" or \*(L"P_ASN1_INTEGER_get_hex\*(R". .Sp .Vb 4 \& my $rv = Net::SSLeay::ASN1_INTEGER_get($a); \& # $a \- value corresponding to openssl\*(Aqs ASN1_INTEGER structure \& # \& # returns: integer value of ASN1_INTEGER object in $a .Ve .IP "\(bu" 4 ASN1_INTEGER_set .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Sets value of given \s-1ASN1_INTEGER\s0 object to value \f(CW$val\fR .Sp \&\fB\s-1BEWARE:\s0\fR \f(CW$val\fR has max. limit (= max. integer that can be stored in 'long' type). For setting large \s-1ASN1_INTEGER\s0 values consider using \*(L"P_ASN1_INTEGER_set_dec\*(R" or \*(L"P_ASN1_INTEGER_set_hex\*(R". .Sp .Vb 5 \& my $rv = Net::SSLeay::ASN1_INTEGER_set($i, $val); \& # $i \- value corresponding to openssl\*(Aqs ASN1_INTEGER structure \& # $val \- integer value \& # \& # returns: 1 on success, 0 on failure .Ve .IP "\(bu" 4 P_ASN1_INTEGER_get_dec .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Returns string with decimal representation of integer value of given \s-1ASN1_INTEGER\s0 object. .Sp .Vb 4 \& Net::SSLeay::P_ASN1_INTEGER_get_dec($i); \& # $i \- value corresponding to openssl\*(Aqs ASN1_INTEGER structure \& # \& # returns: string with decimal representation .Ve .IP "\(bu" 4 P_ASN1_INTEGER_get_hex .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Returns string with hexadecimal representation of integer value of given \s-1ASN1_INTEGER\s0 object. .Sp .Vb 4 \& Net::SSLeay::P_ASN1_INTEGER_get_hex($i); \& # $i \- value corresponding to openssl\*(Aqs ASN1_INTEGER structure \& # \& # returns: string with hexadecimal representation .Ve .IP "\(bu" 4 P_ASN1_INTEGER_set_dec .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Sets value of given \s-1ASN1_INTEGER\s0 object to value \f(CW$val\fR (decimal string, suitable for large integers) .Sp .Vb 5 \& Net::SSLeay::P_ASN1_INTEGER_set_dec($i, $str); \& # $i \- value corresponding to openssl\*(Aqs ASN1_INTEGER structure \& # $str \- string with decimal representation \& # \& # returns: 1 on success, 0 on failure .Ve .IP "\(bu" 4 P_ASN1_INTEGER_set_hex .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Sets value of given \s-1ASN1_INTEGER\s0 object to value \f(CW$val\fR (hexadecimal string, suitable for large integers) .Sp .Vb 5 \& Net::SSLeay::P_ASN1_INTEGER_set_hex($i, $str); \& # $i \- value corresponding to openssl\*(Aqs ASN1_INTEGER structure \& # $str \- string with hexadecimal representation \& # \& # returns: 1 on success, 0 on failure .Ve .PP \fILow level \s-1API:\s0 ASN1_STRING_* related functions\fR .IX Subsection "Low level API: ASN1_STRING_* related functions" .IP "\(bu" 4 P_ASN1_STRING_get .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Returns string value of given \s-1ASN1_STRING\s0 object. .Sp .Vb 5 \& Net::SSLeay::P_ASN1_STRING_get($s, $utf8_decode); \& # $s \- value corresponding to openssl\*(Aqs ASN1_STRING structure \& # $utf8_decode \- [optional] 0 or 1 whether the returned value should be utf8 decoded (default=0) \& # \& # returns: string \& \& $string = Net::SSLeay::P_ASN1_STRING_get($s); \& #is the same as: \& $string = Net::SSLeay::P_ASN1_STRING_get($s, 0); .Ve .PP \fILow level \s-1API:\s0 ASN1_TIME_* related functions\fR .IX Subsection "Low level API: ASN1_TIME_* related functions" .IP "\(bu" 4 ASN1_TIME_new .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.42 and before .Sp .Vb 2 \& my $time = ASN1_TIME_new(); \& # returns: value corresponding to openssl\*(Aqs ASN1_TIME structure .Ve .IP "\(bu" 4 ASN1_TIME_free .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.42 and before .Sp .Vb 2 \& ASN1_TIME_free($time); \& # $time \- value corresponding to openssl\*(Aqs ASN1_TIME structure .Ve .IP "\(bu" 4 ASN1_TIME_set .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.42 and before .Sp .Vb 3 \& ASN1_TIME_set($time, $t); \& # $time \- value corresponding to openssl\*(Aqs ASN1_TIME structure \& # $t \- time value in seconds since 1.1.1970 .Ve .Sp \&\fB\s-1BEWARE:\s0\fR 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). .Sp If you want to safely set date and time after 2038 use function \*(L"P_ASN1_TIME_set_isotime\*(R". .IP "\(bu" 4 P_ASN1_TIME_get_isotime .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.42 and before; requires at least openssl\-0.9.7e .Sp \&\fB\s-1NOTE:\s0\fR Does not exactly correspond to any low level \s-1API\s0 function .Sp Gives \s-1ISO\-8601\s0 string representation of \s-1ASN1_TIME\s0 structure. .Sp .Vb 4 \& my $datetime_string = P_ASN1_TIME_get_isotime($time); \& # $time \- value corresponding to openssl\*(Aqs ASN1_TIME structure \& # \& # returns: datetime string like \*(Aq2033\-05\-16T20:39:37Z\*(Aq or \*(Aq\*(Aq on failure .Ve .Sp The output format is compatible with module DateTime::Format::RFC3339 .IP "\(bu" 4 P_ASN1_TIME_set_isotime .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.42 and before; requires at least openssl\-0.9.7e .Sp \&\fB\s-1NOTE:\s0\fR Does not exactly correspond to any low level \s-1API\s0 function .Sp Sets time and date value of ANS1_time structure. .Sp .Vb 5 \& my $rv = P_ASN1_TIME_set_isotime($time, $string); \& # $time \- value corresponding to openssl\*(Aqs ASN1_TIME structure \& # $string \- ISO\-8601 timedate string like \*(Aq2033\-05\-16T20:39:37Z\*(Aq \& # \& # returns: 1 on success, 0 on failure .Ve .Sp The \f(CW$string\fR parameter has to be in full form like \f(CW"2012\-03\-22T23:55:33"\fR or \&\f(CW"2012\-03\-22T23:55:33Z"\fR or \f(CW"2012\-03\-22T23:55:33CET"\fR. Short forms like \&\f(CW"2012\-03\-22T23:55"\fR or \f(CW"2012\-03\-22"\fR are not supported. .IP "\(bu" 4 P_ASN1_TIME_put2string .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.42 and before, has bugs with openssl\-0.9.8i .Sp \&\fB\s-1NOTE:\s0\fR Does not exactly correspond to any low level \s-1API\s0 function .Sp Gives string representation of \s-1ASN1_TIME\s0 structure. .Sp .Vb 4 \& my $str = P_ASN1_TIME_put2string($time); \& # $time \- value corresponding to openssl\*(Aqs ASN1_TIME structure \& # \& # returns: datetime string like \*(AqMay 16 20:39:37 2033 GMT\*(Aq .Ve .IP "\(bu" 4 P_ASN1_UTCTIME_put2string .Sp \&\fB\s-1NOTE:\s0\fR deprecated function, only for backward compatibility, just an alias for \*(L"P_ASN1_TIME_put2string\*(R" .PP \fILow level \s-1API:\s0 X509_* related functions\fR .IX Subsection "Low level API: X509_* related functions" .IP "\(bu" 4 X509_new .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Allocates and initializes a X509 structure. .Sp .Vb 3 \& my $rv = Net::SSLeay::X509_new(); \& # \& # returns: value corresponding to openssl\*(Aqs X509 structure (0 on failure) .Ve .Sp Check openssl doc .IP "\(bu" 4 X509_free .Sp Frees up the X509 structure. .Sp .Vb 4 \& Net::SSLeay::X509_free($a); \& # $a \- value corresponding to openssl\*(Aqs X509 structure \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 X509_check_host .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.68 and before; requires at least OpenSSL 1.0.2. .Sp Checks f the certificate Subject Alternative Name (\s-1SAN\s0) or Subject CommonName (\s-1CN\s0) matches the specified host name. .Sp .Vb 10 \& my $rv = Net::SSLeay::X509_check_host($cert, $name, $flags, $peername); \& # $cert \- value corresponding to openssl\*(Aqs X509 structure \& # $name \- host name to check \& # $flags (optional, default: 0) \- can be the bitwise OR of: \& # &Net::SSLeay::X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT \& # &Net::SSLeay::X509_CHECK_FLAG_NO_WILDCARDS \& # &Net::SSLeay::X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS \& # &Net::SSLeay::X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS \& # &Net::SSLeay::X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS \& # $peername (optional) \- If not omitted and $host matches $cert, \& # a copy of the matching SAN or CN from \& # the peer certificate is stored in $peername. \& # \& # returns: \& # 1 for a successful match \& # 0 for a failed match \& # \-1 for an internal error \& # \-2 if the input is malformed .Ve .Sp Check openssl doc . .IP "\(bu" 4 X509_check_email .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.68 and before; requires at least OpenSSL 1.0.2. .Sp Checks if the certificate matches the specified email address. .Sp .Vb 6 \& my $rv = Net::SSLeay::X509_check_email($cert, $address, $flags); \& # $cert \- value corresponding to openssl\*(Aqs X509 structure \& # $address \- email address to check \& # $flags (optional, default: 0) \- see X509_check_host() \& # \& # returns: see X509_check_host() .Ve .Sp Check openssl doc . .IP "\(bu" 4 X509_check_ip .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.68 and before; requires at least OpenSSL 1.0.2. .Sp Checks if the certificate matches the specified IPv4 or IPv6 address. .Sp .Vb 6 \& my $rv = Net::SSLeay::X509_check_email($cert, $address, $flags); \& # $cert \- value corresponding to openssl\*(Aqs X509 structure \& # $address \- IP address to check in binary format, in network byte order \& # $flags (optional, default: 0) \- see X509_check_host() \& # \& # returns: see X509_check_host() .Ve .Sp Check openssl doc . .IP "\(bu" 4 X509_check_ip_asc .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.68 and before; requires at least OpenSSL 1.0.2. .Sp Checks if the certificate matches the specified IPv4 or IPv6 address. .Sp .Vb 6 \& my $rv = Net::SSLeay::X509_check_email($cert, $address, $flags); \& # $cert \- value corresponding to openssl\*(Aqs X509 structure \& # $address \- IP address to check in text representation \& # $flags (optional, default: 0) \- see X509_check_host() \& # \& # returns: see X509_check_host() .Ve .Sp Check openssl doc . .IP "\(bu" 4 X509_certificate_type .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Returns bitmask with type of certificate \f(CW$x\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_certificate_type($x); \& # $x \- value corresponding to openssl\*(Aqs X509 structure \& # \& # returns: (integer) bitmask with certificate type \& \& #to decode bitmask returned by this function use these constants: \& &Net::SSLeay::EVP_PKS_DSA \& &Net::SSLeay::EVP_PKS_EC \& &Net::SSLeay::EVP_PKS_RSA \& &Net::SSLeay::EVP_PKT_ENC \& &Net::SSLeay::EVP_PKT_EXCH \& &Net::SSLeay::EVP_PKT_EXP \& &Net::SSLeay::EVP_PKT_SIGN \& &Net::SSLeay::EVP_PK_DH \& &Net::SSLeay::EVP_PK_DSA \& &Net::SSLeay::EVP_PK_EC \& &Net::SSLeay::EVP_PK_RSA .Ve .IP "\(bu" 4 X509_digest .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Computes digest/fingerprint of X509 \f(CW$data\fR using \f(CW$type\fR hash function. .Sp .Vb 5 \& my $digest_value = Net::SSLeay::X509_digest($data, $type); \& # $data \- value corresponding to openssl\*(Aqs X509 structure \& # $type \- value corresponding to openssl\*(Aqs EVP_MD structure \- e.g. got via EVP_get_digestbyname() \& # \& # returns: hash value (binary) \& \& #to get printable (hex) value of digest use: \& print unpack(\*(AqH*\*(Aq, $digest_value); .Ve .IP "\(bu" 4 X509_issuer_and_serial_hash .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Sort of a checksum of issuer name and serial number of X509 certificate \f(CW$x\fR. 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. .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_issuer_and_serial_hash($x); \& # $x \- value corresponding to openssl\*(Aqs X509 structure \& # \& # returns: number representing checksum .Ve .IP "\(bu" 4 X509_issuer_name_hash .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Sort of a checksum of issuer name of X509 certificate \f(CW$x\fR. 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. .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_issuer_name_hash($x); \& # $x \- value corresponding to openssl\*(Aqs X509 structure \& # \& # returns: number representing checksum .Ve .IP "\(bu" 4 X509_subject_name_hash .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Sort of a checksum of subject name of X509 certificate \f(CW$x\fR. 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. .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_subject_name_hash($x); \& # $x \- value corresponding to openssl\*(Aqs X509 structure \& # \& # returns: number representing checksum .Ve .IP "\(bu" 4 X509_pubkey_digest .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before; requires at least openssl\-0.9.7 .Sp Computes digest/fingerprint of public key from X509 certificate \f(CW$data\fR using \f(CW$type\fR hash function. .Sp .Vb 5 \& my $digest_value = Net::SSLeay::X509_pubkey_digest($data, $type); \& # $data \- value corresponding to openssl\*(Aqs X509 structure \& # $type \- value corresponding to openssl\*(Aqs EVP_MD structure \- e.g. got via EVP_get_digestbyname() \& # \& # returns: hash value (binary) \& \& #to get printable (hex) value of digest use: \& print unpack(\*(AqH*\*(Aq, $digest_value); .Ve .IP "\(bu" 4 X509_set_issuer_name .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Sets issuer of X509 certificate \f(CW$x\fR to \f(CW$name\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::X509_set_issuer_name($x, $name); \& # $x \- value corresponding to openssl\*(Aqs X509 structure \& # $name \- value corresponding to openssl\*(Aqs X509_NAME structure \& # \& # returns: 1 on success, 0 on failure .Ve .IP "\(bu" 4 X509_set_pubkey .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Sets public key of X509 certificate \f(CW$x\fR to \f(CW$pkey\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::X509_set_pubkey($x, $pkey); \& # $x \- value corresponding to openssl\*(Aqs X509 structure \& # $pkey \- value corresponding to openssl\*(Aqs EVP_PKEY structure \& # \& # returns: 1 on success, 0 on failure .Ve .IP "\(bu" 4 X509_set_serialNumber .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Sets serial number of X509 certificate \f(CW$x\fR to \f(CW$serial\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::X509_set_serialNumber($x, $serial); \& # $x \- value corresponding to openssl\*(Aqs X509 structure \& # $serial \- value corresponding to openssl\*(Aqs ASN1_INTEGER structure \& # \& # returns: 1 on success, 0 on failure \& \& #to create $serial value use one of these: \& $serial = Net::SSLeay::P_ASN1_INTEGER_set_hex(\*(Aq45ad6f\*(Aq); \& $serial = Net::SSLeay::P_ASN1_INTEGER_set_dec(\*(Aq7896541238529631478\*(Aq); \& $serial = Net::SSLeay::ASN1_INTEGER_set(45896); .Ve .IP "\(bu" 4 X509_set_subject_name .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Sets subject of X509 certificate \f(CW$x\fR to \f(CW$name\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::X509_set_subject_name($x, $name); \& # $x \- value corresponding to openssl\*(Aqs X509 structure \& # $name \- value corresponding to openssl\*(Aqs X509_NAME structure \& # \& # returns: 1 on success, 0 on failure .Ve .IP "\(bu" 4 X509_set_version .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Set 'version' value for X509 certificate $ to \f(CW$version\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::X509_set_version($x, $version); \& # $x \- value corresponding to openssl\*(Aqs X509 structure \& # $version \- (integer) version number \& # \& # returns: 1 on success, 0 on failure .Ve .IP "\(bu" 4 X509_sign .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Sign X509 certificate \f(CW$x\fR with private key \f(CW$pkey\fR (using digest algorithm \f(CW$md\fR). .Sp .Vb 6 \& my $rv = Net::SSLeay::X509_sign($x, $pkey, $md); \& # $x \- value corresponding to openssl\*(Aqs X509 structure \& # $pkey \- value corresponding to openssl\*(Aqs EVP_PKEY structure \& # $md \- value corresponding to openssl\*(Aqs EVP_MD structure \& # \& # returns: 1 on success, 0 on failure .Ve .IP "\(bu" 4 X509_verify .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Verifies X509 object \f(CW$a\fR using public key \f(CW$r\fR (pubkey of issuing \s-1CA\s0). .Sp .Vb 5 \& my $rv = Net::SSLeay::X509_verify($x, $r); \& # $x \- value corresponding to openssl\*(Aqs X509 structure \& # $r \- value corresponding to openssl\*(Aqs EVP_PKEY structure \& # \& # returns: 0 \- verify failure, 1 \- verify OK, <0 \- error .Ve .IP "\(bu" 4 X509_get_ext_count .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Returns the total number of extensions in X509 object \f(CW$x\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_get_ext_count($x); \& # $x \- value corresponding to openssl\*(Aqs X509 structure \& # \& # returns: count of extensions .Ve .IP "\(bu" 4 X509_get_pubkey .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Returns public key corresponding to given X509 object \f(CW$x\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_get_pubkey($x); \& # $x \- value corresponding to openssl\*(Aqs X509 structure \& # \& # returns: value corresponding to openssl\*(Aqs EVP_PKEY structure (0 on failure) .Ve .Sp \&\fB\s-1NOTE:\s0\fR This method returns only the public key's key bits, without the algorithm or parameters. Use \f(CW\*(C`X509_get_X509_PUBKEY()\*(C'\fR to return the full public key (\s-1SPKI\s0) instead. .IP "\(bu" 4 X509_get_X509_PUBKEY .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.72 and before .Sp Returns the full public key (\s-1SPKI\s0) of given X509 certificate \f(CW$x\fR. .Sp .Vb 4 \& Net::SSLeay::X509_get_X509_PUBKEY($x); \& # $x \- value corresponding to openssl\*(Aqs X509 structure \& # \& # returns: public key data in DER format (binary) .Ve .IP "\(bu" 4 X509_get_serialNumber .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Returns serial number of X509 certificate \f(CW$x\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_get_serialNumber($x); \& # $x \- value corresponding to openssl\*(Aqs X509 structure \& # \& # returns: value corresponding to openssl\*(Aqs ASN1_INTEGER structure (0 on failure) .Ve .Sp See \*(L"P_ASN1_INTEGER_get_dec\*(R", \*(L"P_ASN1_INTEGER_get_hex\*(R" or \*(L"ASN1_INTEGER_get\*(R" to decode \s-1ASN1_INTEGER\s0 object. .IP "\(bu" 4 X509_get_version .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Returns 'version' value of given X509 certificate \f(CW$x\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_get_version($x); \& # $x \- value corresponding to openssl\*(Aqs X509 structure \& # \& # returns: (integer) version .Ve .IP "\(bu" 4 X509_get_ext .Sp Returns X509_EXTENSION from \f(CW$x509\fR based on given position/index. .Sp .Vb 5 \& my $rv = Net::SSLeay::X509_get_ext($x509, $index); \& # $x509 \- value corresponding to openssl\*(Aqs X509 structure \& # $index \- (integer) position/index of extension within $x509 \& # \& # returns: value corresponding to openssl\*(Aqs X509_EXTENSION structure (0 on failure) .Ve .IP "\(bu" 4 X509_get_ext_by_NID .Sp Returns X509_EXTENSION from \f(CW$x509\fR based on given \s-1NID.\s0 .Sp .Vb 7 \& my $rv = Net::SSLeay::X509_get_ext_by_NID($x509, $nid, $loc); \& # $x509 \- value corresponding to openssl\*(Aqs X509 structure \& # $nid \- (integer) NID value \& # $loc \- (integer) position to start lookup at \& # \& # returns: position/index of extension, negative value on error \& # call Net::SSLeay::X509_get_ext($x509, $rv) to get the actual extension .Ve .IP "\(bu" 4 X509_get_fingerprint .Sp Returns fingerprint of certificate \f(CW$cert\fR. .Sp \&\fB\s-1NOTE:\s0\fR Does not exactly correspond to any low level \s-1API\s0 function. The implementation is basen on openssl's \f(CW\*(C`X509_digest()\*(C'\fR. .Sp .Vb 9 \& Net::SSLeay::X509_get_fingerprint($x509, $type); \& # $x509 \- value corresponding to openssl\*(Aqs X509 structure \& # $type \- (string) digest type, currently supported values: \& # "md5" \& # "sha1" \& # "sha256" \& # "ripemd160" \& # \& # returns: certificate digest \- hexadecimal string (NOT binary data!) .Ve .IP "\(bu" 4 X509_get_issuer_name .Sp Return an X509_NAME object representing the issuer of the certificate \f(CW$cert\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_get_issuer_name($cert); \& # $cert \- value corresponding to openssl\*(Aqs X509 structure \& # \& # returns: value corresponding to openssl\*(Aqs X509_NAME structure (0 on failure) .Ve .IP "\(bu" 4 X509_get_notAfter .Sp Return an object giving the time after which the certificate \f(CW$cert\fR is not valid. .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_get_notAfter($cert); \& # $cert \- value corresponding to openssl\*(Aqs X509 structure \& # \& # returns: value corresponding to openssl\*(Aqs ASN1_TIME structure (0 on failure) .Ve .Sp To get human readable/printable form the return value you can use: .Sp .Vb 2 \& my $time = Net::SSLeay::X509_get_notAfter($cert); \& print "notAfter=", Net::SSLeay::P_ASN1_TIME_get_isotime($time), "\en"; .Ve .IP "\(bu" 4 X509_get_notBefore .Sp Return an object giving the time before which the certificate \f(CW$cert\fR is not valid .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_get_notBefore($cert); \& # $cert \- value corresponding to openssl\*(Aqs X509 structure \& # \& # returns: value corresponding to openssl\*(Aqs ASN1_TIME structure (0 on failure) .Ve .Sp To get human readable/printable form the return value you can use: .Sp .Vb 2 \& my $time = Net::SSLeay::X509_get_notBefore($cert); \& print "notBefore=", Net::SSLeay::P_ASN1_TIME_get_isotime($time), "\en"; .Ve .IP "\(bu" 4 X509_get_subjectAltNames .Sp \&\fB\s-1NOTE:\s0\fR Does not exactly correspond to any low level \s-1API\s0 function. .Sp Returns the list of alternative subject names from X509 certificate \f(CW$cert\fR. .Sp .Vb 10 \& my @rv = Net::SSLeay::X509_get_subjectAltNames($cert); \& # $cert \- value corresponding to openssl\*(Aqs X509 structure \& # \& # returns: list containing pairs \- name_type (integer), name_value (string) \& # where name_type can be: \& # 0 \- GEN_OTHERNAME \& # 1 \- GEN_EMAIL \& # 2 \- GEN_DNS \& # 3 \- GEN_X400 \& # 4 \- GEN_DIRNAME \& # 5 \- GEN_EDIPARTY \& # 6 \- GEN_URI \& # 7 \- GEN_IPADD \& # 8 \- GEN_RID .Ve .Sp Note: type 7 \- \s-1GEN_IPADD\s0 contains the \s-1IP\s0 address as a packed binary address. .IP "\(bu" 4 X509_get_subject_name .Sp Returns the subject of the certificate \f(CW$cert\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_get_subject_name($cert); \& # $cert \- value corresponding to openssl\*(Aqs X509 structure \& # \& # returns: value corresponding to openssl\*(Aqs X509_NAME structure (0 on failure) .Ve .IP "\(bu" 4 X509_gmtime_adj .Sp Adjust th \s-1ASN1_TIME\s0 object to the timestamp (in \s-1GMT\s0). .Sp .Vb 5 \& my $rv = Net::SSLeay::X509_gmtime_adj($s, $adj); \& # $s \- value corresponding to openssl\*(Aqs ASN1_TIME structure \& # $adj \- timestamp (seconds since 1.1.1970) \& # \& # returns: value corresponding to openssl\*(Aqs ASN1_TIME structure (0 on failure) .Ve .Sp \&\fB\s-1BEWARE:\s0\fR 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\*(R" instead). .IP "\(bu" 4 X509_load_cert_crl_file .Sp Takes \s-1PEM\s0 file and loads all X509 certificates and X509 CRLs from that file into X509_LOOKUP structure. .Sp .Vb 7 \& my $rv = Net::SSLeay::X509_load_cert_crl_file($ctx, $file, $type); \& # $ctx \- value corresponding to openssl\*(Aqs X509_LOOKUP structure \& # $file \- (string) file name \& # $type \- (integer) type \- use constants &Net::SSLeay::FILETYPE_PEM or &Net::SSLeay::FILETYPE_ASN1 \& # if not FILETYPE_PEM then behaves as Net::SSLeay::X509_load_cert_file() \& # \& # returns: 1 on success, 0 on failure .Ve .IP "\(bu" 4 X509_load_cert_file .Sp Loads/adds X509 certificate from \f(CW$file\fR to X509_LOOKUP structure .Sp .Vb 6 \& my $rv = Net::SSLeay::X509_load_cert_file($ctx, $file, $type); \& # $ctx \- value corresponding to openssl\*(Aqs X509_LOOKUP structure \& # $file \- (string) file name \& # $type \- (integer) type \- use constants &Net::SSLeay::FILETYPE_PEM or &Net::SSLeay::FILETYPE_ASN1 \& # \& # returns: 1 on success, 0 on failure .Ve .IP "\(bu" 4 X509_load_crl_file .Sp Loads/adds X509 \s-1CRL\s0 from \f(CW$file\fR to X509_LOOKUP structure .Sp .Vb 6 \& my $rv = Net::SSLeay::X509_load_crl_file($ctx, $file, $type); \& # $ctx \- value corresponding to openssl\*(Aqs X509_LOOKUP structure \& # $file \- (string) file name \& # $type \- (integer) type \- use constants &Net::SSLeay::FILETYPE_PEM or &Net::SSLeay::FILETYPE_ASN1 \& # \& # returns: 1 on success, 0 on failure .Ve .IP "\(bu" 4 X509_policy_level_get0_node .Sp ??? (more info needed) .Sp .Vb 5 \& my $rv = Net::SSLeay::X509_policy_level_get0_node($level, $i); \& # $level \- value corresponding to openssl\*(Aqs X509_POLICY_LEVEL structure \& # $i \- (integer) index/position \& # \& # returns: value corresponding to openssl\*(Aqs X509_POLICY_NODE structure (0 on failure) .Ve .IP "\(bu" 4 X509_policy_level_node_count .Sp ??? (more info needed) .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_policy_level_node_count($level); \& # $level \- value corresponding to openssl\*(Aqs X509_POLICY_LEVEL structure \& # \& # returns: (integer) node count .Ve .IP "\(bu" 4 X509_policy_node_get0_parent .Sp ??? (more info needed) .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_policy_node_get0_parent($node); \& # $node \- value corresponding to openssl\*(Aqs X509_POLICY_NODE structure \& # \& # returns: value corresponding to openssl\*(Aqs X509_POLICY_NODE structure (0 on failure) .Ve .IP "\(bu" 4 X509_policy_node_get0_policy .Sp ??? (more info needed) .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_policy_node_get0_policy($node); \& # $node \- value corresponding to openssl\*(Aqs X509_POLICY_NODE structure \& # \& # returns: value corresponding to openssl\*(Aqs ASN1_OBJECT structure (0 on failure) .Ve .IP "\(bu" 4 X509_policy_node_get0_qualifiers .Sp ??? (more info needed) .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_policy_node_get0_qualifiers($node); \& # $node \- value corresponding to openssl\*(Aqs X509_POLICY_NODE structure \& # \& # returns: value corresponding to openssl\*(Aqs STACK_OF(POLICYQUALINFO) structure (0 on failure) .Ve .IP "\(bu" 4 X509_policy_tree_free .Sp ??? (more info needed) .Sp .Vb 4 \& Net::SSLeay::X509_policy_tree_free($tree); \& # $tree \- value corresponding to openssl\*(Aqs X509_POLICY_TREE structure \& # \& # returns: no return value .Ve .IP "\(bu" 4 X509_policy_tree_get0_level .Sp ??? (more info needed) .Sp .Vb 5 \& my $rv = Net::SSLeay::X509_policy_tree_get0_level($tree, $i); \& # $tree \- value corresponding to openssl\*(Aqs X509_POLICY_TREE structure \& # $i \- (integer) level index \& # \& # returns: value corresponding to openssl\*(Aqs X509_POLICY_LEVEL structure (0 on failure) .Ve .IP "\(bu" 4 X509_policy_tree_get0_policies .Sp ??? (more info needed) .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_policy_tree_get0_policies($tree); \& # $tree \- value corresponding to openssl\*(Aqs X509_POLICY_TREE structure \& # \& # returns: value corresponding to openssl\*(Aqs X509_POLICY_NODE structure (0 on failure) .Ve .IP "\(bu" 4 X509_policy_tree_get0_user_policies .Sp ??? (more info needed) .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_policy_tree_get0_user_policies($tree); \& # $tree \- value corresponding to openssl\*(Aqs X509_POLICY_TREE structure \& # \& # returns: value corresponding to openssl\*(Aqs X509_POLICY_NODE structure (0 on failure) .Ve .IP "\(bu" 4 X509_policy_tree_level_count .Sp ??? (more info needed) .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_policy_tree_level_count($tree); \& # $tree \- value corresponding to openssl\*(Aqs X509_POLICY_TREE structure \& # \& # returns: (integer) count .Ve .IP "\(bu" 4 X509_verify_cert_error_string .Sp Returns a human readable error string for verification error \f(CW$n\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_verify_cert_error_string($n); \& # $n \- (long) numeric error code \& # \& # returns: error string .Ve .Sp Check openssl doc .IP "\(bu" 4 P_X509_add_extensions .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Adds one or more X509 extensions to X509 object \f(CW$x\fR. .Sp .Vb 7 \& my $rv = Net::SSLeay::P_X509_add_extensions($x, $ca_cert, $nid, $value); \& # $x \- value corresponding to openssl\*(Aqs X509 structure \& # $ca_cert \- value corresponding to openssl\*(Aqs X509 structure (issuer\*(Aqs cert \- necessary for sertting NID_authority_key_identifier) \& # $nid \- NID identifying extension to be set \& # $value \- extension value \& # \& # returns: 1 on success, 0 on failure .Ve .Sp You can set more extensions at once: .Sp .Vb 10 \& my $rv = Net::SSLeay::P_X509_add_extensions($x509, $ca_cert, \& &Net::SSLeay::NID_key_usage => \*(AqdigitalSignature,keyEncipherment\*(Aq, \& &Net::SSLeay::NID_subject_key_identifier => \*(Aqhash\*(Aq, \& &Net::SSLeay::NID_authority_key_identifier => \*(Aqkeyid\*(Aq, \& &Net::SSLeay::NID_authority_key_identifier => \*(Aqissuer\*(Aq, \& &Net::SSLeay::NID_basic_constraints => \*(AqCA:FALSE\*(Aq, \& &Net::SSLeay::NID_ext_key_usage => \*(AqserverAuth,clientAuth\*(Aq, \& &Net::SSLeay::NID_netscape_cert_type => \*(Aqserver\*(Aq, \& &Net::SSLeay::NID_subject_alt_name => \*(AqDNS:s1.dom.com,DNS:s2.dom.com,DNS:s3.dom.com\*(Aq, \& ); .Ve .IP "\(bu" 4 P_X509_copy_extensions .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Copies X509 extensions from X509_REQ object to X509 object \- handy when you need to turn X509_REQ into X509 certificate. .Sp .Vb 6 \& Net::SSLeay::P_X509_copy_extensions($x509_req, $x509, $override); \& # $x509_req \- value corresponding to openssl\*(Aqs X509_REQ structure \& # $x509 \- value corresponding to openssl\*(Aqs X509 structure \& # $override \- (integer) flag indication whether to override already existing items in $x509 (default 1) \& # \& # returns: 1 on success, 0 on failure .Ve .IP "\(bu" 4 P_X509_get_crl_distribution_points .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before; requires at least openssl\-0.9.7 .Sp Get the list of \s-1CRL\s0 distribution points from X509 certificate. .Sp .Vb 4 \& my @cdp = Net::SSLeay::P_X509_get_crl_distribution_points($x509); \& # $x509 \- value corresponding to openssl\*(Aqs X509 structure \& # \& # returns: list of distribution points (usually URLs) .Ve .IP "\(bu" 4 P_X509_get_ext_key_usage .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before; requires at least openssl\-0.9.7 .Sp Gets the list of extended key usage of given X509 certificate \f(CW$cert\fR. .Sp .Vb 5 \& my @ext_usage = Net::SSLeay::P_X509_get_ext_key_usage($cert, $format); \& # $cert \- value corresponding to openssl\*(Aqs X509 structure \& # $format \- choose type of return values: 0=OIDs, 1=NIDs, 2=shortnames, 3=longnames \& # \& # returns: list of values .Ve .Sp Examples: .Sp .Vb 2 \& my @extkeyusage_oid = Net::SSLeay::P_X509_get_ext_key_usage($x509,0); \& # returns for example: ("1.3.6.1.5.5.7.3.1", "1.3.6.1.5.5.7.3.2") \& \& my @extkeyusage_nid = Net::SSLeay::P_X509_get_ext_key_usage($x509,1); \& # returns for example: (129, 130) \& \& my @extkeyusage_sn = Net::SSLeay::P_X509_get_ext_key_usage($x509,2); \& # returns for example: ("serverAuth", "clientAuth") \& \& my @extkeyusage_ln = Net::SSLeay::P_X509_get_ext_key_usage($x509,3); \& # returns for example: ("TLS Web Server Authentication", "TLS Web Client Authentication") .Ve .IP "\(bu" 4 P_X509_get_key_usage .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Gets the list of key usage of given X509 certificate \f(CW$cert\fR. .Sp .Vb 10 \& my @keyusage = Net::SSLeay::P_X509_get_key_usage($cert); \& # $cert \- value corresponding to openssl\*(Aqs X509 structure \& # \& # returns: list of key usage values which can be none, one or more from the following list: \& # "digitalSignature" \& # "nonRepudiation" \& # "keyEncipherment" \& # "dataEncipherment" \& # "keyAgreement" \& # "keyCertSign" \& # "cRLSign" \& # "encipherOnly" \& # "decipherOnly" .Ve .IP "\(bu" 4 P_X509_get_netscape_cert_type .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Gets the list of Netscape cert types of given X509 certificate \f(CW$cert\fR. .Sp .Vb 12 \& Net::SSLeay::P_X509_get_netscape_cert_type($cert); \& # $cert \- value corresponding to openssl\*(Aqs X509 structure \& # \& # returns: list of Netscape type values which can be none, one or more from the following list: \& # "client" \& # "server" \& # "email" \& # "objsign" \& # "reserved" \& # "sslCA" \& # "emailCA" \& # "objCA" .Ve .IP "\(bu" 4 P_X509_get_pubkey_alg .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Returns \s-1ASN1_OBJECT\s0 corresponding to X509 certificate public key algorithm. .Sp .Vb 4 \& my $rv = Net::SSLeay::P_X509_get_pubkey_alg($x); \& # $x \- value corresponding to openssl\*(Aqs X509 structure \& # \& # returns: value corresponding to openssl\*(Aqs ASN1_OBJECT structure (0 on failure) .Ve .Sp To get textual representation use: .Sp .Vb 2 \& my $alg = Net::SSLeay::OBJ_obj2txt(Net::SSLeay::P_X509_get_pubkey_alg($x509)); \& # returns for example: "rsaEncryption" .Ve .IP "\(bu" 4 P_X509_get_signature_alg .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Returns \s-1ASN1_OBJECT\s0 corresponding to X509 signarite key algorithm. .Sp .Vb 4 \& my $rv = Net::SSLeay::P_X509_get_signature_alg($x); \& # $x \- value corresponding to openssl\*(Aqs X509 structure \& # \& # returns: value corresponding to openssl\*(Aqs ASN1_OBJECT structure (0 on failure) .Ve .Sp To get textual representation use: .Sp .Vb 2 \& my $alg = Net::SSLeay::OBJ_obj2txt(Net::SSLeay::P_X509_get_signature_alg($x509)) \& # returns for example: "sha1WithRSAEncryption" .Ve .PP \fILow level \s-1API:\s0 X509_REQ_* related functions\fR .IX Subsection "Low level API: X509_REQ_* related functions" .IP "\(bu" 4 X509_REQ_new .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Creates a new X509_REQ structure. .Sp .Vb 3 \& my $rv = Net::SSLeay::X509_REQ_new(); \& # \& # returns: value corresponding to openssl\*(Aqs X509_REQ structure (0 on failure) .Ve .IP "\(bu" 4 X509_REQ_free .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Free an allocated X509_REQ structure. .Sp .Vb 4 \& Net::SSLeay::X509_REQ_free($x); \& # $x \- value corresponding to openssl\*(Aqs X509_REQ structure \& # \& # returns: no return value .Ve .IP "\(bu" 4 X509_REQ_add1_attr_by_NID .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Adds an attribute whose name is defined by a \s-1NID\s0 \f(CW$nid\fR. The field value to be added is in \f(CW$bytes\fR. .Sp .Vb 7 \& my $rv = Net::SSLeay::X509_REQ_add1_attr_by_NID($req, $nid, $type, $bytes); \& # $req \- value corresponding to openssl\*(Aqs X509_REQ structure \& # $nid \- (integer) NID value \& # $type \- (integer) type of data in $bytes (see below) \& # $bytes \- data to be set \& # \& # returns: 1 on success, 0 on failure \& \& # values for $type \- use constants: \& &Net::SSLeay::MBSTRING_UTF8 \- $bytes contains utf8 encoded data \& &Net::SSLeay::MBSTRING_ASC \- $bytes contains ASCII data .Ve .IP "\(bu" 4 X509_REQ_digest .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Computes digest/fingerprint of X509_REQ \f(CW$data\fR using \f(CW$type\fR hash function. .Sp .Vb 5 \& my $digest_value = Net::SSLeay::X509_REQ_digest($data, $type); \& # $data \- value corresponding to openssl\*(Aqs X509_REQ structure \& # $type \- value corresponding to openssl\*(Aqs EVP_MD structure \- e.g. got via EVP_get_digestbyname() \& # \& # returns: hash value (binary) \& \& #to get printable (hex) value of digest use: \& print unpack(\*(AqH*\*(Aq, $digest_value); .Ve .IP "\(bu" 4 X509_REQ_get_attr_by_NID .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Retrieve the next index matching \f(CW$nid\fR after \f(CW$lastpos\fR ($lastpos should initially be set to \-1). .Sp .Vb 6 \& my $rv = Net::SSLeay::X509_REQ_get_attr_by_NID($req, $nid, $lastpos=\-1); \& # $req \- value corresponding to openssl\*(Aqs X509_REQ structure \& # $nid \- (integer) NID value \& # $lastpos \- [optional] (integer) index where to start search (default \-1) \& # \& # returns: index (\-1 if there are no more entries) .Ve .Sp Note: use \*(L"P_X509_REQ_get_attr\*(R" to get the actual attribute value \- e.g. .Sp .Vb 2 \& my $index = Net::SSLeay::X509_REQ_get_attr_by_NID($req, $nid); \& my @attr_values = Net::SSLeay::P_X509_REQ_get_attr($req, $index); .Ve .IP "\(bu" 4 X509_REQ_get_attr_by_OBJ .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Retrieve the next index matching \f(CW$obj\fR after \f(CW$lastpos\fR ($lastpos should initially be set to \-1). .Sp .Vb 6 \& my $rv = Net::SSLeay::X509_REQ_get_attr_by_OBJ($req, $obj, $lastpos=\-1); \& # $req \- value corresponding to openssl\*(Aqs X509_REQ structure \& # $obj \- value corresponding to openssl\*(Aqs ASN1_OBJECT structure \& # $lastpos \- [optional] (integer) index where to start search (default \-1) \& # \& # returns: index (\-1 if there are no more entries) .Ve .Sp Note: use \*(L"P_X509_REQ_get_attr\*(R" to get the actual attribute value \- e.g. .Sp .Vb 2 \& my $index = Net::SSLeay::X509_REQ_get_attr_by_NID($req, $nid); \& my @attr_values = Net::SSLeay::P_X509_REQ_get_attr($req, $index); .Ve .IP "\(bu" 4 X509_REQ_get_attr_count .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Returns the total number of attributes in \f(CW$req\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_REQ_get_attr_count($req); \& # $req \- value corresponding to openssl\*(Aqs X509_REQ structure \& # \& # returns: (integer) items count .Ve .IP "\(bu" 4 X509_REQ_get_pubkey .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Returns public key corresponding to given X509_REQ object \f(CW$x\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_REQ_get_pubkey($x); \& # $x \- value corresponding to openssl\*(Aqs X509_REQ structure \& # \& # returns: value corresponding to openssl\*(Aqs EVP_PKEY structure (0 on failure) .Ve .IP "\(bu" 4 X509_REQ_get_subject_name .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Returns X509_NAME object corresponding to subject name of given X509_REQ object \f(CW$x\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_REQ_get_subject_name($x); \& # $x \- value corresponding to openssl\*(Aqs X509_REQ structure \& # \& # returns: value corresponding to openssl\*(Aqs X509_NAME structure (0 on failure) .Ve .IP "\(bu" 4 X509_REQ_get_version .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Returns 'version' value for given X509_REQ object \f(CW$x\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_REQ_get_version($x); \& # $x \- value corresponding to openssl\*(Aqs X509_REQ structure \& # \& # returns: (integer) version e.g. 0 = "version 1" .Ve .IP "\(bu" 4 X509_REQ_set_pubkey .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Sets public key of given X509_REQ object \f(CW$x\fR to \f(CW$pkey\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::X509_REQ_set_pubkey($x, $pkey); \& # $x \- value corresponding to openssl\*(Aqs X509_REQ structure \& # $pkey \- value corresponding to openssl\*(Aqs EVP_PKEY structure \& # \& # returns: 1 on success, 0 on failure .Ve .IP "\(bu" 4 X509_REQ_set_subject_name .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Sets subject name of given X509_REQ object \f(CW$x\fR to X509_NAME object \f(CW$name\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::X509_REQ_set_subject_name($x, $name); \& # $x \- value corresponding to openssl\*(Aqs X509_REQ structure \& # $name \- value corresponding to openssl\*(Aqs X509_NAME structure \& # \& # returns: 1 on success, 0 on failure .Ve .IP "\(bu" 4 X509_REQ_set_version .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Sets 'version' of given X509_REQ object \f(CW$x\fR to \f(CW$version\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::X509_REQ_set_version($x, $version); \& # $x \- value corresponding to openssl\*(Aqs X509_REQ structure \& # $version \- (integer) e.g. 0 = "version 1" \& # \& # returns: 1 on success, 0 on failure .Ve .IP "\(bu" 4 X509_REQ_sign .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Sign X509_REQ object \f(CW$x\fR with private key \f(CW$pk\fR (using digest algorithm \f(CW$md\fR). .Sp .Vb 6 \& my $rv = Net::SSLeay::X509_REQ_sign($x, $pk, $md); \& # $x \- value corresponding to openssl\*(Aqs X509_REQ structure \& # $pk \- value corresponding to openssl\*(Aqs EVP_PKEY structure (requestor\*(Aqs private key) \& # $md \- value corresponding to openssl\*(Aqs EVP_MD structure \& # \& # returns: 1 on success, 0 on failure .Ve .IP "\(bu" 4 X509_REQ_verify .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Verifies X509_REQ object \f(CW$x\fR using public key \f(CW$r\fR (pubkey of requesting party). .Sp .Vb 5 \& my $rv = Net::SSLeay::X509_REQ_verify($x, $r); \& # $x \- value corresponding to openssl\*(Aqs X509_REQ structure \& # $r \- value corresponding to openssl\*(Aqs EVP_PKEY structure \& # \& # returns: 0 \- verify failure, 1 \- verify OK, <0 \- error .Ve .IP "\(bu" 4 P_X509_REQ_add_extensions .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Adds one or more X509 extensions to X509_REQ object \f(CW$x\fR. .Sp .Vb 6 \& my $rv = Net::SSLeay::P_X509_REQ_add_extensions($x, $nid, $value); \& # $x \- value corresponding to openssl\*(Aqs X509_REQ structure \& # $nid \- NID identifying extension to be set \& # $value \- extension value \& # \& # returns: 1 on success, 0 on failure .Ve .Sp You can set more extensions at once: .Sp .Vb 8 \& my $rv = Net::SSLeay::P_X509_REQ_add_extensions($x509_req, \& &Net::SSLeay::NID_key_usage => \*(AqdigitalSignature,keyEncipherment\*(Aq, \& &Net::SSLeay::NID_basic_constraints => \*(AqCA:FALSE\*(Aq, \& &Net::SSLeay::NID_ext_key_usage => \*(AqserverAuth,clientAuth\*(Aq, \& &Net::SSLeay::NID_netscape_cert_type => \*(Aqserver\*(Aq, \& &Net::SSLeay::NID_subject_alt_name => \*(AqDNS:s1.com,DNS:s2.com\*(Aq, \& &Net::SSLeay::NID_crl_distribution_points => \*(AqURI:http://pki.com/crl1,URI:http://pki.com/crl2\*(Aq, \& ); .Ve .IP "\(bu" 4 P_X509_REQ_get_attr .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before; requires at least openssl\-0.9.7 .Sp Returns attribute value for X509_REQ's attribute at index \f(CW$n\fR. .Sp .Vb 5 \& Net::SSLeay::P_X509_REQ_get_attr($req, $n); \& # $req \- value corresponding to openssl\*(Aqs X509_REQ structure \& # $n \- (integer) attribute index \& # \& # returns: value corresponding to openssl\*(Aqs ASN1_STRING structure .Ve .PP \fILow level \s-1API:\s0 X509_CRL_* related functions\fR .IX Subsection "Low level API: X509_CRL_* related functions" .IP "\(bu" 4 X509_CRL_new .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Creates a new X509_CRL structure. .Sp .Vb 3 \& my $rv = Net::SSLeay::X509_CRL_new(); \& # \& # returns: value corresponding to openssl\*(Aqs X509_CRL structure (0 on failure) .Ve .IP "\(bu" 4 X509_CRL_free .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Free an allocated X509_CRL structure. .Sp .Vb 4 \& Net::SSLeay::X509_CRL_free($x); \& # $x \- value corresponding to openssl\*(Aqs X509_CRL structure \& # \& # returns: no return value .Ve .IP "\(bu" 4 X509_CRL_digest .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Computes digest/fingerprint of X509_CRL \f(CW$data\fR using \f(CW$type\fR hash function. .Sp .Vb 5 \& my $digest_value = Net::SSLeay::X509_CRL_digest($data, $type); \& # $data \- value corresponding to openssl\*(Aqs X509_CRL structure \& # $type \- value corresponding to openssl\*(Aqs EVP_MD structure \- e.g. got via EVP_get_digestbyname() \& # \& # returns: hash value (binary) .Ve .Sp Example: .Sp .Vb 5 \& my $x509_crl \& my $md = Net::SSLeay::EVP_get_digestbyname("sha1"); \& my $digest_value = Net::SSLeay::X509_CRL_digest($x509_crl, $md); \& #to get printable (hex) value of digest use: \& print "digest=", unpack(\*(AqH*\*(Aq, $digest_value), "\en"; .Ve .IP "\(bu" 4 X509_CRL_get_ext .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.54 and before .Sp Returns X509_EXTENSION from \f(CW$x509\fR based on given position/index. .Sp .Vb 5 \& my $rv = Net::SSLeay::X509_CRL_get_ext($x509, $index); \& # $x509 \- value corresponding to openssl\*(Aqs X509_CRL structure \& # $index \- (integer) position/index of extension within $x509 \& # \& # returns: value corresponding to openssl\*(Aqs X509_EXTENSION structure (0 on failure) .Ve .IP "\(bu" 4 X509_CRL_get_ext_by_NID .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.54 and before .Sp Returns X509_EXTENSION from \f(CW$x509\fR based on given \s-1NID.\s0 .Sp .Vb 7 \& my $rv = Net::SSLeay::X509_CRL_get_ext_by_NID($x509, $nid, $loc); \& # $x509 \- value corresponding to openssl\*(Aqs X509_CRL structure \& # $nid \- (integer) NID value \& # $loc \- (integer) position to start lookup at \& # \& # returns: position/index of extension, negative value on error \& # call Net::SSLeay::X509_CRL_get_ext($x509, $rv) to get the actual extension .Ve .IP "\(bu" 4 X509_CRL_get_ext_count .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.54 and before .Sp Returns the total number of extensions in X509_CRL object \f(CW$x\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_CRL_get_ext_count($x); \& # $x \- value corresponding to openssl\*(Aqs X509_CRL structure \& # \& # returns: count of extensions .Ve .IP "\(bu" 4 X509_CRL_get_issuer .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Returns X509_NAME object corresponding to the issuer of X509_CRL \f(CW$x\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_CRL_get_issuer($x); \& # $x \- value corresponding to openssl\*(Aqs X509_CRL structure \& # \& # returns: value corresponding to openssl\*(Aqs X509_NAME structure (0 on failure) .Ve .Sp See other \f(CW\*(C`X509_NAME_*\*(C'\fR functions to get more info from X509_NAME structure. .IP "\(bu" 4 X509_CRL_get_lastUpdate .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Returns 'lastUpdate' date-time value of X509_CRL object \f(CW$x\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_CRL_get_lastUpdate($x); \& # $x \- value corresponding to openssl\*(Aqs X509_CRL structure \& # \& # returns: value corresponding to openssl\*(Aqs ASN1_TIME structure (0 on failure) .Ve .IP "\(bu" 4 X509_CRL_get_nextUpdate .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Returns 'nextUpdate' date-time value of X509_CRL object \f(CW$x\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_CRL_get_nextUpdate($x); \& # $x \- value corresponding to openssl\*(Aqs X509_CRL structure \& # \& # returns: value corresponding to openssl\*(Aqs ASN1_TIME structure (0 on failure) .Ve .IP "\(bu" 4 X509_CRL_get_version .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Returns 'version' value of given X509_CRL structure \f(CW$x\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_CRL_get_version($x); \& # $x \- value corresponding to openssl\*(Aqs X509_CRL structure \& # \& # returns: (integer) version .Ve .IP "\(bu" 4 X509_CRL_set_issuer_name .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before; requires at least openssl\-0.9.7 .Sp Sets the issuer of X509_CRL object \f(CW$x\fR to X509_NAME object \f(CW$name\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::X509_CRL_set_issuer_name($x, $name); \& # $x \- value corresponding to openssl\*(Aqs X509_CRL structure \& # $name \- value corresponding to openssl\*(Aqs X509_NAME structure \& # \& # returns: 1 on success, 0 on failure .Ve .IP "\(bu" 4 X509_CRL_set_lastUpdate .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before; requires at least openssl\-0.9.7 .Sp Sets 'lastUpdate' value of X509_CRL object \f(CW$x\fR to \f(CW$tm\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::X509_CRL_set_lastUpdate($x, $tm); \& # $x \- value corresponding to openssl\*(Aqs X509_CRL structure \& # $tm \- value corresponding to openssl\*(Aqs ASN1_TIME structure \& # \& # returns: 1 on success, 0 on failure .Ve .IP "\(bu" 4 X509_CRL_set_nextUpdate .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before; requires at least openssl\-0.9.7 .Sp Sets 'nextUpdate' value of X509_CRL object \f(CW$x\fR to \f(CW$tm\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::X509_CRL_set_nextUpdate($x, $tm); \& # $x \- value corresponding to openssl\*(Aqs X509_CRL structure \& # $tm \- value corresponding to openssl\*(Aqs ASN1_TIME structure \& # \& # returns: 1 on success, 0 on failure .Ve .IP "\(bu" 4 X509_CRL_set_version .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before; requires at least openssl\-0.9.7 .Sp Sets 'version' value of given X509_CRL structure \f(CW$x\fR to \f(CW$version\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::X509_CRL_set_version($x, $version); \& # $x \- value corresponding to openssl\*(Aqs X509_CRL structure \& # $version \- (integer) version number (1 = version 2 CRL) \& # \& # returns: 1 on success, 0 on failure .Ve .Sp Note that if you want to use any X509_CRL extension you need to set \*(L"version 2 \s-1CRL\*(R" \- \s0\f(CW\*(C`Net::SSLeay::X509_CRL_set_version($x, 1)\*(C'\fR. .IP "\(bu" 4 X509_CRL_sign .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Sign X509_CRL object \f(CW$x\fR with private key \f(CW$pkey\fR (using digest algorithm \f(CW$md\fR). .Sp .Vb 6 \& my $rv = Net::SSLeay::X509_CRL_sign($x, $pkey, $md); \& # $x \- value corresponding to openssl\*(Aqs X509_CRL structure \& # $pkey \- value corresponding to openssl\*(Aqs EVP_PKEY structure \& # $md \- value corresponding to openssl\*(Aqs EVP_MD structure \& # \& # returns: 1 on success, 0 on failure .Ve .IP "\(bu" 4 X509_CRL_sort .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before; requires at least openssl\-0.9.7 .Sp Sorts the data of X509_CRL object so it will be written in serial number order. .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_CRL_sort($x); \& # $x \- value corresponding to openssl\*(Aqs X509_CRL structure \& # \& # returns: 1 on success, 0 on failure .Ve .IP "\(bu" 4 X509_CRL_verify .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Verifies X509_CRL object \f(CW$a\fR using public key \f(CW$r\fR (pubkey of issuing \s-1CA\s0). .Sp .Vb 5 \& my $rv = Net::SSLeay::X509_CRL_verify($a, $r); \& # $a \- value corresponding to openssl\*(Aqs X509_CRL structure \& # $r \- value corresponding to openssl\*(Aqs EVP_PKEY structure \& # \& # returns: 0 \- verify failure, 1 \- verify OK, <0 \- error .Ve .IP "\(bu" 4 P_X509_CRL_add_revoked_serial_hex .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before; requires at least openssl\-0.9.7 .Sp Adds given serial number \f(CW$serial_hex\fR to X509_CRL object \f(CW$crl\fR. .Sp .Vb 8 \& Net::SSLeay::P_X509_CRL_add_revoked_serial_hex($crl, $serial_hex, $rev_time, $reason_code, $comp_time); \& # $crl \- value corresponding to openssl\*(Aqs X509_CRL structure \& # $serial_hex \- string (hexadecimal) representation of serial number \& # $rev_time \- (revocation time) value corresponding to openssl\*(Aqs ASN1_TIME structure \& # $reason_code \- [optional] (integer) reason code (see below) \- default 0 \& # $comp_time \- [optional] (compromise time) value corresponding to openssl\*(Aqs ASN1_TIME structure \& # \& # returns: no return value \& \& reason codes: \& 0 \- unspecified \& 1 \- keyCompromise \& 2 \- CACompromise \& 3 \- affiliationChanged \& 4 \- superseded \& 5 \- cessationOfOperation \& 6 \- certificateHold \& 7 \- removeFromCRL .Ve .IP "\(bu" 4 P_X509_CRL_get_serial .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before; requires at least openssl\-0.9.7 .Sp Returns serial number of X509_CRL object. .Sp .Vb 4 \& my $rv = Net::SSLeay::P_X509_CRL_get_serial($crl); \& # $crl \- value corresponding to openssl\*(Aqs X509_CRL structure \& # \& # returns: value corresponding to openssl\*(Aqs ASN1_INTEGER structure (0 on failure) .Ve .IP "\(bu" 4 P_X509_CRL_set_serial .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before; requires at least openssl\-0.9.7 .Sp Sets serial number of X509_CRL object to \f(CW$crl_number\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::P_X509_CRL_set_serial($crl, $crl_number); \& # $crl \- value corresponding to openssl\*(Aqs X509_CRL structure \& # $crl_number \- value corresponding to openssl\*(Aqs ASN1_INTEGER structure \& # \& # returns: 1 on success, 0 on failure .Ve .PP \fILow level \s-1API:\s0 X509_EXTENSION_* related functions\fR .IX Subsection "Low level API: X509_EXTENSION_* related functions" .IP "\(bu" 4 X509_EXTENSION_get_critical .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Returns 'critical' flag of given X509_EXTENSION object \f(CW$ex\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_EXTENSION_get_critical($ex); \& # $ex \- value corresponding to openssl\*(Aqs X509_EXTENSION structure \& # \& # returns: (integer) 1 \- critical, 0 \- noncritical .Ve .IP "\(bu" 4 X509_EXTENSION_get_data .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Returns value (raw data) of X509_EXTENSION object \f(CW$ne\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_EXTENSION_get_data($ne); \& # $ne \- value corresponding to openssl\*(Aqs X509_EXTENSION structure \& # \& # returns: value corresponding to openssl\*(Aqs ASN1_OCTET_STRING structure (0 on failure) .Ve .Sp Note: you can use \*(L"P_ASN1_STRING_get\*(R" to convert \s-1ASN1_OCTET_STRING\s0 into perl scalar variable. .IP "\(bu" 4 X509_EXTENSION_get_object .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Returns \s-1OID \s0(\s-1ASN1_OBJECT\s0) of X509_EXTENSION object \f(CW$ne\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_EXTENSION_get_object($ex); \& # $ex \- value corresponding to openssl\*(Aqs X509_EXTENSION structure \& # \& # returns: value corresponding to openssl\*(Aqs ASN1_OBJECT structure (0 on failure) .Ve .IP "\(bu" 4 X509V3_EXT_print .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Returns string representation of given X509_EXTENSION object \f(CW$ext\fR. .Sp .Vb 6 \& Net::SSLeay::X509V3_EXT_print($ext, $flags, $utf8_decode); \& # $ext \- value corresponding to openssl\*(Aqs X509_EXTENSION structure \& # $flags \- [optional] (integer) Currently the flag argument is unused and should be set to 0 \& # $utf8_decode \- [optional] 0 or 1 whether the returned value should be utf8 decoded (default=0) \& # \& # returns: no return value .Ve .IP "\(bu" 4 X509V3_EXT_d2i .Sp Parses an extension and returns its internal structure. .Sp .Vb 4 \& my $rv = Net::SSLeay::X509V3_EXT_d2i($ext); \& # $ext \- value corresponding to openssl\*(Aqs X509_EXTENSION structure \& # \& # returns: pointer ??? .Ve .PP \fILow level \s-1API:\s0 X509_NAME_* related functions\fR .IX Subsection "Low level API: X509_NAME_* related functions" .IP "\(bu" 4 X509_NAME_ENTRY_get_data .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Retrieves the field value of \f(CW$ne\fR in and \s-1ASN1_STRING\s0 structure. .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_NAME_ENTRY_get_data($ne); \& # $ne \- value corresponding to openssl\*(Aqs X509_NAME_ENTRY structure \& # \& # returns: value corresponding to openssl\*(Aqs ASN1_STRING structure (0 on failure) .Ve .Sp Check openssl doc .IP "\(bu" 4 X509_NAME_ENTRY_get_object .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Retrieves the field name of \f(CW$ne\fR in and \s-1ASN1_OBJECT\s0 structure. .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_NAME_ENTRY_get_object($ne); \& # $ne \- value corresponding to openssl\*(Aqs X509_NAME_ENTRY structure \& # \& # returns: value corresponding to openssl\*(Aqs ASN1_OBJECT structure (0 on failure) .Ve .Sp Check openssl doc .IP "\(bu" 4 X509_NAME_new .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.55 and before; requires at least openssl\-0.9.5 .Sp Creates a new X509_NAME structure. Adds a field whose name is defined by a string \f(CW$field\fR. The field value to be added is in \f(CW$bytes\fR. .Sp .Vb 3 \& my $rv = Net::SSLeay::X509_NAME_new(); \& # \& # returns: value corresponding to openssl\*(Aqs X509_NAME structure (0 on failure) .Ve .IP "\(bu" 4 X509_NAME_hash .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.55 and before; requires at least openssl\-0.9.5 .Sp Sort of a checksum of issuer name \f(CW$name\fR. 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. .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_NAME_hash($name); \& # $name \- value corresponding to openssl\*(Aqs X509_NAME structure \& # \& # returns: number representing checksum .Ve .IP "\(bu" 4 X509_NAME_add_entry_by_txt .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before; requires at least openssl\-0.9.5 .Sp Adds a field whose name is defined by a string \f(CW$field\fR. The field value to be added is in \f(CW$bytes\fR. .Sp .Vb 9 \& my $rv = Net::SSLeay::X509_NAME_add_entry_by_txt($name, $field, $type, $bytes, $len, $loc, $set); \& # $name \- value corresponding to openssl\*(Aqs X509_NAME structure \& # $field \- (string) field definition (name) \- e.g. "organizationName" \& # $type \- (integer) type of data in $bytes (see below) \& # $bytes \- data to be set \& # $loc \- [optional] (integer) index where the new entry is inserted: if it is \-1 (default) it is appended \& # $set \- [optional] (integer) determines how the new type is added. If it is 0 (default) a new RDN is created \& # \& # returns: 1 on success, 0 on failure \& \& # values for $type \- use constants: \& &Net::SSLeay::MBSTRING_UTF8 \- $bytes contains utf8 encoded data \& &Net::SSLeay::MBSTRING_ASC \- $bytes contains ASCII data .Ve .Sp Unicode note: when passing non-ascii (unicode) string in \f(CW$bytes\fR do not forget to set \f(CW\*(C`$flags = &Net::SSLeay::MBSTRING_UTF8\*(C'\fR and encode the perl \f(CW$string\fR via \f(CW\*(C`$bytes = encode(\*(Aqutf\-8\*(Aq, $string)\*(C'\fR. .Sp Check openssl doc .IP "\(bu" 4 X509_NAME_add_entry_by_NID .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before; requires at least openssl\-0.9.5 .Sp Adds a field whose name is defined by a \s-1NID\s0 \f(CW$nid\fR. The field value to be added is in \f(CW$bytes\fR. .Sp .Vb 9 \& my $rv = Net::SSLeay::X509_NAME_add_entry_by_NID($name, $nid, $type, $bytes, $len, $loc, $set); \& # $name \- value corresponding to openssl\*(Aqs X509_NAME structure \& # $nid \- (integer) field definition \- NID value \& # $type \- (integer) type of data in $bytes (see below) \& # $bytes \- data to be set \& # $loc \- [optional] (integer) index where the new entry is inserted: if it is \-1 (default) it is appended \& # $set \- [optional] (integer) determines how the new type is added. If it is 0 (default) a new RDN is created \& # \& # returns: 1 on success, 0 on failure .Ve .Sp Check openssl doc .IP "\(bu" 4 X509_NAME_add_entry_by_OBJ .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before; requires at least openssl\-0.9.5 .Sp Adds a field whose name is defined by a object (\s-1OID\s0) \f(CW$obj\fR . The field value to be added is in \f(CW$bytes\fR. .Sp .Vb 9 \& my $rv = Net::SSLeay::X509_NAME_add_entry_by_OBJ($name, $obj, $type, $bytes, $len, $loc, $set); \& # $name \- value corresponding to openssl\*(Aqs X509_NAME structure \& # $obj \- field definition \- value corresponding to openssl\*(Aqs ASN1_OBJECT structure \& # $type \- (integer) type of data in $bytes (see below) \& # $bytes \- data to be set \& # $loc \- [optional] (integer) index where the new entry is inserted: if it is \-1 (default) it is appended \& # $set \- [optional] (integer) determines how the new type is added. If it is 0 (default) a new RDN is created \& # \& # returns: 1 on success, 0 on failure .Ve .Sp Check openssl doc .IP "\(bu" 4 X509_NAME_cmp .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Compares two X509_NAME obejcts. .Sp .Vb 5 \& my $rv = Net::SSLeay::X509_NAME_cmp($a, $b); \& # $a \- value corresponding to openssl\*(Aqs X509_NAME structure \& # $b \- value corresponding to openssl\*(Aqs X509_NAME structure \& # \& # returns: 0 if $a matches $b; non zero otherwise .Ve .IP "\(bu" 4 X509_NAME_digest .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Computes digest/fingerprint of X509_NAME \f(CW$data\fR using \f(CW$type\fR hash function. .Sp .Vb 5 \& my $digest_value = Net::SSLeay::X509_NAME_digest($data, $type); \& # $data \- value corresponding to openssl\*(Aqs X509_NAME structure \& # $type \- value corresponding to openssl\*(Aqs EVP_MD structure \- e.g. got via EVP_get_digestbyname() \& # \& # returns: hash value (binary) \& \& #to get printable (hex) value of digest use: \& print unpack(\*(AqH*\*(Aq, $digest_value); .Ve .IP "\(bu" 4 X509_NAME_entry_count .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Returns the total number of entries in \f(CW$name\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_NAME_entry_count($name); \& # $name \- value corresponding to openssl\*(Aqs X509_NAME structure \& # \& # returns: (integer) entries count .Ve .Sp Check openssl doc .IP "\(bu" 4 X509_NAME_get_entry .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Retrieves the X509_NAME_ENTRY from \f(CW$name\fR corresponding to index \f(CW$loc\fR. Acceptable values for \f(CW$loc\fR run from 0 to \f(CW\*(C`Net::SSLeay::X509_NAME_entry_count($name)\- 1\*(C'\fR. The value returned is an internal pointer which must not be freed. .Sp .Vb 5 \& my $rv = Net::SSLeay::X509_NAME_get_entry($name, $loc); \& # $name \- value corresponding to openssl\*(Aqs X509_NAME structure \& # $loc \- (integer) index of wanted entry \& # \& # returns: value corresponding to openssl\*(Aqs X509_NAME_ENTRY structure (0 on failure) .Ve .Sp Check openssl doc .IP "\(bu" 4 X509_NAME_print_ex .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Returns a string with human readable version of \f(CW$name\fR. .Sp .Vb 6 \& Net::SSLeay::X509_NAME_print_ex($name, $flags, $utf8_decode); \& # $name \- value corresponding to openssl\*(Aqs X509_NAME structure \& # $flags \- [optional] conversion flags (default XN_FLAG_RFC2253) \- see below \& # $utf8_decode \- [optional] 0 or 1 whether the returned value should be utf8 decoded (default=0) \& # \& # returns: string representation of $name \& \& #available conversion flags \- use constants: \& &Net::SSLeay::XN_FLAG_COMPAT \& &Net::SSLeay::XN_FLAG_DN_REV \& &Net::SSLeay::XN_FLAG_DUMP_UNKNOWN_FIELDS \& &Net::SSLeay::XN_FLAG_FN_ALIGN \& &Net::SSLeay::XN_FLAG_FN_LN \& &Net::SSLeay::XN_FLAG_FN_MASK \& &Net::SSLeay::XN_FLAG_FN_NONE \& &Net::SSLeay::XN_FLAG_FN_OID \& &Net::SSLeay::XN_FLAG_FN_SN \& &Net::SSLeay::XN_FLAG_MULTILINE \& &Net::SSLeay::XN_FLAG_ONELINE \& &Net::SSLeay::XN_FLAG_RFC2253 \& &Net::SSLeay::XN_FLAG_SEP_COMMA_PLUS \& &Net::SSLeay::XN_FLAG_SEP_CPLUS_SPC \& &Net::SSLeay::XN_FLAG_SEP_MASK \& &Net::SSLeay::XN_FLAG_SEP_MULTILINE \& &Net::SSLeay::XN_FLAG_SEP_SPLUS_SPC \& &Net::SSLeay::XN_FLAG_SPC_EQ .Ve .Sp Most likely you will be fine with default: .Sp .Vb 1 \& Net::SSLeay::X509_NAME_print_ex($name, &Net::SSLeay::XN_FLAG_RFC2253); .Ve .Sp Or you might want RFC2253\-like output without utf8 chars escaping: .Sp .Vb 3 \& 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); .Ve .Sp Check openssl doc .IP "\(bu" 4 X509_NAME_get_text_by_NID .Sp Retrieves the text from the first entry in name which matches \f(CW$nid\fR, if no such entry exists \-1 is returned. .Sp \&\fBopenssl note:\fR 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. .Sp .Vb 5 \& Net::SSLeay::X509_NAME_get_text_by_NID($name, $nid); \& # $name \- value corresponding to openssl\*(Aqs X509_NAME structure \& # $nid \- NID value (integer) \& # \& # returns: text value .Ve .Sp Check openssl doc .IP "\(bu" 4 X509_NAME_oneline .Sp Return an \s-1ASCII\s0 version of \f(CW$name\fR. .Sp .Vb 4 \& Net::SSLeay::X509_NAME_oneline($name); \& # $name \- value corresponding to openssl\*(Aqs X509_NAME structure \& # \& # returns: (string) ASCII version of $name .Ve .Sp Check openssl doc .IP "\(bu" 4 sk_X509_NAME_free .Sp Free an allocated \s-1STACK_OF\s0(X509_NAME) structure. .Sp .Vb 4 \& Net::SSLeay::sk_X509_NAME_free($sk); \& # $sk \- value corresponding to openssl\*(Aqs STACK_OF(X509_NAME) structure \& # \& # returns: no return value .Ve .IP "\(bu" 4 sk_X509_NAME_num .Sp Return number of items in \s-1STACK_OF\s0(X509_NAME) .Sp .Vb 4 \& my $rv = Net::SSLeay::sk_X509_NAME_num($sk); \& # $sk \- value corresponding to openssl\*(Aqs STACK_OF(X509_NAME) structure \& # \& # returns: number of items .Ve .IP "\(bu" 4 sk_X509_NAME_value .Sp Returns X509_NAME from position \f(CW$index\fR in \s-1STACK_OF\s0(X509_NAME) .Sp .Vb 5 \& my $rv = Net::SSLeay::sk_X509_NAME_value($sk, $i); \& # $sk \- value corresponding to openssl\*(Aqs STACK_OF(X509_NAME) structure \& # $i \- (integer) index/position \& # \& # returns: value corresponding to openssl\*(Aqs X509_NAME structure (0 on failure) .Ve .IP "\(bu" 4 add_file_cert_subjects_to_stack .Sp Add a file of certs to a stack. All certs in \f(CW$file\fR that are not already in the \f(CW$stackCAs\fR will be added. .Sp .Vb 5 \& my $rv = Net::SSLeay::add_file_cert_subjects_to_stack($stackCAs, $file); \& # $stackCAs \- value corresponding to openssl\*(Aqs STACK_OF(X509_NAME) structure \& # $file \- (string) filename \& # \& # returns: 1 on success, 0 on failure .Ve .IP "\(bu" 4 add_dir_cert_subjects_to_stack .Sp Add a directory of certs to a stack. All certs in \f(CW$dir\fR that are not already in the \f(CW$stackCAs\fR will be added. .Sp .Vb 5 \& my $rv = Net::SSLeay::add_dir_cert_subjects_to_stack($stackCAs, $dir); \& # $stackCAs \- value corresponding to openssl\*(Aqs STACK_OF(X509_NAME) structure \& # $dir \- (string) the directory to append from. All files in this directory will be examined as potential certs. Any that are acceptable to SSL_add_dir_cert_subjects_to_stack() that are not already in the stack will be included. \& # \& # returns: 1 on success, 0 on failure .Ve .PP \fILow level \s-1API:\s0 X509_STORE_* related functions\fR .IX Subsection "Low level API: X509_STORE_* related functions" .IP "\(bu" 4 X509_STORE_CTX_get_current_cert .Sp Returns the certificate in ctx which caused the error or 0 if no certificate is relevant. .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_STORE_CTX_get_current_cert($x509_store_ctx); \& # $x509_store_ctx \- value corresponding to openssl\*(Aqs X509_STORE_CTX structure \& # \& # returns: value corresponding to openssl\*(Aqs X509 structure (0 on failure) .Ve .Sp Check openssl doc .IP "\(bu" 4 X509_STORE_CTX_get_error .Sp Returns the error code of \f(CW$ctx\fR. .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_STORE_CTX_get_error($x509_store_ctx); \& # $x509_store_ctx \- value corresponding to openssl\*(Aqs X509_STORE_CTX structure \& # \& # returns: (integer) error code .Ve .Sp For more info about erro code values check function \*(L"get_verify_result\*(R". .Sp Check openssl doc .IP "\(bu" 4 X509_STORE_CTX_get_error_depth .Sp 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. .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_STORE_CTX_get_error_depth($x509_store_ctx); \& # $x509_store_ctx \- value corresponding to openssl\*(Aqs X509_STORE_CTX structure \& # \& # returns: (integer) depth .Ve .Sp Check openssl doc .IP "\(bu" 4 X509_STORE_CTX_get_ex_data .Sp Is used to retrieve the information for \f(CW$idx\fR from \f(CW$x509_store_ctx\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::X509_STORE_CTX_get_ex_data($x509_store_ctx, $idx); \& # $x509_store_ctx \- value corresponding to openssl\*(Aqs X509_STORE_CTX structure \& # $idx \- (integer) index for application specific data \& # \& # returns: pointer to ??? .Ve .IP "\(bu" 4 X509_STORE_CTX_set_ex_data .Sp Is used to store application data at arg for idx into \f(CW$x509_store_ctx\fR. .Sp .Vb 6 \& my $rv = Net::SSLeay::X509_STORE_CTX_set_ex_data($x509_store_ctx, $idx, $data); \& # $x509_store_ctx \- value corresponding to openssl\*(Aqs X509_STORE_CTX structure \& # $idx \- (integer) ??? \& # $data \- (pointer) ??? \& # \& # returns: 1 on success, 0 on failure .Ve .IP "\(bu" 4 X509_STORE_CTX_set_cert .Sp Sets the certificate to be verified in \f(CW$x509_store_ctx\fR to \f(CW$x\fR. .Sp .Vb 5 \& Net::SSLeay::X509_STORE_CTX_set_cert($x509_store_ctx, $x); \& # $x509_store_ctx \- value corresponding to openssl\*(Aqs X509_STORE_CTX structure \& # $x \- value corresponding to openssl\*(Aqs X509 structure \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 X509_STORE_CTX_set_error .Sp Sets the error code of \f(CW$ctx\fR to \f(CW$s\fR. For example it might be used in a verification callback to set an error based on additional checks. .Sp .Vb 5 \& Net::SSLeay::X509_STORE_CTX_set_error($x509_store_ctx, $s); \& # $x509_store_ctx \- value corresponding to openssl\*(Aqs X509_STORE_CTX structure \& # $s \- (integer) error id \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 X509_STORE_add_cert .Sp Adds X509 certificate \f(CW$x\fR into the X509_STORE \f(CW$store\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::X509_STORE_add_cert($store, $x); \& # $store \- value corresponding to openssl\*(Aqs X509_STORE structure \& # $x \- value corresponding to openssl\*(Aqs X509 structure \& # \& # returns: 1 on success, 0 on failure .Ve .IP "\(bu" 4 X509_STORE_add_crl .Sp Adds X509 \s-1CRL\s0 \f(CW$x\fR into the X509_STORE \f(CW$store\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::X509_STORE_add_crl($store, $x); \& # $store \- value corresponding to openssl\*(Aqs X509_STORE structure \& # $x \- value corresponding to openssl\*(Aqs X509_CRL structure \& # \& # returns: 1 on success, 0 on failure .Ve .IP "\(bu" 4 X509_STORE_set1_param .Sp ??? (more info needed) .Sp .Vb 5 \& my $rv = Net::SSLeay::X509_STORE_set1_param($store, $pm); \& # $store \- value corresponding to openssl\*(Aqs X509_STORE structure \& # $pm \- value corresponding to openssl\*(Aqs X509_VERIFY_PARAM structure \& # \& # returns: 1 on success, 0 on failure .Ve .IP "\(bu" 4 X509_STORE_set_flags .Sp .Vb 5 \& Net::SSLeay::X509_STORE_set_flags($ctx, $flags); \& # $ctx \- value corresponding to openssl\*(Aqs X509_STORE structure \& # $flags \- (unsigned long) flags to be set (bitmask) \& # \& # returns: no return value \& \& #to create $flags value use: \& 0x0001 \- X509_V_FLAG_CB_ISSUER_CHECK \- Send issuer+subject checks to verify_cb \& 0x0002 \- X509_V_FLAG_USE_CHECK_TIME \- Use check time instead of current time \& 0x0004 \- X509_V_FLAG_CRL_CHECK \- Lookup CRLs \& 0x0008 \- X509_V_FLAG_CRL_CHECK_ALL \- Lookup CRLs for whole chain \& 0x0010 \- X509_V_FLAG_IGNORE_CRITICAL \- Ignore unhandled critical extensions \& 0x0020 \- X509_V_FLAG_X509_STRICT \- Disable workarounds for broken certificates \& 0x0040 \- X509_V_FLAG_ALLOW_PROXY_CERTS \- Enable proxy certificate validation \& 0x0080 \- X509_V_FLAG_POLICY_CHECK \- Enable policy checking \& 0x0100 \- X509_V_FLAG_EXPLICIT_POLICY \- Policy variable require\-explicit\-policy \& 0x0200 \- X509_V_FLAG_INHIBIT_ANY \- Policy variable inhibit\-any\-policy \& 0x0400 \- X509_V_FLAG_INHIBIT_MAP \- Policy variable inhibit\-policy\-mapping \& 0x0800 \- X509_V_FLAG_NOTIFY_POLICY \- Notify callback that policy is OK \& 0x1000 \- X509_V_FLAG_EXTENDED_CRL_SUPPORT \- Extended CRL features such as indirect CRLs, alternate CRL signing keys \& 0x2000 \- X509_V_FLAG_USE_DELTAS \- Delta CRL support \& 0x4000 \- X509_V_FLAG_CHECK_SS_SIGNATURE \- Check selfsigned CA signature \& \& #or use corresponding constants like \& $flags = &Net::SSLeay::X509_V_FLAG_CB_ISSUER_CHECK; \& ... \& $flags = &Net::SSLeay::X509_V_FLAG_CHECK_SS_SIGNATURE; .Ve .IP "\(bu" 4 X509_STORE_set_purpose .Sp .Vb 5 \& Net::SSLeay::X509_STORE_set_purpose($ctx, $purpose); \& # $ctx \- value corresponding to openssl\*(Aqs X509_STORE structure \& # $purpose \- (integer) purpose identifier \& # \& # returns: no return value .Ve .Sp For more details about \f(CW$purpose\fR identifier check \*(L"CTX_set_purpose\*(R". .IP "\(bu" 4 X509_STORE_set_trust .Sp .Vb 5 \& Net::SSLeay::X509_STORE_set_trust($ctx, $trust); \& # $ctx \- value corresponding to openssl\*(Aqs X509_STORE structure \& # $trust \- (integer) trust identifier \& # \& # returns: no return value .Ve .Sp For more details about \f(CW$trust\fR identifier check \*(L"CTX_set_trust\*(R". .PP \fILow level \s-1API:\s0 X509_VERIFY_PARAM_* related functions\fR .IX Subsection "Low level API: X509_VERIFY_PARAM_* related functions" .IP "\(bu" 4 X509_VERIFY_PARAM_add0_policy .Sp Enables policy checking (it is disabled by default) and adds \f(CW$policy\fR to the acceptable policy set. .Sp .Vb 5 \& my $rv = Net::SSLeay::X509_VERIFY_PARAM_add0_policy($param, $policy); \& # $param \- value corresponding to openssl\*(Aqs X509_VERIFY_PARAM structure \& # $policy \- value corresponding to openssl\*(Aqs ASN1_OBJECT structure \& # \& # returns: 1 on success, 0 on failure .Ve .Sp Check openssl doc .IP "\(bu" 4 X509_VERIFY_PARAM_add0_table .Sp ??? (more info needed) .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_VERIFY_PARAM_add0_table($param); \& # $param \- value corresponding to openssl\*(Aqs X509_VERIFY_PARAM structure \& # \& # returns: 1 on success, 0 on failure .Ve .IP "\(bu" 4 X509_VERIFY_PARAM_clear_flags .Sp Clears the flags \f(CW$flags\fR in param. .Sp .Vb 5 \& my $rv = Net::SSLeay::X509_VERIFY_PARAM_clear_flags($param, $flags); \& # $param \- value corresponding to openssl\*(Aqs X509_VERIFY_PARAM structure \& # $flags \- (unsigned long) flags to be set (bitmask) \& # \& # returns: 1 on success, 0 on failure .Ve .Sp For more details about \f(CW$flags\fR bitmask see \*(L"X509_STORE_set_flags\*(R". .Sp Check openssl doc .IP "\(bu" 4 X509_VERIFY_PARAM_free .Sp Frees up the X509_VERIFY_PARAM structure. .Sp .Vb 4 \& Net::SSLeay::X509_VERIFY_PARAM_free($param); \& # $param \- value corresponding to openssl\*(Aqs X509_VERIFY_PARAM structure \& # \& # returns: no return value .Ve .IP "\(bu" 4 X509_VERIFY_PARAM_get_depth .Sp Returns the current verification depth. .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_VERIFY_PARAM_get_depth($param); \& # $param \- value corresponding to openssl\*(Aqs X509_VERIFY_PARAM structure \& # \& # returns: (ineger) depth .Ve .Sp Check openssl doc .IP "\(bu" 4 X509_VERIFY_PARAM_get_flags .Sp Returns the current verification flags. .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_VERIFY_PARAM_get_flags($param); \& # $param \- value corresponding to openssl\*(Aqs X509_VERIFY_PARAM structure \& # \& # returns: (unsigned long) flags to be set (bitmask) .Ve .Sp For more details about returned flags bitmask see \*(L"X509_STORE_set_flags\*(R". .Sp Check openssl doc .IP "\(bu" 4 X509_VERIFY_PARAM_set_flags .Sp .Vb 5 \& my $rv = Net::SSLeay::X509_VERIFY_PARAM_set_flags($param, $flags); \& # $param \- value corresponding to openssl\*(Aqs X509_VERIFY_PARAM structure \& # $flags \- (unsigned long) flags to be set (bitmask) \& # \& # returns: 1 on success, 0 on failure .Ve .Sp For more details about \f(CW$flags\fR bitmask see \*(L"X509_STORE_set_flags\*(R". .Sp Check openssl doc .IP "\(bu" 4 X509_VERIFY_PARAM_inherit .Sp ??? (more info needed) .Sp .Vb 5 \& my $rv = Net::SSLeay::X509_VERIFY_PARAM_inherit($to, $from); \& # $to \- value corresponding to openssl\*(Aqs X509_VERIFY_PARAM structure \& # $from \- value corresponding to openssl\*(Aqs X509_VERIFY_PARAM structure \& # \& # returns: 1 on success, 0 on failure .Ve .IP "\(bu" 4 X509_VERIFY_PARAM_lookup .Sp Finds X509_VERIFY_PARAM by name. .Sp .Vb 4 \& my $rv = Net::SSLeay::X509_VERIFY_PARAM_lookup($name); \& # $name \- (string) name we want to find \& # \& # returns: value corresponding to openssl\*(Aqs X509_VERIFY_PARAM structure (0 on failure) .Ve .IP "\(bu" 4 X509_VERIFY_PARAM_new .Sp Creates a new X509_VERIFY_PARAM structure. .Sp .Vb 3 \& my $rv = Net::SSLeay::X509_VERIFY_PARAM_new(); \& # \& # returns: value corresponding to openssl\*(Aqs X509_VERIFY_PARAM structure (0 on failure) .Ve .IP "\(bu" 4 X509_VERIFY_PARAM_set1 .Sp Sets the name of X509_VERIFY_PARAM structure \f(CW$to\fR to the same value as the name of X509_VERIFY_PARAM structure \f(CW$from\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::X509_VERIFY_PARAM_set1($to, $from); \& # $to \- value corresponding to openssl\*(Aqs X509_VERIFY_PARAM structure \& # $from \- value corresponding to openssl\*(Aqs X509_VERIFY_PARAM structure \& # \& # returns: 1 on success, 0 on failure .Ve .IP "\(bu" 4 X509_VERIFY_PARAM_set1_name .Sp Sets the name of X509_VERIFY_PARAM structure \f(CW$param\fR to \f(CW$name\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::X509_VERIFY_PARAM_set1_name($param, $name); \& # $param \- value corresponding to openssl\*(Aqs X509_VERIFY_PARAM structure \& # $name \- (string) name to be set \& # \& # returns: 1 on success, 0 on failure .Ve .IP "\(bu" 4 X509_VERIFY_PARAM_set1_policies .Sp 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. .Sp .Vb 5 \& my $rv = Net::SSLeay::X509_VERIFY_PARAM_set1_policies($param, $policies); \& # $param \- value corresponding to openssl\*(Aqs X509_VERIFY_PARAM structure \& # $policies \- value corresponding to openssl\*(Aqs STACK_OF(ASN1_OBJECT) structure \& # \& # returns: 1 on success, 0 on failure .Ve .Sp Check openssl doc .IP "\(bu" 4 X509_VERIFY_PARAM_set_depth .Sp Sets the maximum verification depth to depth. That is the maximum number of untrusted \s-1CA\s0 certificates that can appear in a chain. .Sp .Vb 5 \& Net::SSLeay::X509_VERIFY_PARAM_set_depth($param, $depth); \& # $param \- value corresponding to openssl\*(Aqs X509_VERIFY_PARAM structure \& # $depth \- (integer) depth to be set \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 X509_VERIFY_PARAM_set_purpose .Sp Sets the verification purpose in \f(CW$param\fR to \f(CW$purpose\fR. This determines the acceptable purpose of the certificate chain, for example \s-1SSL\s0 client or \s-1SSL\s0 server. .Sp .Vb 5 \& my $rv = Net::SSLeay::X509_VERIFY_PARAM_set_purpose($param, $purpose); \& # $param \- value corresponding to openssl\*(Aqs X509_VERIFY_PARAM structure \& # $purpose \- (integer) purpose identifier \& # \& # returns: 1 on success, 0 on failure .Ve .Sp For more details about \f(CW$purpose\fR identifier check \*(L"CTX_set_purpose\*(R". .Sp Check openssl doc .IP "\(bu" 4 X509_VERIFY_PARAM_set_time .Sp Sets the verification time in \f(CW$param\fR to \f(CW$t\fR. Normally the current time is used. .Sp .Vb 5 \& Net::SSLeay::X509_VERIFY_PARAM_set_time($param, $t); \& # $param \- value corresponding to openssl\*(Aqs X509_VERIFY_PARAM structure \& # $t \- (time_t) time in seconds since 1.1.1970 \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 X509_VERIFY_PARAM_set_trust .Sp Sets the trust setting in \f(CW$param\fR to \f(CW$trust\fR. .Sp .Vb 5 \& my $rv = Net::SSLeay::X509_VERIFY_PARAM_set_trust($param, $trust); \& # $param \- value corresponding to openssl\*(Aqs X509_VERIFY_PARAM structure \& # $trust \- (integer) trust identifier \& # \& # returns: 1 on success, 0 on failure .Ve .Sp For more details about \f(CW$trust\fR identifier check \*(L"CTX_set_trust\*(R". .Sp Check openssl doc .IP "\(bu" 4 X509_VERIFY_PARAM_table_cleanup .Sp ??? (more info needed) .Sp .Vb 3 \& Net::SSLeay::X509_VERIFY_PARAM_table_cleanup(); \& # \& # returns: no return value .Ve .PP \fILow level \s-1API:\s0 Cipher (EVP_CIPHER_*) related functions\fR .IX Subsection "Low level API: Cipher (EVP_CIPHER_*) related functions" .IP "\(bu" 4 EVP_get_cipherbyname .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before .Sp Returns an \s-1EVP_CIPHER\s0 structure when passed a cipher name. .Sp .Vb 4 \& my $rv = Net::SSLeay::EVP_get_cipherbyname($name); \& # $name \- (string) cipher name e.g. \*(Aqaes\-128\-cbc\*(Aq, \*(Aqcamellia\-256\-ecb\*(Aq, \*(Aqdes\-ede\*(Aq, ... \& # \& # returns: value corresponding to openssl\*(Aqs EVP_CIPHER structure .Ve .Sp Check openssl doc .PP \fILow level \s-1API:\s0 Digest (EVP_MD_*) related functions\fR .IX Subsection "Low level API: Digest (EVP_MD_*) related functions" .IP "\(bu" 4 OpenSSL_add_all_digests .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.42 and before .Sp .Vb 2 \& Net::SSLeay::OpenSSL_add_all_digests(); \& # no args, no return value .Ve .Sp http://www.openssl.org/docs/crypto/OpenSSL_add_all_algorithms.html .IP "\(bu" 4 P_EVP_MD_list_all .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.42 and before; requires at least openssl\-1.0.0 .Sp \&\fB\s-1NOTE:\s0\fR Does not exactly correspond to any low level \s-1API\s0 function .Sp .Vb 3 \& my $rv = Net::SSLeay::P_EVP_MD_list_all(); \& # \& # returns: arrayref \- list of available digest names .Ve .Sp The returned digest names correspond to values expected by \*(L"EVP_get_digestbyname\*(R". .Sp Note that some of the digests are available by default and some only after calling \*(L"OpenSSL_add_all_digests\*(R". .IP "\(bu" 4 EVP_get_digestbyname .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.42 and before .Sp .Vb 4 \& my $rv = Net::SSLeay::EVP_get_digestbyname($name); \& # $name \- string with digest name \& # \& # returns: value corresponding to openssl\*(Aqs EVP_MD structure .Ve .Sp The \f(CW$name\fR param can be: .Sp .Vb 11 \& md2 \& md4 \& md5 \& mdc2 \& ripemd160 \& sha \& sha1 \& sha224 \& sha256 \& sha512 \& whirlpool .Ve .Sp Or better check the supported digests by calling \*(L"P_EVP_MD_list_all\*(R". .IP "\(bu" 4 EVP_MD_type .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.42 and before .Sp .Vb 4 \& my $rv = Net::SSLeay::EVP_MD_type($md); \& # $md \- value corresponding to openssl\*(Aqs EVP_MD structure \& # \& # returns: the NID (integer) of the OBJECT IDENTIFIER representing the given message digest .Ve .IP "\(bu" 4 EVP_MD_size .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.42 and before .Sp .Vb 4 \& my $rv = Net::SSLeay::EVP_MD_size($md); \& # $md \- value corresponding to openssl\*(Aqs EVP_MD structure \& # \& # returns: the size of the message digest in bytes (e.g. 20 for SHA1) .Ve .IP "\(bu" 4 EVP_MD_CTX_md .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.42 and before; requires at least openssl\-0.9.7 .Sp .Vb 4 \& Net::SSLeay::EVP_MD_CTX_md($ctx); \& # $ctx \- value corresponding to openssl\*(Aqs EVP_MD_CTX structure \& # \& # returns: value corresponding to openssl\*(Aqs EVP_MD structure .Ve .IP "\(bu" 4 EVP_MD_CTX_create .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.42 and before; requires at least openssl\-0.9.7 .Sp Allocates, initializes and returns a digest context. .Sp .Vb 3 \& my $rv = Net::SSLeay::EVP_MD_CTX_create(); \& # \& # returns: value corresponding to openssl\*(Aqs EVP_MD_CTX structure .Ve .Sp The complete idea behind \s-1EVP_MD_CTX\s0 looks like this example: .Sp .Vb 1 \& 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(\*(AqH*\*(Aq, $result), "\en"; #print hex value .Ve .IP "\(bu" 4 EVP_DigestInit_ex .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.42 and before; requires at least openssl\-0.9.7 .Sp Sets up digest context \f(CW$ctx\fR to use a digest \f(CW$type\fR from \s-1ENGINE\s0 \f(CW$impl\fR, \f(CW$ctx\fR must be initialized before calling this function, type will typically be supplied by a function such as \*(L"EVP_get_digestbyname\*(R". If \f(CW$impl\fR is 0 then the default implementation of digest \f(CW$type\fR is used. .Sp .Vb 6 \& my $rv = Net::SSLeay::EVP_DigestInit_ex($ctx, $type, $impl); \& # $ctx \- value corresponding to openssl\*(Aqs EVP_MD_CTX structure \& # $type \- value corresponding to openssl\*(Aqs EVP_MD structure \& # $impl \- value corresponding to openssl\*(Aqs ENGINE structure \& # \& # returns: 1 for success and 0 for failure .Ve .IP "\(bu" 4 EVP_DigestInit .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.42 and before; requires at least openssl\-0.9.7 .Sp Behaves in the same way as \*(L"EVP_DigestInit_ex\*(R" except the passed context \f(CW$ctx\fR does not have to be initialized, and it always uses the default digest implementation. .Sp .Vb 5 \& my $rv = Net::SSLeay::EVP_DigestInit($ctx, $type); \& # $ctx \- value corresponding to openssl\*(Aqs EVP_MD_CTX structure \& # $type \- value corresponding to openssl\*(Aqs EVP_MD structure \& # \& # returns: 1 for success and 0 for failure .Ve .IP "\(bu" 4 EVP_MD_CTX_destroy .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.42 and before; requires at least openssl\-0.9.7 .Sp Cleans up digest context \f(CW$ctx\fR and frees up the space allocated to it, it should be called only on a context created using \*(L"EVP_MD_CTX_create\*(R". .Sp .Vb 4 \& Net::SSLeay::EVP_MD_CTX_destroy($ctx); \& # $ctx \- value corresponding to openssl\*(Aqs EVP_MD_CTX structure \& # \& # returns: no return value .Ve .IP "\(bu" 4 EVP_DigestUpdate .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.42 and before; requires at least openssl\-0.9.7 .Sp .Vb 5 \& my $rv = Net::SSLeay::EVP_DigestUpdate($ctx, $data); \& # $ctx \- value corresponding to openssl\*(Aqs EVP_MD_CTX structure \& # $data \- data to be hashed \& # \& # returns: 1 for success and 0 for failure .Ve .IP "\(bu" 4 EVP_DigestFinal_ex .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.42 and before; requires at least openssl\-0.9.7 .Sp Retrieves the digest value from \f(CW$ctx\fR. After calling \*(L"EVP_DigestFinal_ex\*(R" no additional calls to \*(L"EVP_DigestUpdate\*(R" can be made, but \&\*(L"EVP_DigestInit_ex\*(R" can be called to initialize a new digest operation. .Sp .Vb 4 \& my $digest_value = Net::SSLeay::EVP_DigestFinal_ex($ctx); \& # $ctx \- value corresponding to openssl\*(Aqs EVP_MD_CTX structure \& # \& # returns: hash value (binary) \& \& #to get printable (hex) value of digest use: \& print unpack(\*(AqH*\*(Aq, $digest_value); .Ve .IP "\(bu" 4 EVP_DigestFinal .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.42 and before; requires at least openssl\-0.9.7 .Sp Similar to \*(L"EVP_DigestFinal_ex\*(R" except the digest context ctx is automatically cleaned up. .Sp .Vb 4 \& my $rv = Net::SSLeay::EVP_DigestFinal($ctx); \& # $ctx \- value corresponding to openssl\*(Aqs EVP_MD_CTX structure \& # \& # returns: hash value (binary) \& \& #to get printable (hex) value of digest use: \& print unpack(\*(AqH*\*(Aq, $digest_value); .Ve .IP "\(bu" 4 \&\s-1MD2\s0 .Sp \&\fB\s-1COMPATIBILITY:\s0\fR no supported by default in openssl\-1.0.0 .Sp Computes \s-1MD2\s0 from given \f(CW$data\fR (all data needs to be loaded into memory) .Sp .Vb 2 \& my $digest = Net::SSLeay::MD2($data); \& print "digest(hexadecimal)=", unpack(\*(AqH*\*(Aq, $digest); .Ve .IP "\(bu" 4 \&\s-1MD4\s0 .Sp Computes \s-1MD4\s0 from given \f(CW$data\fR (all data needs to be loaded into memory) .Sp .Vb 2 \& my $digest = Net::SSLeay::MD4($data); \& print "digest(hexadecimal)=", unpack(\*(AqH*\*(Aq, $digest); .Ve .IP "\(bu" 4 \&\s-1MD5\s0 .Sp Computes \s-1MD5\s0 from given \f(CW$data\fR (all data needs to be loaded into memory) .Sp .Vb 2 \& my $digest = Net::SSLeay::MD5($data); \& print "digest(hexadecimal)=", unpack(\*(AqH*\*(Aq, $digest); .Ve .IP "\(bu" 4 \&\s-1RIPEMD160\s0 .Sp Computes \s-1RIPEMD160\s0 from given \f(CW$data\fR (all data needs to be loaded into memory) .Sp .Vb 2 \& my $digest = Net::SSLeay::RIPEMD160($data); \& print "digest(hexadecimal)=", unpack(\*(AqH*\*(Aq, $digest); .Ve .IP "\(bu" 4 \&\s-1SHA1\s0 .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.42 and before .Sp Computes \s-1SHA1\s0 from given \f(CW$data\fR (all data needs to be loaded into memory) .Sp .Vb 2 \& my $digest = Net::SSLeay::SHA1($data); \& print "digest(hexadecimal)=", unpack(\*(AqH*\*(Aq, $digest); .Ve .IP "\(bu" 4 \&\s-1SHA256\s0 .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.42 and before; requires at least openssl\-0.9.8 .Sp Computes \s-1SHA256\s0 from given \f(CW$data\fR (all data needs to be loaded into memory) .Sp .Vb 2 \& my $digest = Net::SSLeay::SHA256($data); \& print "digest(hexadecimal)=", unpack(\*(AqH*\*(Aq, $digest); .Ve .IP "\(bu" 4 \&\s-1SHA512\s0 .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.42 and before; requires at least openssl\-0.9.8 .Sp Computes \s-1SHA512\s0 from given \f(CW$data\fR (all data needs to be loaded into memory) .Sp .Vb 2 \& my $digest = Net::SSLeay::SHA512($data); \& print "digest(hexadecimal)=", unpack(\*(AqH*\*(Aq, $digest); .Ve .IP "\(bu" 4 EVP_Digest .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.42 and before; requires at least openssl\-0.9.7 .Sp Computes \*(L"any\*(R" digest from given \f(CW$data\fR (all data needs to be loaded into memory) .Sp .Vb 3 \& my $md = Net::SSLeay::EVP_get_digestbyname("sha1"); #or any other algorithm \& my $digest = Net::SSLeay::EVP_Digest($data, $md); \& print "digest(hexadecimal)=", unpack(\*(AqH*\*(Aq, $digest); .Ve .IP "\(bu" 4 EVP_sha1 .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.42 and before .Sp .Vb 3 \& my $md = Net::SSLeay::EVP_sha1(); \& # \& # returns: value corresponding to openssl\*(Aqs EVP_MD structure .Ve .IP "\(bu" 4 EVP_sha256 .Sp \&\fB\s-1COMPATIBILITY:\s0\fR requires at least openssl\-0.9.8 .Sp .Vb 3 \& my $md = Net::SSLeay::EVP_sha256(); \& # \& # returns: value corresponding to openssl\*(Aqs EVP_MD structure .Ve .IP "\(bu" 4 EVP_sha512 .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.42 and before; requires at least openssl\-0.9.8 .Sp .Vb 3 \& my $md = Net::SSLeay::EVP_sha512(); \& # \& # returns: value corresponding to openssl\*(Aqs EVP_MD structure .Ve .IP "\(bu" 4 EVP_add_digest .Sp .Vb 4 \& my $rv = Net::SSLeay::EVP_add_digest($digest); \& # $digest \- value corresponding to openssl\*(Aqs EVP_MD structure \& # \& # returns: 1 on success, 0 otherwise .Ve .PP \fILow level \s-1API:\s0 CIPHER_* related functions\fR .IX Subsection "Low level API: CIPHER_* related functions" .IP "\(bu" 4 CIPHER_get_name .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.42 and before .Sp Returns name of the cipher used. .Sp .Vb 4 \& my $rv = Net::SSLeay::CIPHER_description($cipher); \& # $cipher \- value corresponding to openssl\*(Aqs SSL_CIPHER structure \& # \& # returns: (string) cipher name e.g. \*(AqDHE\-RSA\-AES256\-SHA\*(Aq .Ve .Sp Check openssl doc .Sp Example: .Sp .Vb 2 \& my $ssl_cipher = Net::SSLeay::get_current_cipher($ssl); \& my $cipher_name = Net::SSLeay::CIPHER_get_name($ssl_cipher); .Ve .IP "\(bu" 4 CIPHER_description .Sp Returns a textual description of the cipher used. .Sp ??? (does this function really work?) .Sp .Vb 6 \& my $rv = Net::SSLeay::CIPHER_description($cipher, $buf, $size); \& # $cipher \- value corresponding to openssl\*(Aqs SSL_CIPHER structure \& # $bufer \- (string/buffer) ??? \& # $size \- (integer) ??? \& # \& # returns: (string) cipher description e.g. \*(AqDHE\-RSA\-AES256\-SHA SSLv3 Kx=DH Au=RSA Enc=AES(256) Mac=SHA1\*(Aq .Ve .Sp Check openssl doc .IP "\(bu" 4 CIPHER_get_bits .Sp Returns the number of secret bits used for cipher. .Sp .Vb 4 \& my $rv = Net::SSLeay::CIPHER_get_bits($c); \& # $c \- value corresponding to openssl\*(Aqs SSL_CIPHER structure \& # \& # returns: (integert) number of secret bits, 0 on error .Ve .Sp Check openssl doc .PP \fILow level \s-1API:\s0 RSA_* related functions\fR .IX Subsection "Low level API: RSA_* related functions" .IP "\(bu" 4 RSA_generate_key .Sp Generates a key pair and returns it in a newly allocated \s-1RSA\s0 structure. The pseudo-random number generator must be seeded prior to calling RSA_generate_key. .Sp .Vb 7 \& my $rv = Net::SSLeay::RSA_generate_key($bits, $e, $perl_cb, $perl_cb_arg); \& # $bits \- (integer) modulus size in bits e.g. 512, 1024, 2048 \& # $e \- (integer) public exponent, an odd number, typically 3, 17 or 65537 \& # $perl_cb \- [optional] reference to perl callback function \& # $perl_cb_arg \- [optional] data that will be passed to callback function when invoked \& # \& # returns: value corresponding to openssl\*(Aqs RSA structure (0 on failure) .Ve .Sp Check openssl doc .IP "\(bu" 4 RSA_free .Sp Frees the \s-1RSA\s0 structure and its components. The key is erased before the memory is returned to the system. .Sp .Vb 4 \& Net::SSLeay::RSA_free($r); \& # $r \- value corresponding to openssl\*(Aqs RSA structure \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 RSA_get_key_parameters .Sp Returns a list of pointers to BIGNUMs representing the parameters of the key in this order: (n, e, d, p, q, dmp1, dmq1, iqmp) Caution: returned list consists of \s-1SV\s0 pointers to BIGNUMs, which would need to be blessed as Crypt::OpenSSL::Bignum for further use .Sp my (@params) = RSA_get_key_parameters($r); .PP \fILow level \s-1API:\s0 BIO_* related functions\fR .IX Subsection "Low level API: BIO_* related functions" .IP "\(bu" 4 BIO_eof .Sp Returns 1 if the \s-1BIO\s0 has read \s-1EOF,\s0 the precise meaning of '\s-1EOF\s0' varies according to the \s-1BIO\s0 type. .Sp .Vb 4 \& my $rv = Net::SSLeay::BIO_eof($s); \& # $s \- value corresponding to openssl\*(Aqs BIO structure \& # \& # returns: 1 if EOF has been reached 0 otherwise .Ve .Sp Check openssl doc .IP "\(bu" 4 BIO_f_ssl .Sp Returns the \s-1SSL BIO\s0 method. This is a filter \s-1BIO\s0 which is a wrapper round the OpenSSL \s-1SSL\s0 routines adding a \s-1BIO \s0'flavour' to \s-1SSL I/O.\s0 .Sp .Vb 3 \& my $rv = Net::SSLeay::BIO_f_ssl(); \& # \& # returns: value corresponding to openssl\*(Aqs BIO_METHOD structure (0 on failure) .Ve .Sp Check openssl doc .IP "\(bu" 4 BIO_free .Sp Frees up a single \s-1BIO.\s0 .Sp .Vb 4 \& my $rv = Net::SSLeay::BIO_free($bio;); \& # $bio; \- value corresponding to openssl\*(Aqs BIO structure \& # \& # returns: 1 on success, 0 on failure .Ve .Sp Check openssl doc .IP "\(bu" 4 BIO_new .Sp Returns a new \s-1BIO\s0 using method \f(CW$type\fR .Sp .Vb 4 \& my $rv = Net::SSLeay::BIO_new($type); \& # $type \- value corresponding to openssl\*(Aqs BIO_METHOD structure \& # \& # returns: value corresponding to openssl\*(Aqs BIO structure (0 on failure) .Ve .Sp Check openssl doc .IP "\(bu" 4 BIO_new_buffer_ssl_connect .Sp Creates a new \s-1BIO\s0 chain consisting of a buffering \s-1BIO,\s0 an \s-1SSL BIO \s0(using ctx) and a connect \s-1BIO.\s0 .Sp .Vb 4 \& my $rv = Net::SSLeay::BIO_new_buffer_ssl_connect($ctx); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # \& # returns: value corresponding to openssl\*(Aqs BIO structure (0 on failure) .Ve .Sp Check openssl doc .IP "\(bu" 4 BIO_new_file .Sp Creates a new file \s-1BIO\s0 with mode \f(CW$mode\fR the meaning of mode is the same as the stdio function \fIfopen()\fR. The \s-1BIO_CLOSE\s0 flag is set on the returned \s-1BIO.\s0 .Sp .Vb 5 \& my $rv = Net::SSLeay::BIO_new_file($filename, $mode); \& # $filename \- (string) filename \& # $mode \- (string) opening mode (as mode by stdio function fopen) \& # \& # returns: value corresponding to openssl\*(Aqs BIO structure (0 on failure) .Ve .Sp Check openssl doc .IP "\(bu" 4 BIO_new_ssl .Sp Allocates an \s-1SSL BIO\s0 using \s-1SSL_CTX\s0 ctx and using client mode if client is non zero. .Sp .Vb 5 \& my $rv = Net::SSLeay::BIO_new_ssl($ctx, $client); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $client \- (integer) 0 or 1 \- indicates ssl client mode \& # \& # returns: value corresponding to openssl\*(Aqs BIO structure (0 on failure) .Ve .Sp Check openssl doc .IP "\(bu" 4 BIO_new_ssl_connect .Sp Creates a new \s-1BIO\s0 chain consisting of an \s-1SSL BIO \s0(using ctx) followed by a connect \s-1BIO.\s0 .Sp .Vb 4 \& my $rv = Net::SSLeay::BIO_new_ssl_connect($ctx); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # \& # returns: value corresponding to openssl\*(Aqs BIO structure (0 on failure) .Ve .Sp Check openssl doc .IP "\(bu" 4 BIO_pending .Sp Return the number of pending characters in the BIOs read buffers. .Sp .Vb 4 \& my $rv = Net::SSLeay::BIO_pending($s); \& # $s \- value corresponding to openssl\*(Aqs BIO structure \& # \& # returns: the amount of pending data .Ve .Sp Check openssl doc .IP "\(bu" 4 BIO_wpending .Sp Return the number of pending characters in the BIOs write buffers. .Sp .Vb 4 \& my $rv = Net::SSLeay::BIO_wpending($s); \& # $s \- value corresponding to openssl\*(Aqs BIO structure \& # \& # returns: the amount of pending data .Ve .Sp Check openssl doc .IP "\(bu" 4 BIO_read .Sp Read the underlying descriptor. .Sp .Vb 5 \& Net::SSLeay::BIO_read($s, $max); \& # $s \- value corresponding to openssl\*(Aqs BIO structure \& # $max \- [optional] max. bytes to read (if not specified, the value 32768 is used) \& # \& # returns: data .Ve .Sp Check openssl doc .IP "\(bu" 4 BIO_write .Sp Attempts to write data from \f(CW$buffer\fR to \s-1BIO\s0 \f(CW$b\fR. .Sp .Vb 7 \& my $rv = Net::SSLeay::BIO_write($b, $buffer); \& # $b \- value corresponding to openssl\*(Aqs BIO structure \& # $buffer \- data \& # \& # returns: amount of data successfully written \& # or that no data was successfully read or written if the result is 0 or \-1 \& # or \-2 when the operation is not implemented in the specific BIO type .Ve .Sp Check openssl doc .IP "\(bu" 4 BIO_s_mem .Sp Return the memory \s-1BIO\s0 method function. .Sp .Vb 3 \& my $rv = Net::SSLeay::BIO_s_mem(); \& # \& # returns: value corresponding to openssl\*(Aqs BIO_METHOD structure (0 on failure) .Ve .Sp Check openssl doc .IP "\(bu" 4 BIO_ssl_copy_session_id .Sp Copies an \s-1SSL\s0 session id between \s-1BIO\s0 chains from and to. It does this by locating the \s-1SSL\s0 BIOs in each chain and calling \fISSL_copy_session_id()\fR on the internal \s-1SSL\s0 pointer. .Sp .Vb 5 \& my $rv = Net::SSLeay::BIO_ssl_copy_session_id($to, $from); \& # $to \- value corresponding to openssl\*(Aqs BIO structure \& # $from \- value corresponding to openssl\*(Aqs BIO structure \& # \& # returns: 1 on success, 0 on failure .Ve .Sp Check openssl doc .IP "\(bu" 4 BIO_ssl_shutdown .Sp Closes down an \s-1SSL\s0 connection on \s-1BIO\s0 chain bio. It does this by locating the \&\s-1SSL BIO\s0 in the chain and calling \fISSL_shutdown()\fR on its internal \s-1SSL\s0 pointer. .Sp .Vb 4 \& Net::SSLeay::BIO_ssl_shutdown($ssl_bio); \& # $ssl_bio \- value corresponding to openssl\*(Aqs BIO structure \& # \& # returns: no return value .Ve .Sp Check openssl doc .PP \fILow level \s-1API:\s0 Server side Server Name Indication (\s-1SNI\s0) support\fR .IX Subsection "Low level API: Server side Server Name Indication (SNI) support" .IP "\(bu" 4 set_tlsext_host_name .Sp \&\s-1TBA\s0 .IP "\(bu" 4 get_servername .Sp \&\s-1TBA\s0 .IP "\(bu" 4 get_servername_type .Sp \&\s-1TBA\s0 .IP "\(bu" 4 CTX_set_tlsext_servername_callback .Sp \&\fB\s-1COMPATIBILITY:\s0\fR requires at least OpenSSL 0.9.8f .Sp This function is used in a server to support Server side Server Name Indication (\s-1SNI\s0). .Sp .Vb 7 \& Net::SSLeay::CTX_set_tlsext_servername_callback($ctx, $code) \& # $ctx \- SSL context \& # $code \- reference to a subroutine that will be called when a new connection is being initiated \& # \& # returns: no return value \&On the client side: \&use set_tlsext_host_name($ssl, $servername) before initiating the SSL connection. .Ve .Sp On the server side: Set up an additional \s-1\fISSL_CTX\s0()\fR for each different certificate; .Sp Add a servername callback to each \s-1\fISSL_CTX\s0()\fR using \fICTX_set_tlsext_servername_callback()\fR; .Sp The callback function is required to retrieve the client-supplied servername with get_servername(ssl). Figure out the right \&\s-1SSL_CTX\s0 to go with that host name, then switch the \s-1SSL\s0 object to that \s-1SSL_CTX\s0 with \fIset_SSL_CTX()\fR. .Sp Example: .Sp .Vb 7 \& # set callback \& Net::SSLeay::CTX_set_tlsext_servername_callback($ctx, \& sub { \& my $ssl = shift; \& my $h = Net::SSLeay::get_servername($ssl); \& Net::SSLeay::set_SSL_CTX($ssl, $hostnames{$h}\->{ctx}) if exists $hostnames{$h}; \& } ); .Ve .Sp More complete example: .Sp .Vb 1 \& # ... initialize Net::SSLeay \& \& my %hostnames = ( \& \*(Aqsni1\*(Aq => { cert=>\*(Aqsni1.pem\*(Aq, key=>\*(Aqsni1.key\*(Aq }, \& \*(Aqsni2\*(Aq => { cert=>\*(Aqsni2.pem\*(Aq, key=>\*(Aqsni2.key\*(Aq }, \& ); \& \& # create a new context for each certificate/key pair \& for my $name (keys %hostnames) { \& $hostnames{$name}\->{ctx} = Net::SSLeay::CTX_new or die; \& Net::SSLeay::CTX_set_cipher_list($hostnames{$name}\->{ctx}, \*(AqALL\*(Aq); \& Net::SSLeay::set_cert_and_key($hostnames{$name}\->{ctx}, \& $hostnames{$name}\->{cert}, $hostnames{$name}\->{key}) or die; \& } \& \& # create default context \& my $ctx = Net::SSLeay::CTX_new or die; \& Net::SSLeay::CTX_set_cipher_list($ctx, \*(AqALL\*(Aq); \& Net::SSLeay::set_cert_and_key($ctx, \*(Aqcert.pem\*(Aq,\*(Aqkey.pem\*(Aq) or die; \& \& # set callback \& Net::SSLeay::CTX_set_tlsext_servername_callback($ctx, sub { \& my $ssl = shift; \& my $h = Net::SSLeay::get_servername($ssl); \& Net::SSLeay::set_SSL_CTX($ssl, $hostnames{$h}\->{ctx}) if exists $hostnames{$h}; \& } ); \& \& # ... later \& \& $s = Net::SSLeay::new($ctx); \& Net::SSLeay::set_fd($s, fileno($accepted_socket)); \& Net::SSLeay::accept($s); .Ve .PP \fILow level \s-1API: NPN \s0(next protocol negotiation) related functions\fR .IX Subsection "Low level API: NPN (next protocol negotiation) related functions" .PP \&\s-1NPN\s0 is being replaced with \s-1ALPN,\s0 a more recent \s-1TLS\s0 extension for application protocol negotiation that's in process of being adopted by \s-1IETF.\s0 Please look below for \s-1APLN API\s0 description. .PP Simple approach for using \s-1NPN\s0 support looks like this: .PP .Vb 3 \& ### client side \& use Net::SSLeay; \& use IO::Socket::INET; \& \& Net::SSLeay::initialize(); \& my $sock = IO::Socket::INET\->new(PeerAddr=>\*(Aqencrypted.google.com:443\*(Aq) 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, [\*(Aqhttp1.1\*(Aq,\*(Aqspdy/2\*(Aq]); \& 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), "\en"; \& warn "client:last_status=", Net::SSLeay::P_next_proto_last_status($ssl), "\en"; \& \& ### server side \& use Net::SSLeay; \& use IO::Socket::INET; \& \& Net::SSLeay::initialize(); \& my $ctx = Net::SSLeay::CTX_tlsv1_new() or die; \& Net::SSLeay::CTX_set_options($ctx, &Net::SSLeay::OP_ALL); \& Net::SSLeay::set_cert_and_key($ctx, "t/data/cert.pem", "t/data/key.pem"); \& Net::SSLeay::CTX_set_next_protos_advertised_cb($ctx, [\*(Aqspdy/2\*(Aq,\*(Aqhttp1.1\*(Aq]); \& my $sock = IO::Socket::INET\->new(LocalAddr=>\*(Aqlocalhost\*(Aq, LocalPort=>5443, Proto=>\*(Aqtcp\*(Aq, Listen=>20) or die; \& \& while (1) { \& my $ssl = Net::SSLeay::new($ctx); \& warn("server:waiting for incoming connection...\en"); \& 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),"\en"; \& my $got = Net::SSLeay::read($ssl); \& Net::SSLeay::ssl_write_all($ssl, "length=".length($got)); \& Net::SSLeay::free($ssl); \& $fd\->close(); \& } \& # check with: openssl s_client \-connect localhost:5443 \-nextprotoneg http/1.1,spdy/2 .Ve .PP Please note that the selection (negotiation) is performed by client side, the server side simply advertise the list of supported protocols. .PP Advanced approach allows you to implement your own negotiation algorithm. .PP .Vb 3 \& #see below documentation for: \& Net::SSleay::CTX_set_next_proto_select_cb($ctx, $perl_callback_function, $callback_data); \& Net::SSleay::CTX_set_next_protos_advertised_cb($ctx, $perl_callback_function, $callback_data); .Ve .PP Detection of \s-1NPN\s0 support (works even in older Net::SSLeay versions): .PP .Vb 1 \& use Net::SSLeay; \& \& if (exists &Net::SSLeay::P_next_proto_negotiated) { \& # do NPN stuff \& } .Ve .IP "\(bu" 4 CTX_set_next_proto_select_cb .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before; requires at least openssl\-1.0.1 .Sp \&\fB\s-1NOTE:\s0\fR You need CTX_set_next_proto_select_cb on \fBclient side\fR of \s-1SSL\s0 connection. .Sp Simple usage \- in this case a \*(L"common\*(R" negotiation algorithm (as implemented by openssl's function SSL_select_next_proto) is used. .Sp .Vb 5 \& $rv = Net::SSleay::CTX_set_next_proto_select_cb($ctx, $arrayref); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $arrayref \- list of accepted protocols \- e.g. [\*(Aqhttp1.0\*(Aq, \*(Aqhttp1.1\*(Aq] \& # \& # returns: 0 on success, 1 on failure .Ve .Sp Advanced usage (you probably do not need this): .Sp .Vb 6 \& $rv = Net::SSleay::CTX_set_next_proto_select_cb($ctx, $perl_callback_function, $callback_data); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $perl_callback_function \- reference to perl function \& # $callback_data \- [optional] data to passed to callback function when invoked \& # \& # returns: 0 on success, 1 on failure \& \& # where callback function looks like \& sub npn_advertised_cb_invoke { \& my ($ssl, $arrayref_proto_list_advertised_by_server, $callback_data) = @_; \& my $status; \& # ... \& $status = 1; #status can be: \& # 0 \- OPENSSL_NPN_UNSUPPORTED \& # 1 \- OPENSSL_NPN_NEGOTIATED \& # 2 \- OPENSSL_NPN_NO_OVERLAP \& return $status, [\*(Aqhttp1.1\*(Aq,\*(Aqspdy/2\*(Aq]; # the callback has to return 2 values \& } .Ve .Sp To undefine/clear this callback use: .Sp .Vb 1 \& Net::SSleay::CTX_set_next_proto_select_cb($ctx, undef); .Ve .IP "\(bu" 4 CTX_set_next_protos_advertised_cb .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before; requires at least openssl\-1.0.1 .Sp \&\fB\s-1NOTE:\s0\fR You need CTX_set_next_proto_select_cb on \fBserver side\fR of \s-1SSL\s0 connection. .Sp Simple usage: .Sp .Vb 5 \& $rv = Net::SSleay::CTX_set_next_protos_advertised_cb($ctx, $arrayref); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $arrayref \- list of advertised protocols \- e.g. [\*(Aqhttp1.0\*(Aq, \*(Aqhttp1.1\*(Aq] \& # \& # returns: 0 on success, 1 on failure .Ve .Sp Advanced usage (you probably do not need this): .Sp .Vb 6 \& $rv = Net::SSleay::CTX_set_next_protos_advertised_cb($ctx, $perl_callback_function, $callback_data); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $perl_callback_function \- reference to perl function \& # $callback_data \- [optional] data to passed to callback function when invoked \& # \& # returns: 0 on success, 1 on failure \& \& # where callback function looks like \& sub npn_advertised_cb_invoke { \& my ($ssl, $callback_data) = @_; \& # ... \& return [\*(Aqhttp1.1\*(Aq,\*(Aqspdy/2\*(Aq]; # the callback has to return arrayref \& } .Ve .Sp To undefine/clear this callback use: .Sp .Vb 1 \& Net::SSleay::CTX_set_next_protos_advertised_cb($ctx, undef); .Ve .IP "\(bu" 4 P_next_proto_negotiated .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before; requires at least openssl\-1.0.1 .Sp Returns the name of negotiated protocol for given \s-1SSL\s0 connection \f(CW$ssl\fR. .Sp .Vb 4 \& $rv = Net::SSLeay::P_next_proto_negotiated($ssl) \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: (string) negotiated protocol name (or undef if no negotiation was done or failed with fatal error) .Ve .IP "\(bu" 4 P_next_proto_last_status .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.45 and before; requires at least openssl\-1.0.1 .Sp Returns the result of the last negotiation for given \s-1SSL\s0 connection \f(CW$ssl\fR. .Sp .Vb 7 \& $rv = Net::SSLeay::P_next_proto_last_status($ssl) \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: (integer) negotiation status \& # 0 \- OPENSSL_NPN_UNSUPPORTED \& # 1 \- OPENSSL_NPN_NEGOTIATED \& # 2 \- OPENSSL_NPN_NO_OVERLAP .Ve .PP \fILow level \s-1API: ALPN \s0(application layer protocol negotiation) related functions\fR .IX Subsection "Low level API: ALPN (application layer protocol negotiation) related functions" .PP Application protocol can be negotiated via two different mechanisms employing two different \s-1TLS\s0 extensions: \s-1NPN \s0(obsolete) and \s-1ALPN \s0(recommended). .PP The \s-1API\s0 is rather similar, with slight differences reflecting protocol specifics. In particular, with \s-1ALPN\s0 the protocol negotiation takes place on server, while with \s-1NPN\s0 the client implements the protocol negotiation logic. .PP With \s-1ALPN,\s0 the most basic implementation looks like this: .PP .Vb 3 \& ### client side \& use Net::SSLeay; \& use IO::Socket::INET; \& \& Net::SSLeay::initialize(); \& my $sock = IO::Socket::INET\->new(PeerAddr=>\*(Aqencrypted.google.com:443\*(Aq) 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, [\*(Aqhttp/1.1\*(Aq, \*(Aqhttp/2.0\*(Aq, \*(Aqspdy/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), "\en"; \& \& ### server side \& use Net::SSLeay; \& use IO::Socket::INET; \& \& Net::SSLeay::initialize(); \& my $ctx = Net::SSLeay::CTX_tlsv1_new() or die; \& Net::SSLeay::CTX_set_options($ctx, &Net::SSLeay::OP_ALL); \& Net::SSLeay::set_cert_and_key($ctx, "t/data/cert.pem", "t/data/key.pem"); \& Net::SSLeay::CTX_set_alpn_select_cb($ctx, [\*(Aqhttp/1.1\*(Aq, \*(Aqhttp/2.0\*(Aq, \*(Aqspdy/3]); \& my $sock = IO::Socket::INET\->new(LocalAddr=>\*(Aqlocalhost\*(Aq, LocalPort=>5443, Proto=>\*(Aqtcp\*(Aq, Listen=>20) or die; \& \& while (1) { \& my $ssl = Net::SSLeay::new($ctx); \& warn("server:waiting for incoming connection...\en"); \& my $fd = $sock\->accept(); \& Net::SSLeay::set_fd($ssl, $fd\->fileno); \& Net::SSLeay::accept($ssl); \& warn "server:selected=",Net::SSLeay::P_alpn_selected($ssl),"\en"; \& my $got = Net::SSLeay::read($ssl); \& Net::SSLeay::ssl_write_all($ssl, "length=".length($got)); \& Net::SSLeay::free($ssl); \& $fd\->close(); \& } \& # check with: openssl s_client \-connect localhost:5443 \-alpn spdy/3,http/1.1 .Ve .PP Advanced approach allows you to implement your own negotiation algorithm. .PP .Vb 2 \& #see below documentation for: \& Net::SSleay::CTX_set_alpn_select_cb($ctx, $perl_callback_function, $callback_data); .Ve .PP Detection of \s-1ALPN\s0 support (works even in older Net::SSLeay versions): .PP .Vb 1 \& use Net::SSLeay; \& \& if (exists &Net::SSLeay::P_alpn_selected) { \& # do ALPN stuff \& } .Ve .IP "\(bu" 4 CTX_set_alpn_select_cb .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.55 and before; requires at least openssl\-1.0.2 .Sp \&\fB\s-1NOTE:\s0\fR You need CTX_set_alpn_select_cb on \fBserver side\fR of \s-1TLS\s0 connection. .Sp Simple usage \- in this case a \*(L"common\*(R" negotiation algorithm (as implemented by openssl's function SSL_select_next_proto) is used. .Sp .Vb 5 \& $rv = Net::SSleay::CTX_set_alpn_select_cb($ctx, $arrayref); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $arrayref \- list of accepted protocols \- e.g. [\*(Aqhttp/2.0\*(Aq, \*(Aqhttp/1.1\*(Aq, \*(Aqspdy/3\*(Aq] \& # \& # returns: 0 on success, 1 on failure .Ve .Sp Advanced usage (you probably do not need this): .Sp .Vb 6 \& $rv = Net::SSleay::CTX_set_alpn_select_cb($ctx, $perl_callback_function, $callback_data); \& # $ctx \- value corresponding to openssl\*(Aqs SSL_CTX structure \& # $perl_callback_function \- reference to perl function \& # $callback_data \- [optional] data to passed to callback function when invoked \& # \& # returns: 0 on success, 1 on failure \& \& # where callback function looks like \& sub alpn_select_cb_invoke { \& my ($ssl, $arrayref_proto_list_advertised_by_client, $callback_data) = @_; \& # ... \& if ($negotiated) { \& return \*(Aqhttp/2.0\*(Aq; \& } else { \& return undef; \& } \& } .Ve .Sp To undefine/clear this callback use: .Sp .Vb 1 \& Net::SSleay::CTX_set_alpn_select_cb($ctx, undef); .Ve .IP "\(bu" 4 set_alpn_protos .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.55 and before; requires at least openssl\-1.0.2 .Sp \&\fB\s-1NOTE:\s0\fR You need set_alpn_protos on \fBclient side\fR of \s-1TLS\s0 connection. .Sp This adds list of supported application layer protocols to ClientHello message sent by a client. It advertises the enumeration of supported protocols: .Sp .Vb 2 \& Net::SSLeay::set_alpn_protos($ssl, [\*(Aqhttp/1.1\*(Aq, \*(Aqhttp/2.0\*(Aq, \*(Aqspdy/3]); \& # returns 0 on success .Ve .IP "\(bu" 4 CTX_set_alpn_protos .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.55 and before; requires at least openssl\-1.0.2 .Sp \&\fB\s-1NOTE:\s0\fR You need CTX_set_alpn_protos on \fBclient side\fR of \s-1TLS\s0 connection. .Sp This adds list of supported application layer protocols to ClientHello message sent by a client. It advertises the enumeration of supported protocols: .Sp .Vb 2 \& Net::SSLeay::CTX_set_alpn_protos($ctx, [\*(Aqhttp/1.1\*(Aq, \*(Aqhttp/2.0\*(Aq, \*(Aqspdy/3]); \& # returns 0 on success .Ve .IP "\(bu" 4 P_alpn_selected .Sp \&\fB\s-1COMPATIBILITY:\s0\fR not available in Net\-SSLeay\-1.55 and before; requires at least openssl\-1.0.2 .Sp Returns the name of negotiated protocol for given \s-1TLS\s0 connection \f(CW$ssl\fR. .Sp .Vb 4 \& $rv = Net::SSLeay::P_alpn_selected($ssl) \& # $ssl \- value corresponding to openssl\*(Aqs SSL structure \& # \& # returns: (string) negotiated protocol name (or undef if no negotiation was done or failed with fatal error) .Ve .PP \fILow level \s-1API: DANE\s0 Support\fR .IX Subsection "Low level API: DANE Support" .PP OpenSSL version 1.0.2 adds preliminary support \s-1RFC6698\s0 Domain Authentication of Named Entities (\s-1DANE\s0) Transport Layer Association within OpenSSL .IP "\(bu" 4 SSL_get_tlsa_record_byname .Sp \&\fB\s-1COMPATIBILITY:\s0\fR \s-1DELETED\s0 from net-ssleay, since it is not supported by OpenSSL .Sp In order to facilitate \s-1DANE\s0 there is additional interface, SSL_get_tlsa_record_byname, accepting hostname, port and socket type that returns packed \s-1TLSA\s0 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). .Sp Net::SSLeay::get_tlsa_record_byname($name, \f(CW$port\fR, \f(CW$type\fR); .PP \fILow level \s-1API:\s0 Other functions\fR .IX Subsection "Low level API: Other functions" .IP "\(bu" 4 COMP_add_compression_method .Sp Adds the compression method cm with the identifier id to the list of available compression methods. This list is globally maintained for all \s-1SSL\s0 operations within this application. It cannot be set for specific \s-1SSL_CTX\s0 or \s-1SSL\s0 objects. .Sp .Vb 9 \& my $rv = Net::SSLeay::COMP_add_compression_method($id, $cm); \& # $id \- (integer) compression method id \& # 0 to 63: methods defined by the IETF \& # 64 to 192: external party methods assigned by IANA \& # 193 to 255: reserved for private use \& # \& # $cm \- value corresponding to openssl\*(Aqs COMP_METHOD structure \& # \& # returns: 0 on success, 1 on failure (check the error queue to find out the reason) .Ve .Sp Check openssl doc .IP "\(bu" 4 DH_free .Sp Frees the \s-1DH\s0 structure and its components. The values are erased before the memory is returned to the system. .Sp .Vb 4 \& Net::SSLeay::DH_free($dh); \& # $dh \- value corresponding to openssl\*(Aqs DH structure \& # \& # returns: no return value .Ve .Sp Check openssl doc .IP "\(bu" 4 FIPS_mode_set .Sp Enable or disable \s-1FIPS\s0 mode in a \s-1FIPS\s0 capable OpenSSL. .Sp .Vb 2 \& Net::SSLeay:: FIPS_mode_set($enable); \& # $enable \- (integer) 1 to enable, 0 to disable .Ve .PP \fILow level \s-1API: EC\s0 related functions\fR .IX Subsection "Low level API: EC related functions" .IP "\(bu" 4 CTX_set_tmp_ecdh .Sp \&\s-1TBA\s0 .IP "\(bu" 4 EC_KEY_free .Sp \&\s-1TBA\s0 .IP "\(bu" 4 EC_KEY_new_by_curve_name .Sp \&\s-1TBA\s0 .IP "\(bu" 4 EC_KEY_generate_key .Sp Generates a \s-1EC\s0 key and returns it in a newly allocated \s-1EC_KEY\s0 structure. The \s-1EC\s0 key then can be used to create a \s-1PKEY\s0 which can be used in calls like X509_set_pubkey. .Sp .Vb 3 \& my $key = Net::SSLeay::EVP_PKEY_new(); \& my $ec = Net::SSLeay::EC_KEY_generate_key($curve); \& Net::SSLeay::EVP_PKEY_assign_EC_KEY($key,$ec); \& \& # $curve \- curve name like \*(Aqsecp521r1\*(Aq or the matching Id (integer) of the curve \& # \& # returns: value corresponding to openssl\*(Aqs EC_KEY structure (0 on failure) .Ve .Sp This function has no equivalent in OpenSSL but combines multiple OpenSSL functions for an easier interface. .SS "Constants" .IX Subsection "Constants" There are many openssl constants available in Net::SSLeay. You can use them like this: .PP .Vb 4 \& use Net::SSLeay; \& print &Net::SSLeay::NID_commonName; \& #or \& print Net::SSLeay::NID_commonName(); .Ve .PP Or you can import them and use: .PP .Vb 6 \& use Net::SSLeay qw/NID_commonName/; \& print &NID_commonName; \& #or \& print NID_commonName(); \& #or \& print NID_commonName; .Ve .PP The constants names are derived from openssl constants, however constants starting with \f(CW\*(C`SSL_\*(C'\fR prefix have name with \f(CW\*(C`SSL_\*(C'\fR part stripped \- e.g. openssl's constant \f(CW\*(C`SSL_OP_ALL\*(C'\fR is available as \f(CW\*(C`Net::SSleay::OP_ALL\*(C'\fR .PP The list of all available constant names: .PP .Vb 10 \& ASN1_STRFLGS_ESC_CTRL NID_ext_key_usage OP_CRYPTOPRO_TLSEXT_BUG \& ASN1_STRFLGS_ESC_MSB NID_ext_req OP_DONT_INSERT_EMPTY_FRAGMENTS \& ASN1_STRFLGS_ESC_QUOTE NID_friendlyName OP_EPHEMERAL_RSA \& ASN1_STRFLGS_RFC2253 NID_givenName OP_LEGACY_SERVER_CONNECT \& CB_ACCEPT_EXIT NID_hmacWithSHA1 OP_MICROSOFT_BIG_SSLV3_BUFFER \& CB_ACCEPT_LOOP NID_id_ad OP_MICROSOFT_SESS_ID_BUG \& CB_ALERT NID_id_ce OP_MSIE_SSLV2_RSA_PADDING \& CB_CONNECT_EXIT NID_id_kp OP_NETSCAPE_CA_DN_BUG \& CB_CONNECT_LOOP NID_id_pbkdf2 OP_NETSCAPE_CHALLENGE_BUG \& CB_EXIT NID_id_pe OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG \& CB_HANDSHAKE_DONE NID_id_pkix OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG \& CB_HANDSHAKE_START NID_id_qt_cps OP_NON_EXPORT_FIRST \& CB_LOOP NID_id_qt_unotice OP_NO_COMPRESSION \& CB_READ NID_idea_cbc OP_NO_QUERY_MTU \& CB_READ_ALERT NID_idea_cfb64 OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION \& CB_WRITE NID_idea_ecb OP_NO_SSLv2 \& CB_WRITE_ALERT NID_idea_ofb64 OP_NO_SSLv3 \& ERROR_NONE NID_info_access OP_NO_TICKET \& ERROR_SSL NID_initials OP_NO_TLSv1 \& ERROR_SYSCALL NID_invalidity_date OP_NO_TLSv1_1 \& ERROR_WANT_ACCEPT NID_issuer_alt_name OP_NO_TLSv1_2 \& ERROR_WANT_CONNECT NID_keyBag OP_PKCS1_CHECK_1 \& ERROR_WANT_READ NID_key_usage OP_PKCS1_CHECK_2 \& ERROR_WANT_WRITE NID_localKeyID OP_SINGLE_DH_USE \& ERROR_WANT_X509_LOOKUP NID_localityName OP_SINGLE_ECDH_USE \& ERROR_ZERO_RETURN NID_md2 OP_SSLEAY_080_CLIENT_DH_BUG \& EVP_PKS_DSA NID_md2WithRSAEncryption OP_SSLREF2_REUSE_CERT_TYPE_BUG \& EVP_PKS_EC NID_md5 OP_TLS_BLOCK_PADDING_BUG \& EVP_PKS_RSA NID_md5WithRSA OP_TLS_D5_BUG \& EVP_PKT_ENC NID_md5WithRSAEncryption OP_TLS_ROLLBACK_BUG \& EVP_PKT_EXCH NID_md5_sha1 READING \& EVP_PKT_EXP NID_mdc2 RECEIVED_SHUTDOWN \& EVP_PKT_SIGN NID_mdc2WithRSA RSA_3 \& EVP_PK_DH NID_ms_code_com RSA_F4 \& EVP_PK_DSA NID_ms_code_ind R_BAD_AUTHENTICATION_TYPE \& EVP_PK_EC NID_ms_ctl_sign R_BAD_CHECKSUM \& EVP_PK_RSA NID_ms_efs R_BAD_MAC_DECODE \& FILETYPE_ASN1 NID_ms_ext_req R_BAD_RESPONSE_ARGUMENT \& FILETYPE_PEM NID_ms_sgc R_BAD_SSL_FILETYPE \& F_CLIENT_CERTIFICATE NID_name R_BAD_SSL_SESSION_ID_LENGTH \& F_CLIENT_HELLO NID_netscape R_BAD_STATE \& F_CLIENT_MASTER_KEY NID_netscape_base_url R_BAD_WRITE_RETRY \& F_D2I_SSL_SESSION NID_netscape_ca_policy_url R_CHALLENGE_IS_DIFFERENT \& F_GET_CLIENT_FINISHED NID_netscape_ca_revocation_url R_CIPHER_TABLE_SRC_ERROR \& F_GET_CLIENT_HELLO NID_netscape_cert_extension R_INVALID_CHALLENGE_LENGTH \& F_GET_CLIENT_MASTER_KEY NID_netscape_cert_sequence R_NO_CERTIFICATE_SET \& F_GET_SERVER_FINISHED NID_netscape_cert_type R_NO_CERTIFICATE_SPECIFIED \& F_GET_SERVER_HELLO NID_netscape_comment R_NO_CIPHER_LIST \& F_GET_SERVER_VERIFY NID_netscape_data_type R_NO_CIPHER_MATCH \& F_I2D_SSL_SESSION NID_netscape_renewal_url R_NO_PRIVATEKEY \& F_READ_N NID_netscape_revocation_url R_NO_PUBLICKEY \& F_REQUEST_CERTIFICATE NID_netscape_ssl_server_name R_NULL_SSL_CTX \& F_SERVER_HELLO NID_ns_sgc R_PEER_DID_NOT_RETURN_A_CERTIFICATE \& F_SSL_CERT_NEW NID_organizationName R_PEER_ERROR \& F_SSL_GET_NEW_SESSION NID_organizationalUnitName R_PEER_ERROR_CERTIFICATE \& F_SSL_NEW NID_pbeWithMD2AndDES_CBC R_PEER_ERROR_NO_CIPHER \& F_SSL_READ NID_pbeWithMD2AndRC2_CBC R_PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE \& F_SSL_RSA_PRIVATE_DECRYPT NID_pbeWithMD5AndCast5_CBC R_PUBLIC_KEY_ENCRYPT_ERROR \& F_SSL_RSA_PUBLIC_ENCRYPT NID_pbeWithMD5AndDES_CBC R_PUBLIC_KEY_IS_NOT_RSA \& F_SSL_SESSION_NEW NID_pbeWithMD5AndRC2_CBC R_READ_WRONG_PACKET_TYPE \& F_SSL_SESSION_PRINT_FP NID_pbeWithSHA1AndDES_CBC R_SHORT_READ \& F_SSL_SET_FD NID_pbeWithSHA1AndRC2_CBC R_SSL_SESSION_ID_IS_DIFFERENT \& F_SSL_SET_RFD NID_pbe_WithSHA1And128BitRC2_CBC R_UNABLE_TO_EXTRACT_PUBLIC_KEY \& F_SSL_SET_WFD NID_pbe_WithSHA1And128BitRC4 R_UNKNOWN_REMOTE_ERROR_TYPE \& F_SSL_USE_CERTIFICATE NID_pbe_WithSHA1And2_Key_TripleDES_CBC R_UNKNOWN_STATE \& F_SSL_USE_CERTIFICATE_ASN1 NID_pbe_WithSHA1And3_Key_TripleDES_CBC R_X509_LIB \& F_SSL_USE_CERTIFICATE_FILE NID_pbe_WithSHA1And40BitRC2_CBC SENT_SHUTDOWN \& F_SSL_USE_PRIVATEKEY NID_pbe_WithSHA1And40BitRC4 SESSION_ASN1_VERSION \& F_SSL_USE_PRIVATEKEY_ASN1 NID_pbes2 ST_ACCEPT \& F_SSL_USE_PRIVATEKEY_FILE NID_pbmac1 ST_BEFORE \& F_SSL_USE_RSAPRIVATEKEY NID_pkcs ST_CONNECT \& F_SSL_USE_RSAPRIVATEKEY_ASN1 NID_pkcs3 ST_INIT \& F_SSL_USE_RSAPRIVATEKEY_FILE NID_pkcs7 ST_OK \& F_WRITE_PENDING NID_pkcs7_data ST_READ_BODY \& GEN_DIRNAME NID_pkcs7_digest ST_READ_HEADER \& GEN_DNS NID_pkcs7_encrypted TLSEXT_STATUSTYPE_ocsp \& GEN_EDIPARTY NID_pkcs7_enveloped VERIFY_CLIENT_ONCE \& GEN_EMAIL NID_pkcs7_signed VERIFY_FAIL_IF_NO_PEER_CERT \& GEN_IPADD NID_pkcs7_signedAndEnveloped VERIFY_NONE \& GEN_OTHERNAME NID_pkcs8ShroudedKeyBag VERIFY_PEER \& GEN_RID NID_pkcs9 V_OCSP_CERTSTATUS_GOOD \& GEN_URI NID_pkcs9_challengePassword V_OCSP_CERTSTATUS_REVOKED \& GEN_X400 NID_pkcs9_contentType V_OCSP_CERTSTATUS_UNKNOWN \& LIBRESSL_VERSION_NUMBER NID_pkcs9_countersignature WRITING \& MBSTRING_ASC NID_pkcs9_emailAddress X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT \& MBSTRING_BMP NID_pkcs9_extCertAttributes X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS \& MBSTRING_FLAG NID_pkcs9_messageDigest X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS \& MBSTRING_UNIV NID_pkcs9_signingTime X509_CHECK_FLAG_NO_WILDCARDS \& MBSTRING_UTF8 NID_pkcs9_unstructuredAddress X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS \& MIN_RSA_MODULUS_LENGTH_IN_BYTES NID_pkcs9_unstructuredName X509_LOOKUP \& MODE_ACCEPT_MOVING_WRITE_BUFFER NID_private_key_usage_period X509_PURPOSE_ANY \& MODE_AUTO_RETRY NID_rc2_40_cbc X509_PURPOSE_CRL_SIGN \& MODE_ENABLE_PARTIAL_WRITE NID_rc2_64_cbc X509_PURPOSE_NS_SSL_SERVER \& MODE_RELEASE_BUFFERS NID_rc2_cbc X509_PURPOSE_OCSP_HELPER \& NID_OCSP_sign NID_rc2_cfb64 X509_PURPOSE_SMIME_ENCRYPT \& NID_SMIMECapabilities NID_rc2_ecb X509_PURPOSE_SMIME_SIGN \& NID_X500 NID_rc2_ofb64 X509_PURPOSE_SSL_CLIENT \& NID_X509 NID_rc4 X509_PURPOSE_SSL_SERVER \& NID_ad_OCSP NID_rc4_40 X509_PURPOSE_TIMESTAMP_SIGN \& NID_ad_ca_issuers NID_rc5_cbc X509_TRUST_COMPAT \& NID_algorithm NID_rc5_cfb64 X509_TRUST_EMAIL \& NID_authority_key_identifier NID_rc5_ecb X509_TRUST_OBJECT_SIGN \& NID_basic_constraints NID_rc5_ofb64 X509_TRUST_OCSP_REQUEST \& NID_bf_cbc NID_ripemd160 X509_TRUST_OCSP_SIGN \& NID_bf_cfb64 NID_ripemd160WithRSA X509_TRUST_SSL_CLIENT \& NID_bf_ecb NID_rle_compression X509_TRUST_SSL_SERVER \& NID_bf_ofb64 NID_rsa X509_TRUST_TSA \& NID_cast5_cbc NID_rsaEncryption X509_V_FLAG_ALLOW_PROXY_CERTS \& NID_cast5_cfb64 NID_rsadsi X509_V_FLAG_CB_ISSUER_CHECK \& NID_cast5_ecb NID_safeContentsBag X509_V_FLAG_CHECK_SS_SIGNATURE \& NID_cast5_ofb64 NID_sdsiCertificate X509_V_FLAG_CRL_CHECK \& NID_certBag NID_secretBag X509_V_FLAG_CRL_CHECK_ALL \& NID_certificate_policies NID_serialNumber X509_V_FLAG_EXPLICIT_POLICY \& NID_client_auth NID_server_auth X509_V_FLAG_EXTENDED_CRL_SUPPORT \& NID_code_sign NID_sha X509_V_FLAG_IGNORE_CRITICAL \& NID_commonName NID_sha1 X509_V_FLAG_INHIBIT_ANY \& NID_countryName NID_sha1WithRSA X509_V_FLAG_INHIBIT_MAP \& NID_crlBag NID_sha1WithRSAEncryption X509_V_FLAG_NOTIFY_POLICY \& NID_crl_distribution_points NID_shaWithRSAEncryption X509_V_FLAG_POLICY_CHECK \& NID_crl_number NID_stateOrProvinceName X509_V_FLAG_POLICY_MASK \& NID_crl_reason NID_subject_alt_name X509_V_FLAG_TRUSTED_FIRST \& NID_delta_crl NID_subject_key_identifier X509_V_FLAG_USE_CHECK_TIME \& NID_des_cbc NID_surname X509_V_FLAG_USE_DELTAS \& NID_des_cfb64 NID_sxnet X509_V_FLAG_X509_STRICT \& NID_des_ecb NID_time_stamp X509_V_OK \& NID_des_ede NID_title XN_FLAG_COMPAT \& NID_des_ede3 NID_undef XN_FLAG_DN_REV \& NID_des_ede3_cbc NID_uniqueIdentifier XN_FLAG_DUMP_UNKNOWN_FIELDS \& NID_des_ede3_cfb64 NID_x509Certificate XN_FLAG_FN_ALIGN \& NID_des_ede3_ofb64 NID_x509Crl XN_FLAG_FN_LN \& NID_des_ede_cbc NID_zlib_compression XN_FLAG_FN_MASK \& NID_des_ede_cfb64 NOTHING XN_FLAG_FN_NONE \& NID_des_ede_ofb64 OCSP_RESPONSE_STATUS_INTERNALERROR XN_FLAG_FN_OID \& NID_des_ofb64 OCSP_RESPONSE_STATUS_MALFORMEDREQUEST XN_FLAG_FN_SN \& NID_description OCSP_RESPONSE_STATUS_SIGREQUIRED XN_FLAG_MULTILINE \& NID_desx_cbc OCSP_RESPONSE_STATUS_SUCCESSFUL XN_FLAG_ONELINE \& NID_dhKeyAgreement OCSP_RESPONSE_STATUS_TRYLATER XN_FLAG_RFC2253 \& NID_dnQualifier OCSP_RESPONSE_STATUS_UNAUTHORIZED XN_FLAG_SEP_COMMA_PLUS \& NID_dsa OPENSSL_VERSION_NUMBER XN_FLAG_SEP_CPLUS_SPC \& NID_dsaWithSHA OP_ALL XN_FLAG_SEP_MASK \& NID_dsaWithSHA1 OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION XN_FLAG_SEP_MULTILINE \& NID_dsaWithSHA1_2 OP_CIPHER_SERVER_PREFERENCE XN_FLAG_SEP_SPLUS_SPC \& NID_dsa_2 OP_CISCO_ANYCONNECT XN_FLAG_SPC_EQ \& NID_email_protect OP_COOKIE_EXCHANGE \&=head2 INTERNAL ONLY functions (do not use these) .Ve .PP The following functions are not intended for use from outside of Net::SSLeay module. They might be removed, renamed or changed without prior notice in future version. .PP Simply \fB\s-1DO NOT USE THEM\s0\fR! .IP "\(bu" 4 hello .IP "\(bu" 4 blength .IP "\(bu" 4 constant .SH "EXAMPLES" .IX Header "EXAMPLES" One very good example to look at is the implementation of \f(CW\*(C`sslcat()\*(C'\fR in the \&\f(CW\*(C`SSLeay.pm\*(C'\fR file. .PP The following is a simple SSLeay client (with too little error checking :\-( .PP .Vb 6 \& #!/usr/bin/perl \& use Socket; \& use Net::SSLeay qw(die_now die_if_ssl_error) ; \& Net::SSLeay::load_error_strings(); \& Net::SSLeay::SSLeay_add_ssl_algorithms(); \& Net::SSLeay::randomize(); \& \& ($dest_serv, $port, $msg) = @ARGV; # Read command line \& $port = getservbyname ($port, \*(Aqtcp\*(Aq) unless $port =~ /^\ed+$/; \& $dest_ip = gethostbyname ($dest_serv); \& $dest_serv_params = sockaddr_in($port, $dest_ip); \& \& socket (S, &AF_INET, &SOCK_STREAM, 0) or die "socket: $!"; \& connect (S, $dest_serv_params) or die "connect: $!"; \& select (S); $| = 1; select (STDOUT); # Eliminate STDIO buffering \& \& # The network connection is now open, lets fire up SSL \& \& $ctx = Net::SSLeay::CTX_new() or die_now("Failed to create SSL_CTX $!"); \& Net::SSLeay::CTX_set_options($ctx, &Net::SSLeay::OP_ALL) \& or die_if_ssl_error("ssl ctx set options"); \& $ssl = Net::SSLeay::new($ctx) or die_now("Failed to create SSL $!"); \& Net::SSLeay::set_fd($ssl, fileno(S)); # Must use fileno \& $res = Net::SSLeay::connect($ssl) and die_if_ssl_error("ssl connect"); \& print "Cipher \`" . Net::SSLeay::get_cipher($ssl) . "\*(Aq\en"; \& \& # Exchange data \& \& $res = Net::SSLeay::write($ssl, $msg); # Perl knows how long $msg is \& die_if_ssl_error("ssl write"); \& CORE::shutdown S, 1; # Half close \-\-> No more output, sends EOF to server \& $got = Net::SSLeay::read($ssl); # Perl returns undef on failure \& die_if_ssl_error("ssl read"); \& print $got; \& \& Net::SSLeay::free ($ssl); # Tear down connection \& Net::SSLeay::CTX_free ($ctx); \& close S; .Ve .PP The following is a simple SSLeay echo server (non forking): .PP .Vb 6 \& #!/usr/bin/perl \-w \& use Socket; \& use Net::SSLeay qw(die_now die_if_ssl_error); \& Net::SSLeay::load_error_strings(); \& Net::SSLeay::SSLeay_add_ssl_algorithms(); \& Net::SSLeay::randomize(); \& \& $our_ip = "\e0\e0\e0\e0"; # Bind to all interfaces \& $port = 1235; \& $sockaddr_template = \*(AqS n a4 x8\*(Aq; \& $our_serv_params = pack ($sockaddr_template, &AF_INET, $port, $our_ip); \& \& socket (S, &AF_INET, &SOCK_STREAM, 0) or die "socket: $!"; \& bind (S, $our_serv_params) or die "bind: $!"; \& listen (S, 5) or die "listen: $!"; \& $ctx = Net::SSLeay::CTX_new () or die_now("CTX_new ($ctx): $!"); \& Net::SSLeay::CTX_set_options($ctx, &Net::SSLeay::OP_ALL) \& or die_if_ssl_error("ssl ctx set options"); \& \& # Following will ask password unless private key is not encrypted \& Net::SSLeay::CTX_use_RSAPrivateKey_file ($ctx, \*(Aqplain\-rsa.pem\*(Aq, \& &Net::SSLeay::FILETYPE_PEM); \& die_if_ssl_error("private key"); \& Net::SSLeay::CTX_use_certificate_file ($ctx, \*(Aqplain\-cert.pem\*(Aq, \& &Net::SSLeay::FILETYPE_PEM); \& die_if_ssl_error("certificate"); \& \& while (1) { \& print "Accepting connections...\en"; \& ($addr = accept (NS, S)) or die "accept: $!"; \& select (NS); $| = 1; select (STDOUT); # Piping hot! \& \& ($af,$client_port,$client_ip) = unpack($sockaddr_template,$addr); \& @inetaddr = unpack(\*(AqC4\*(Aq,$client_ip); \& print "$af connection from " . \& join (\*(Aq.\*(Aq, @inetaddr) . ":$client_port\en"; \& \& # We now have a network connection, lets fire up SSLeay... \& \& $ssl = Net::SSLeay::new($ctx) or die_now("SSL_new ($ssl): $!"); \& Net::SSLeay::set_fd($ssl, fileno(NS)); \& \& $err = Net::SSLeay::accept($ssl) and die_if_ssl_error(\*(Aqssl accept\*(Aq); \& print "Cipher \`" . Net::SSLeay::get_cipher($ssl) . "\*(Aq\en"; \& \& # Connected. Exchange some data. \& \& $got = Net::SSLeay::read($ssl); # Returns undef on fail \& die_if_ssl_error("ssl read"); \& print "Got \`$got\*(Aq (" . length ($got) . " chars)\en"; \& \& Net::SSLeay::write ($ssl, uc ($got)) or die "write: $!"; \& die_if_ssl_error("ssl write"); \& \& Net::SSLeay::free ($ssl); # Tear down connection \& close NS; \& } .Ve .PP Yet another echo server. This one runs from \f(CW\*(C`/etc/inetd.conf\*(C'\fR 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 \f(CW\*(C`STDIN\*(C'\fR and \f(CW\*(C`STDOUT\*(C'\fR are wired to \s-1SSL.\s0 .PP .Vb 5 \& #!/usr/bin/perl \& # /etc/inetd.conf \& # ssltst stream tcp nowait root /path/to/server.pl server.pl \& # /etc/services \& # ssltst 1234/tcp \& \& use Net::SSLeay qw(die_now die_if_ssl_error); \& Net::SSLeay::load_error_strings(); \& Net::SSLeay::SSLeay_add_ssl_algorithms(); \& Net::SSLeay::randomize(); \& \& chdir \*(Aq/key/dir\*(Aq or die "chdir: $!"; \& $| = 1; # Piping hot! \& open LOG, ">>/dev/console" or die "Can\*(Aqt open log file $!"; \& select LOG; print "server.pl started\en"; \& \& $ctx = Net::SSLeay::CTX_new() or die_now "CTX_new ($ctx) ($!)"; \& $ssl = Net::SSLeay::new($ctx) or die_now "new ($ssl) ($!)"; \& Net::SSLeay::set_options($ssl, &Net::SSLeay::OP_ALL) \& and die_if_ssl_error("ssl set options"); \& \& # We get already open network connection from inetd, now we just \& # need to attach SSLeay to STDIN and STDOUT \& Net::SSLeay::set_rfd($ssl, fileno(STDIN)); \& Net::SSLeay::set_wfd($ssl, fileno(STDOUT)); \& \& Net::SSLeay::use_RSAPrivateKey_file ($ssl, \*(Aqplain\-rsa.pem\*(Aq, \& Net::SSLeay::FILETYPE_PEM); \& die_if_ssl_error("private key"); \& Net::SSLeay::use_certificate_file ($ssl, \*(Aqplain\-cert.pem\*(Aq, \& 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) . "\*(Aq\en"; \& \& $got = Net::SSLeay::read($ssl); \& die_if_ssl_error("ssl read"); \& print "Got \`$got\*(Aq (" . length ($got) . " chars)\en"; \& \& Net::SSLeay::write ($ssl, uc($got)) or die "write: $!"; \& die_if_ssl_error("ssl write"); \& \& Net::SSLeay::free ($ssl); # Tear down the connection \& Net::SSLeay::CTX_free ($ctx); \& close LOG; .Ve .PP There are also a number of example/test programs in the examples directory: .PP .Vb 11 \& 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) .Ve .SH "INSTALLATION" .IX Header "INSTALLATION" See \s-1README\s0 and \s-1README\s0.* in the distribution directory for installation guidance on a variety of platforms. .SH "LIMITATIONS" .IX Header "LIMITATIONS" \&\f(CW\*(C`Net::SSLeay::read()\*(C'\fR 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: .PP .Vb 5 \& $reply = \*(Aq\*(Aq; \& while ($got = Net::SSLeay::read($ssl)) { \& last if print_errs(\*(AqSSL_read\*(Aq); \& $reply .= $got; \& } .Ve .PP Although there is no built-in limit in \f(CW\*(C`Net::SSLeay::write()\*(C'\fR, the network packet size limitation applies here as well, thus use: .PP .Vb 1 \& $written = 0; \& \& while ($written < length($message)) { \& $written += Net::SSLeay::write($ssl, substr($message, $written)); \& last if print_errs(\*(AqSSL_write\*(Aq); \& } .Ve .PP Or alternatively you can just use the following convenience functions: .PP .Vb 2 \& Net::SSLeay::ssl_write_all($ssl, $message) or die "ssl write failure"; \& $got = Net::SSLeay::ssl_read_all($ssl) or die "ssl read failure"; .Ve .SH "KNOWN BUGS AND CAVEATS" .IX Header "KNOWN BUGS AND CAVEATS" An OpenSSL bug \s-1CVE\-2015\-0290 \s0\*(L"OpenSSL Multiblock Corrupted Pointer Issue\*(R" can cause \s-1POST\s0 requests of over 90kB to fail or crash. This bug is reported to be fixed in OpenSSL 1.0.2a. .PP Autoloader emits a .PP .Vb 1 \& Argument "xxx" isn\*(Aqt numeric in entersub at blib/lib/Net/SSLeay.pm\*(Aq .Ve .PP warning if die_if_ssl_error is made autoloadable. If you figure out why, drop me a line. .PP Callback set using \f(CW\*(C`SSL_set_verify()\*(C'\fR does not appear to work. This may well be an openssl problem (e.g. see \f(CW\*(C`ssl/ssl_lib.c\*(C'\fR line 1029). Try using \&\f(CW\*(C`SSL_CTX_set_verify()\*(C'\fR instead and do not be surprised if even this stops working in future versions. .PP Callback and certificate verification stuff is generally too little tested. .PP Random numbers are not initialized randomly enough, especially if you do not have \f(CW\*(C`/dev/random\*(C'\fR and/or \f(CW\*(C`/dev/urandom\*(C'\fR (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. .PP 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 \f(CW\*(C`/dev/random\*(C'\fR or to operate insecurely if you use \f(CW\*(C`/dev/urandom\*(C'\fR. What happens is that when too much randomness is drawn from the operating system's randomness pool then randomness can temporarily be unavailable. \f(CW\*(C`/dev/random\*(C'\fR 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. \&\f(CW\*(C`/dev/urandom\*(C'\fR solves this dilemma more pragmatically by simply returning predictable \*(L"random\*(R" numbers. Some\f(CW\*(C` /dev/urandom\*(C'\fR emulation software however actually seems to implement \f(CW\*(C`/dev/random\*(C'\fR semantics. Caveat emptor. .PP I've been pointed to two such daemons by Mik Firestone who has used them on Solaris 8: .IP "1." 4 Entropy Gathering Daemon (\s-1EGD\s0) at .IP "2." 4 Pseudo-random number generating daemon (\s-1PRNGD\s0) at .PP If you are using the low level \s-1API\s0 functions to communicate with other \&\s-1SSL\s0 implementations, you would do well to call .PP .Vb 2 \& Net::SSLeay::CTX_set_options($ctx, &Net::SSLeay::OP_ALL) \& or die_if_ssl_error("ssl ctx set options"); .Ve .PP to cope with some well know bugs in some other \s-1SSL\s0 implementations. The high level \s-1API\s0 functions always set all known compatibility options. .PP Sometimes \f(CW\*(C`sslcat()\*(C'\fR (and the high level \s-1HTTPS\s0 functions that build on it) is too fast in signaling the \s-1EOF\s0 to legacy \s-1HTTPS\s0 servers. This causes the server to return empty page. To work around this problem you can set the global variable .PP .Vb 1 \& $Net::SSLeay::slowly = 1; # Add sleep so broken servers can keep up .Ve .PP \&\s-1HTTP/1.1\s0 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 \s-1SSL\s0 session cache on your server helps to alleviate the \s-1CPU\s0 load somewhat. .PP As of version 1.09 many newer OpenSSL auxiliary functions were added (from \f(CW\*(C`REM_AUTOMATICALLY_GENERATED_1_09\*(C'\fR onwards in \f(CW\*(C`SSLeay.xs\*(C'\fR). Unfortunately I have not had any opportunity to test these. Some of them are trivial enough that I believe they \*(L"just work\*(R", but others have rather complex interfaces with function pointers and all. In these cases you should proceed wit great caution. .PP This module defaults to using OpenSSL automatic protocol negotiation code for automatically detecting the version of the \s-1SSL\s0 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. .PP .Vb 3 \& $Net::SSLeay::ssl_version = 2; # Insist on SSLv2 \& $Net::SSLeay::ssl_version = 3; # Insist on SSLv3 \& $Net::SSLeay::ssl_version = 10; # Insist on TLSv1 .Ve .PP Although the autonegotiation is nice to have, the \s-1SSL\s0 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 \s-1SSL\s0 handshake level), try this option before mailing me. .PP 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. .PP The high level \s-1API\s0 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. .PP 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 \s-1API\s0 functions do this, thus you would have to program it using the low level \s-1API. A\s0 good place to start is to see how the \f(CW\*(C`Net::SSLeay::http_cat()\*(C'\fR function is implemented. .PP The high level \s-1API\s0 functions use a global file handle \f(CW\*(C`SSLCAT_S\*(C'\fR internally. This really should not be a problem because there is no way to interleave the high level \s-1API\s0 functions, unless you use threads (but threads are not very well supported in perl anyway (as of version 5.6.1). However, you may run into problems if you call undocumented internal functions in an interleaved fashion. The best solution is to \*(L"require Net::SSLeay\*(R" in one thread after all the threads have been created. .SH "DIAGNOSTICS" .IX Header "DIAGNOSTICS" .IP "Random number generator not seeded!!!" 4 .IX Item "Random number generator not seeded!!!" \&\fB(W)\fR This warning indicates that \f(CW\*(C`randomize()\*(C'\fR was not able to read \&\f(CW\*(C`/dev/random\*(C'\fR or \f(CW\*(C`/dev/urandom\*(C'\fR, possibly because your system does not have them or they are differently named. You can still use \s-1SSL,\s0 but the encryption will not be as strong. .IP "open_tcp_connection: destination host not found:`server' (port 123) ($!)" 4 .IX Item "open_tcp_connection: destination host not found:`server' (port 123) ($!)" Name lookup for host named \f(CW\*(C`server\*(C'\fR failed. .IP "open_tcp_connection: failed `server', 123 ($!)" 4 .IX Item "open_tcp_connection: failed `server', 123 ($!)" The name was resolved, but establishing the \s-1TCP\s0 connection failed. .IP "msg 123: 1 \- error:140770F8:SSL routines:SSL23_GET_SERVER_HELLO:unknown proto" 4 .IX Item "msg 123: 1 - error:140770F8:SSL routines:SSL23_GET_SERVER_HELLO:unknown proto" SSLeay error string. The first number (123) is the \s-1PID,\s0 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. .IP "msg 123: 1 \- \fIerror:02001002::lib\fR\|(2) :\fIfunc\fR\|(1) :\fIreason\fR\|(2)" 4 .IX Item "msg 123: 1 - error:02001002::lib :func :reason" The same as above, but you didn't call \fIload_error_strings()\fR so SSLeay couldn't verbosely explain the error. You can still find out what it means with this command: .Sp .Vb 1 \& /usr/local/ssl/bin/ssleay errstr 02001002 .Ve .IP "Password is being asked for private key" 4 .IX 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 \s-1FAQ\s0 that explains how to do this (or just study examples/makecert.pl which is used during \f(CW\*(C`make test\*(C'\fR to do just that). .SH "SECURITY" .IX Header "SECURITY" You can mitigate some of the security vulnerabilities that might be present in your \s-1SSL/TLS\s0 application: .SS "\s-1BEAST\s0 Attack" .IX Subsection "BEAST Attack" http://blogs.cisco.com/security/beat\-the\-beast\-with\-tls/ https://community.qualys.com/blogs/securitylabs/2011/10/17/mitigating\-the\-beast\-attack\-on\-tls http://blog.zoller.lu/2011/09/beast\-summary\-tls\-cbc\-countermeasures.html .PP The \s-1BEAST\s0 attack relies on a weakness in the way \s-1CBC\s0 mode is used in \s-1SSL/TLS. \s0 In OpenSSL versions 0.9.6d and later, the protocol-level mitigation is enabled by default, thus making it not vulnerable to the \s-1BEAST\s0 attack. .PP Solutions: .IP "\(bu" 4 Compile with OpenSSL versions 0.9.6d or later, which enables \s-1SSL_OP_ALL\s0 by default .IP "\(bu" 4 Ensure \s-1SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS\s0 is not enabled (its not enabled by default) .IP "\(bu" 4 Don't support SSLv2, SSLv3 .IP "\(bu" 4 Actively control the ciphers your server supports with set_cipher_list: .PP Net::SSLeay::set_cipher_list($ssl, '\s-1RC4\-SHA:HIGH:\s0!ADH'); .SS "Session Resumption" .IX Subsection "Session Resumption" http://www.openssl.org/docs/ssl/SSL_CTX_set_options.html .PP The \s-1SSL\s0 Labs vulnerability test on your \s-1SSL\s0 server might report in red: .PP Session resumption No (IDs assigned but not accepted) .PP 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, 0); .SS "Secure Renegotiation and DoS Attack" .IX Subsection "Secure Renegotiation and DoS Attack" https://community.qualys.com/blogs/securitylabs/2011/10/31/tls\-renegotiation\-and\-denial\-of\-service\-attacks .PP This is not a \*(L"security flaw,\*(R" it is more of a DoS vulnerability. .PP Solutions: .IP "\(bu" 4 Do not support SSLv2 .IP "\(bu" 4 Do not set the \s-1SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION\s0 option .IP "\(bu" 4 Compile with OpenSSL 0.9.8m or later .SH "BUGS AND SUPPORT" .IX Header "BUGS AND SUPPORT" Please report any bugs or feature requests to \&\f(CW\*(C`bug\-Net\-SSLeay at rt.cpan.org\*(C'\fR, or through the web interface at . I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. .PP Subversion access to the latest source code etc can be obtained at .PP The developer mailing list (for people interested in contributing to the source code) can be found at .PP You can find documentation for this module with the \f(CW\*(C`perldoc\*(C'\fR command. .PP .Vb 1 \& perldoc Net::SSLeay .Ve .PP You can also look for information at: .IP "\(bu" 4 AnnoCPAN: Annotated \s-1CPAN\s0 documentation .Sp .IP "\(bu" 4 \&\s-1CPAN\s0 Ratings .Sp .IP "\(bu" 4 Search \s-1CPAN\s0 .Sp .PP Commercial support for Net::SSLeay may be obtained from .PP .Vb 3 \& Symlabs (netssleay@symlabs.com) \& Tel: +351\-214.222.630 \& Fax: +351\-214.222.637 .Ve .SH "AUTHOR" .IX Header "AUTHOR" Maintained by Mike McCauley and Florian Ragwitz since November 2005 .PP Originally written by Sampo Kellomäki .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (c) 1996\-2003 Sampo Kellomäki .PP Copyright (C) 2005\-2006 Florian Ragwitz .PP Copyright (C) 2005 Mike McCauley .PP All Rights Reserved. .PP Distribution and use of this module is under the same terms as the OpenSSL package itself (i.e. free, but mandatory attribution; \s-1NO WARRANTY\s0). Please consult \s-1LICENSE\s0 file in the root of the Net-SSLeay distribution, and also included in this distribution. .PP The Authors credit Eric Young and the OpenSSL team with the development of the excellent OpenSSL library, which this Perl package uses. .PP And remember, you, and nobody else but you, are responsible for auditing this module and OpenSSL library for security problems, backdoors, and general suitability for your application. .SH "LICENSE" .IX Header "LICENSE" From version 1.66 onwards, this Net-SSLeay library is issued under the \*(L"Perl Artistic License 2.0\*(R", the same license as Perl itself. .PP (ignore this line: this is to keep kwalitee happy by saying: Not \s-1GPL\s0) .SH "SEE ALSO" .IX Header "SEE ALSO" .Vb 10 \& Net::SSLeay::Handle \- File handle interface \& ./examples \- Example servers and a clients \& \- OpenSSL source, documentation, etc \& openssl\-users\-request@openssl.org \- General OpenSSL mailing list \& \- TLS 1.0 specification \& \- HTTP specifications \& \- How to send password \& \- Entropy Gathering Daemon (EGD) \& \& \- pseudo\-random number generating daemon (PRNGD) \& perl(1) \& perlref(1) \& perllol(1) \& perldoc ~openssl/doc/ssl/SSL_CTX_set_verify.pod .Ve