]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/libfetch/fetch.3
Add UPDATING entries and bump version.
[FreeBSD/FreeBSD.git] / lib / libfetch / fetch.3
1 .\"-
2 .\" Copyright (c) 1998-2013 Dag-Erling Smørgrav
3 .\" Copyright (c) 2013-2016 Michael Gmelin <freebsd@grem.de>
4 .\" All rights reserved.
5 .\"
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
8 .\" are met:
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\"    notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\"    notice, this list of conditions and the following disclaimer in the
13 .\"    documentation and/or other materials provided with the distribution.
14 .\"
15 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 .\" SUCH DAMAGE.
26 .\"
27 .\" $FreeBSD$
28 .\"
29 .Dd August 28, 2019
30 .Dt FETCH 3
31 .Os
32 .Sh NAME
33 .Nm fetchMakeURL ,
34 .Nm fetchParseURL ,
35 .Nm fetchFreeURL ,
36 .Nm fetchXGetURL ,
37 .Nm fetchGetURL ,
38 .Nm fetchPutURL ,
39 .Nm fetchStatURL ,
40 .Nm fetchListURL ,
41 .Nm fetchXGet ,
42 .Nm fetchGet ,
43 .Nm fetchPut ,
44 .Nm fetchStat ,
45 .Nm fetchList ,
46 .Nm fetchXGetFile ,
47 .Nm fetchGetFile ,
48 .Nm fetchPutFile ,
49 .Nm fetchStatFile ,
50 .Nm fetchListFile ,
51 .Nm fetchXGetHTTP ,
52 .Nm fetchGetHTTP ,
53 .Nm fetchPutHTTP ,
54 .Nm fetchStatHTTP ,
55 .Nm fetchListHTTP ,
56 .Nm fetchReqHTTP ,
57 .Nm fetchXGetFTP ,
58 .Nm fetchGetFTP ,
59 .Nm fetchPutFTP ,
60 .Nm fetchStatFTP ,
61 .Nm fetchListFTP
62 .Nd file transfer functions
63 .Sh LIBRARY
64 .Lb libfetch
65 .Sh SYNOPSIS
66 .In sys/param.h
67 .In stdio.h
68 .In fetch.h
69 .Ft struct url *
70 .Fn fetchMakeURL "const char *scheme" "const char *host" "int port" "const char *doc" "const char *user" "const char *pwd"
71 .Ft struct url *
72 .Fn fetchParseURL "const char *URL"
73 .Ft void
74 .Fn fetchFreeURL "struct url *u"
75 .Ft FILE *
76 .Fn fetchXGetURL "const char *URL" "struct url_stat *us" "const char *flags"
77 .Ft FILE *
78 .Fn fetchGetURL "const char *URL" "const char *flags"
79 .Ft FILE *
80 .Fn fetchPutURL "const char *URL" "const char *flags"
81 .Ft int
82 .Fn fetchStatURL "const char *URL" "struct url_stat *us" "const char *flags"
83 .Ft struct url_ent *
84 .Fn fetchListURL "const char *URL" "const char *flags"
85 .Ft FILE *
86 .Fn fetchXGet "struct url *u" "struct url_stat *us" "const char *flags"
87 .Ft FILE *
88 .Fn fetchGet "struct url *u" "const char *flags"
89 .Ft FILE *
90 .Fn fetchPut "struct url *u" "const char *flags"
91 .Ft int
92 .Fn fetchStat "struct url *u" "struct url_stat *us" "const char *flags"
93 .Ft struct url_ent *
94 .Fn fetchList "struct url *u" "const char *flags"
95 .Ft FILE *
96 .Fn fetchXGetFile "struct url *u" "struct url_stat *us" "const char *flags"
97 .Ft FILE *
98 .Fn fetchGetFile "struct url *u" "const char *flags"
99 .Ft FILE *
100 .Fn fetchPutFile "struct url *u" "const char *flags"
101 .Ft int
102 .Fn fetchStatFile "struct url *u" "struct url_stat *us" "const char *flags"
103 .Ft struct url_ent *
104 .Fn fetchListFile "struct url *u" "const char *flags"
105 .Ft FILE *
106 .Fn fetchXGetHTTP "struct url *u" "struct url_stat *us" "const char *flags"
107 .Ft FILE *
108 .Fn fetchGetHTTP "struct url *u" "const char *flags"
109 .Ft FILE *
110 .Fn fetchPutHTTP "struct url *u" "const char *flags"
111 .Ft int
112 .Fn fetchStatHTTP "struct url *u" "struct url_stat *us" "const char *flags"
113 .Ft struct url_ent *
114 .Fn fetchListHTTP "struct url *u" "const char *flags"
115 .Ft FILE *
116 .Fn fetchReqHTTP "struct url *u" "const char *method" "const char *flags" "const char *content_type" "const char *body"
117 .Ft FILE *
118 .Fn fetchXGetFTP "struct url *u" "struct url_stat *us" "const char *flags"
119 .Ft FILE *
120 .Fn fetchGetFTP "struct url *u" "const char *flags"
121 .Ft FILE *
122 .Fn fetchPutFTP "struct url *u" "const char *flags"
123 .Ft int
124 .Fn fetchStatFTP "struct url *u" "struct url_stat *us" "const char *flags"
125 .Ft struct url_ent *
126 .Fn fetchListFTP "struct url *u" "const char *flags"
127 .Sh DESCRIPTION
128 These functions implement a high-level library for retrieving and
129 uploading files using Uniform Resource Locators (URLs).
130 .Pp
131 .Fn fetchParseURL
132 takes a URL in the form of a null-terminated string and splits it into
133 its components function according to the Common Internet Scheme Syntax
134 detailed in RFC1738.
135 A regular expression which produces this syntax is:
136 .Bd -literal
137     <scheme>:(//(<user>(:<pwd>)?@)?<host>(:<port>)?)?/(<document>)?
138 .Ed
139 .Pp
140 If the URL does not seem to begin with a scheme name, the following
141 syntax is assumed:
142 .Bd -literal
143     ((<user>(:<pwd>)?@)?<host>(:<port>)?)?/(<document>)?
144 .Ed
145 .Pp
146 Note that some components of the URL are not necessarily relevant to
147 all URL schemes.
148 For instance, the file scheme only needs the <scheme> and <document>
149 components.
150 .Pp
151 .Fn fetchMakeURL
152 and
153 .Fn fetchParseURL
154 return a pointer to a
155 .Vt url
156 structure, which is defined as follows in
157 .In fetch.h :
158 .Bd -literal
159 #define URL_SCHEMELEN 16
160 #define URL_USERLEN 256
161 #define URL_PWDLEN 256
162
163 struct url {
164     char         scheme[URL_SCHEMELEN+1];
165     char         user[URL_USERLEN+1];
166     char         pwd[URL_PWDLEN+1];
167     char         host[MAXHOSTNAMELEN+1];
168     int          port;
169     char        *doc;
170     off_t        offset;
171     size_t       length;
172     time_t       ims_time;
173 };
174 .Ed
175 .Pp
176 The
177 .Va ims_time
178 field stores the time value for
179 .Li If-Modified-Since
180 HTTP requests.
181 .Pp
182 The pointer returned by
183 .Fn fetchMakeURL
184 or
185 .Fn fetchParseURL
186 should be freed using
187 .Fn fetchFreeURL .
188 .Pp
189 .Fn fetchXGetURL ,
190 .Fn fetchGetURL ,
191 and
192 .Fn fetchPutURL
193 constitute the recommended interface to the
194 .Nm fetch
195 library.
196 They examine the URL passed to them to determine the transfer
197 method, and call the appropriate lower-level functions to perform the
198 actual transfer.
199 .Fn fetchXGetURL
200 also returns the remote document's metadata in the
201 .Vt url_stat
202 structure pointed to by the
203 .Fa us
204 argument.
205 .Pp
206 The
207 .Fa flags
208 argument is a string of characters which specify transfer options.
209 The
210 meaning of the individual flags is scheme-dependent, and is detailed
211 in the appropriate section below.
212 .Pp
213 .Fn fetchStatURL
214 attempts to obtain the requested document's metadata and fill in the
215 structure pointed to by its second argument.
216 The
217 .Vt url_stat
218 structure is defined as follows in
219 .In fetch.h :
220 .Bd -literal
221 struct url_stat {
222     off_t        size;
223     time_t       atime;
224     time_t       mtime;
225 };
226 .Ed
227 .Pp
228 If the size could not be obtained from the server, the
229 .Fa size
230 field is set to -1.
231 If the modification time could not be obtained from the server, the
232 .Fa mtime
233 field is set to the epoch.
234 If the access time could not be obtained from the server, the
235 .Fa atime
236 field is set to the modification time.
237 .Pp
238 .Fn fetchListURL
239 attempts to list the contents of the directory pointed to by the URL
240 provided.
241 If successful, it returns a malloced array of
242 .Vt url_ent
243 structures.
244 The
245 .Vt url_ent
246 structure is defined as follows in
247 .In fetch.h :
248 .Bd -literal
249 struct url_ent {
250     char         name[PATH_MAX];
251     struct url_stat stat;
252 };
253 .Ed
254 .Pp
255 The list is terminated by an entry with an empty name.
256 .Pp
257 The pointer returned by
258 .Fn fetchListURL
259 should be freed using
260 .Fn free .
261 .Pp
262 .Fn fetchXGet ,
263 .Fn fetchGet ,
264 .Fn fetchPut
265 and
266 .Fn fetchStat
267 are similar to
268 .Fn fetchXGetURL ,
269 .Fn fetchGetURL ,
270 .Fn fetchPutURL
271 and
272 .Fn fetchStatURL ,
273 except that they expect a pre-parsed URL in the form of a pointer to
274 a
275 .Vt struct url
276 rather than a string.
277 .Pp
278 All of the
279 .Fn fetchXGetXXX ,
280 .Fn fetchGetXXX
281 and
282 .Fn fetchPutXXX
283 functions return a pointer to a stream which can be used to read or
284 write data from or to the requested document, respectively.
285 Note that
286 although the implementation details of the individual access methods
287 vary, it can generally be assumed that a stream returned by one of the
288 .Fn fetchXGetXXX
289 or
290 .Fn fetchGetXXX
291 functions is read-only, and that a stream returned by one of the
292 .Fn fetchPutXXX
293 functions is write-only.
294 .Sh FILE SCHEME
295 .Fn fetchXGetFile ,
296 .Fn fetchGetFile
297 and
298 .Fn fetchPutFile
299 provide access to documents which are files in a locally mounted file
300 system.
301 Only the <document> component of the URL is used.
302 .Pp
303 .Fn fetchXGetFile
304 and
305 .Fn fetchGetFile
306 do not accept any flags.
307 .Pp
308 .Fn fetchPutFile
309 accepts the
310 .Ql a
311 (append to file) flag.
312 If that flag is specified, the data written to
313 the stream returned by
314 .Fn fetchPutFile
315 will be appended to the previous contents of the file, instead of
316 replacing them.
317 .Sh FTP SCHEME
318 .Fn fetchXGetFTP ,
319 .Fn fetchGetFTP
320 and
321 .Fn fetchPutFTP
322 implement the FTP protocol as described in RFC959.
323 .Pp
324 If the
325 .Ql P
326 (not passive) flag is specified, an active (rather than passive)
327 connection will be attempted.
328 .Pp
329 The
330 .Ql p
331 flag is supported for compatibility with earlier versions where active
332 connections were the default.
333 It has precedence over the
334 .Ql P
335 flag, so if both are specified,
336 .Nm
337 will use a passive connection.
338 .Pp
339 If the
340 .Ql l
341 (low) flag is specified, data sockets will be allocated in the low (or
342 default) port range instead of the high port range (see
343 .Xr ip 4 ) .
344 .Pp
345 If the
346 .Ql d
347 (direct) flag is specified,
348 .Fn fetchXGetFTP ,
349 .Fn fetchGetFTP
350 and
351 .Fn fetchPutFTP
352 will use a direct connection even if a proxy server is defined.
353 .Pp
354 If no user name or password is given, the
355 .Nm fetch
356 library will attempt an anonymous login, with user name "anonymous"
357 and password "anonymous@<hostname>".
358 .Sh HTTP SCHEME
359 The
360 .Fn fetchXGetHTTP ,
361 .Fn fetchGetHTTP ,
362 .Fn fetchPutHTTP
363 and
364 .Fn fetchReqHTTP
365 functions implement the HTTP/1.1 protocol.
366 With a little luck, there is
367 even a chance that they comply with RFC2616 and RFC2617.
368 .Pp
369 If the
370 .Ql d
371 (direct) flag is specified,
372 .Fn fetchXGetHTTP ,
373 .Fn fetchGetHTTP
374 and
375 .Fn fetchPutHTTP
376 will use a direct connection even if a proxy server is defined.
377 .Pp
378 If the
379 .Ql i
380 (if-modified-since) flag is specified, and
381 the
382 .Va ims_time
383 field is set in
384 .Vt "struct url" ,
385 then
386 .Fn fetchXGetHTTP
387 and
388 .Fn fetchGetHTTP
389 will send a conditional
390 .Li If-Modified-Since
391 HTTP header to only fetch the content if it is newer than
392 .Va ims_time .
393 .Pp
394 The function
395 .Fn fetchReqHTTP
396 can be used to make requests with an arbitrary HTTP verb,
397 including POST, DELETE, CONNECT, OPTIONS, TRACE or PATCH.
398 This can be done by setting the argument
399 .Fa method
400 to the intended verb, such as
401 .Ql POST ,
402 and
403 .Fa body
404 to the content.
405 .Pp
406 Since there seems to be no good way of implementing the HTTP PUT
407 method in a manner consistent with the rest of the
408 .Nm fetch
409 library,
410 .Fn fetchPutHTTP
411 is currently unimplemented.
412 .Sh HTTPS SCHEME
413 Based on HTTP SCHEME.
414 By default the peer is verified using the CA bundle located in
415 .Pa /usr/local/etc/ssl/cert.pem .
416 If this file does not exist,
417 .Pa /etc/ssl/cert.pem
418 is used instead.
419 If neither file exists, and
420 .Ev SSL_CA_CERT_PATH
421 has not been set,
422 OpenSSL's default CA cert and path settings apply.
423 The certificate bundle can contain multiple CA certificates.
424 A common source of a current CA bundle is
425 .Pa \%security/ca_root_nss .
426 .Pp
427 The CA bundle used for peer verification can be changed by setting the
428 environment variables
429 .Ev SSL_CA_CERT_FILE
430 to point to a concatenated bundle of trusted certificates and
431 .Ev SSL_CA_CERT_PATH
432 to point to a directory containing hashes of trusted CAs (see
433 .Xr verify 1 ) .
434 .Pp
435 A certificate revocation list (CRL) can be used by setting the
436 environment variable
437 .Ev SSL_CRL_FILE
438 (see
439 .Xr crl 1 ) .
440 .Pp
441 Peer verification can be disabled by setting the environment variable
442 .Ev SSL_NO_VERIFY_PEER .
443 Note that this also disables CRL checking.
444 .Pp
445 By default the service identity is verified according to the rules
446 detailed in RFC6125 (also known as hostname verification).
447 This feature can be disabled by setting the environment variable
448 .Ev SSL_NO_VERIFY_HOSTNAME .
449 .Pp
450 Client certificate based authentication is supported.
451 The environment variable
452 .Ev SSL_CLIENT_CERT_FILE
453 should be set to point to a file containing key and client certificate
454 to be used in PEM format.
455 When a PEM-format key is in a separate file from the client certificate,
456 the environment variable
457 .Ev SSL_CLIENT_KEY_FILE
458 can be set to point to the key file.
459 In case the key uses a password, the user will be prompted on standard
460 input (see
461 .Xr PEM 3 ) .
462 .Pp
463 By default
464 .Nm libfetch
465 allows TLSv1 and newer when negotiating the connecting with the remote
466 peer.
467 You can change this behavior by setting the
468 .Ev SSL_ALLOW_SSL3
469 environment variable to allow SSLv3 and
470 .Ev SSL_NO_TLS1 ,
471 .Ev SSL_NO_TLS1_1 and
472 .Ev SSL_NO_TLS1_2
473 to disable TLS 1.0, 1.1 and 1.2 respectively.
474 .Sh AUTHENTICATION
475 Apart from setting the appropriate environment variables and
476 specifying the user name and password in the URL or the
477 .Vt struct url ,
478 the calling program has the option of defining an authentication
479 function with the following prototype:
480 .Pp
481 .Ft int
482 .Fn myAuthMethod "struct url *u"
483 .Pp
484 The callback function should fill in the
485 .Fa user
486 and
487 .Fa pwd
488 fields in the provided
489 .Vt struct url
490 and return 0 on success, or any other value to indicate failure.
491 .Pp
492 To register the authentication callback, simply set
493 .Va fetchAuthMethod
494 to point at it.
495 The callback will be used whenever a site requires authentication and
496 the appropriate environment variables are not set.
497 .Pp
498 This interface is experimental and may be subject to change.
499 .Sh RETURN VALUES
500 .Fn fetchParseURL
501 returns a pointer to a
502 .Vt struct url
503 containing the individual components of the URL.
504 If it is
505 unable to allocate memory, or the URL is syntactically incorrect,
506 .Fn fetchParseURL
507 returns a NULL pointer.
508 .Pp
509 The
510 .Fn fetchStat
511 functions return 0 on success and -1 on failure.
512 .Pp
513 All other functions return a stream pointer which may be used to
514 access the requested document, or NULL if an error occurred.
515 .Pp
516 The following error codes are defined in
517 .In fetch.h :
518 .Bl -tag -width 18n
519 .It Bq Er FETCH_ABORT
520 Operation aborted
521 .It Bq Er FETCH_AUTH
522 Authentication failed
523 .It Bq Er FETCH_DOWN
524 Service unavailable
525 .It Bq Er FETCH_EXISTS
526 File exists
527 .It Bq Er FETCH_FULL
528 File system full
529 .It Bq Er FETCH_INFO
530 Informational response
531 .It Bq Er FETCH_MEMORY
532 Insufficient memory
533 .It Bq Er FETCH_MOVED
534 File has moved
535 .It Bq Er FETCH_NETWORK
536 Network error
537 .It Bq Er FETCH_OK
538 No error
539 .It Bq Er FETCH_PROTO
540 Protocol error
541 .It Bq Er FETCH_RESOLV
542 Resolver error
543 .It Bq Er FETCH_SERVER
544 Server error
545 .It Bq Er FETCH_TEMP
546 Temporary error
547 .It Bq Er FETCH_TIMEOUT
548 Operation timed out
549 .It Bq Er FETCH_UNAVAIL
550 File is not available
551 .It Bq Er FETCH_UNKNOWN
552 Unknown error
553 .It Bq Er FETCH_URL
554 Invalid URL
555 .El
556 .Pp
557 The accompanying error message includes a protocol-specific error code
558 and message, like "File is not available (404 Not Found)"
559 .Sh ENVIRONMENT
560 .Bl -tag -width ".Ev FETCH_BIND_ADDRESS"
561 .It Ev FETCH_BIND_ADDRESS
562 Specifies a hostname or IP address to which sockets used for outgoing
563 connections will be bound.
564 .It Ev FTP_LOGIN
565 Default FTP login if none was provided in the URL.
566 .It Ev FTP_PASSIVE_MODE
567 If set to
568 .Ql no ,
569 forces the FTP code to use active mode.
570 If set to any other value, forces passive mode even if the application
571 requested active mode.
572 .It Ev FTP_PASSWORD
573 Default FTP password if the remote server requests one and none was
574 provided in the URL.
575 .It Ev FTP_PROXY
576 URL of the proxy to use for FTP requests.
577 The document part is ignored.
578 FTP and HTTP proxies are supported; if no scheme is specified, FTP is
579 assumed.
580 If the proxy is an FTP proxy,
581 .Nm libfetch
582 will send
583 .Ql user@host
584 as user name to the proxy, where
585 .Ql user
586 is the real user name, and
587 .Ql host
588 is the name of the FTP server.
589 .Pp
590 If this variable is set to an empty string, no proxy will be used for
591 FTP requests, even if the
592 .Ev HTTP_PROXY
593 variable is set.
594 .It Ev ftp_proxy
595 Same as
596 .Ev FTP_PROXY ,
597 for compatibility.
598 .It Ev HTTP_ACCEPT
599 Specifies the value of the
600 .Va Accept
601 header for HTTP requests.
602 If empty, no
603 .Va Accept
604 header is sent.
605 The default is
606 .Dq */* .
607 .It Ev HTTP_AUTH
608 Specifies HTTP authorization parameters as a colon-separated list of
609 items.
610 The first and second item are the authorization scheme and realm
611 respectively; further items are scheme-dependent.
612 Currently, the
613 .Dq basic
614 and
615 .Dq digest
616 authorization methods are supported.
617 .Pp
618 Both methods require two parameters: the user name and
619 password, in that order.
620 .Pp
621 This variable is only used if the server requires authorization and
622 no user name or password was specified in the URL.
623 .It Ev HTTP_PROXY
624 URL of the proxy to use for HTTP requests.
625 The document part is ignored.
626 Only HTTP proxies are supported for HTTP requests.
627 If no port number is specified, the default is 3128.
628 .Pp
629 Note that this proxy will also be used for FTP documents, unless the
630 .Ev FTP_PROXY
631 variable is set.
632 .It Ev http_proxy
633 Same as
634 .Ev HTTP_PROXY ,
635 for compatibility.
636 .It Ev HTTP_PROXY_AUTH
637 Specifies authorization parameters for the HTTP proxy in the same
638 format as the
639 .Ev HTTP_AUTH
640 variable.
641 .Pp
642 This variable is used if and only if connected to an HTTP proxy, and
643 is ignored if a user and/or a password were specified in the proxy
644 URL.
645 .It Ev HTTP_REFERER
646 Specifies the referrer URL to use for HTTP requests.
647 If set to
648 .Dq auto ,
649 the document URL will be used as referrer URL.
650 .It Ev HTTP_USER_AGENT
651 Specifies the User-Agent string to use for HTTP requests.
652 This can be useful when working with HTTP origin or proxy servers that
653 differentiate between user agents.
654 If defined but empty, no User-Agent header is sent.
655 .It Ev NETRC
656 Specifies a file to use instead of
657 .Pa ~/.netrc
658 to look up login names and passwords for FTP and HTTP sites as well as
659 HTTP proxies.
660 See
661 .Xr ftp 1
662 for a description of the file format.
663 .It Ev NO_PROXY
664 Either a single asterisk, which disables the use of proxies
665 altogether, or a comma- or whitespace-separated list of hosts for
666 which proxies should not be used.
667 .It Ev no_proxy
668 Same as
669 .Ev NO_PROXY ,
670 for compatibility.
671 .It Ev SSL_ALLOW_SSL3
672 Allow SSL version 3 when negotiating the connection (not recommended).
673 .It Ev SSL_CA_CERT_FILE
674 CA certificate bundle containing trusted CA certificates.
675 Default value: See HTTPS SCHEME above.
676 .It Ev SSL_CA_CERT_PATH
677 Path containing trusted CA hashes.
678 .It Ev SSL_CLIENT_CERT_FILE
679 PEM encoded client certificate/key which will be used in
680 client certificate authentication.
681 .It Ev SSL_CLIENT_KEY_FILE
682 PEM encoded client key in case key and client certificate
683 are stored separately.
684 .It Ev SSL_CRL_FILE
685 File containing certificate revocation list.
686 .It Ev SSL_NO_TLS1
687 Do not allow TLS version 1.0 when negotiating the connection.
688 .It Ev SSL_NO_TLS1_1
689 Do not allow TLS version 1.1 when negotiating the connection.
690 .It Ev SSL_NO_TLS1_2
691 Do not allow TLS version 1.2 when negotiating the connection.
692 .It Ev SSL_NO_VERIFY_HOSTNAME
693 If set, do not verify that the hostname matches the subject of the
694 certificate presented by the server.
695 .It Ev SSL_NO_VERIFY_PEER
696 If set, do not verify the peer certificate against trusted CAs.
697 .El
698 .Sh EXAMPLES
699 To access a proxy server on
700 .Pa proxy.example.com
701 port 8080, set the
702 .Ev HTTP_PROXY
703 environment variable in a manner similar to this:
704 .Pp
705 .Dl HTTP_PROXY=http://proxy.example.com:8080
706 .Pp
707 If the proxy server requires authentication, there are
708 two options available for passing the authentication data.
709 The first method is by using the proxy URL:
710 .Pp
711 .Dl HTTP_PROXY=http://<user>:<pwd>@proxy.example.com:8080
712 .Pp
713 The second method is by using the
714 .Ev HTTP_PROXY_AUTH
715 environment variable:
716 .Bd -literal -offset indent
717 HTTP_PROXY=http://proxy.example.com:8080
718 HTTP_PROXY_AUTH=basic:*:<user>:<pwd>
719 .Ed
720 .Pp
721 To disable the use of a proxy for an HTTP server running on the local
722 host, define
723 .Ev NO_PROXY
724 as follows:
725 .Bd -literal -offset indent
726 NO_PROXY=localhost,127.0.0.1
727 .Ed
728 .Pp
729 Access HTTPS website without any certificate verification whatsoever:
730 .Bd -literal -offset indent
731 SSL_NO_VERIFY_PEER=1
732 SSL_NO_VERIFY_HOSTNAME=1
733 .Ed
734 .Pp
735 Access HTTPS website using client certificate based authentication
736 and a private CA:
737 .Bd -literal -offset indent
738 SSL_CLIENT_CERT_FILE=/path/to/client.pem
739 SSL_CA_CERT_FILE=/path/to/myca.pem
740 .Ed
741 .Sh SEE ALSO
742 .Xr fetch 1 ,
743 .Xr ip 4
744 .Rs
745 .%A J. Postel
746 .%A J. K. Reynolds
747 .%D October 1985
748 .%B File Transfer Protocol
749 .%O RFC959
750 .Re
751 .Rs
752 .%A P. Deutsch
753 .%A A. Emtage
754 .%A A. Marine.
755 .%D May 1994
756 .%T How to Use Anonymous FTP
757 .%O RFC1635
758 .Re
759 .Rs
760 .%A T. Berners-Lee
761 .%A L. Masinter
762 .%A M. McCahill
763 .%D December 1994
764 .%T Uniform Resource Locators (URL)
765 .%O RFC1738
766 .Re
767 .Rs
768 .%A R. Fielding
769 .%A J. Gettys
770 .%A J. Mogul
771 .%A H. Frystyk
772 .%A L. Masinter
773 .%A P. Leach
774 .%A T. Berners-Lee
775 .%D January 1999
776 .%B Hypertext Transfer Protocol -- HTTP/1.1
777 .%O RFC2616
778 .Re
779 .Rs
780 .%A J. Franks
781 .%A P. Hallam-Baker
782 .%A J. Hostetler
783 .%A S. Lawrence
784 .%A P. Leach
785 .%A A. Luotonen
786 .%A L. Stewart
787 .%D June 1999
788 .%B HTTP Authentication: Basic and Digest Access Authentication
789 .%O RFC2617
790 .Re
791 .Sh HISTORY
792 The
793 .Nm fetch
794 library first appeared in
795 .Fx 3.0 .
796 .Sh AUTHORS
797 .An -nosplit
798 The
799 .Nm fetch
800 library was mostly written by
801 .An Dag-Erling Sm\(/orgrav Aq Mt des@FreeBSD.org
802 with numerous suggestions and contributions from
803 .An Jordan K. Hubbard Aq Mt jkh@FreeBSD.org ,
804 .An Eugene Skepner Aq Mt eu@qub.com ,
805 .An Hajimu Umemoto Aq Mt ume@FreeBSD.org ,
806 .An Henry Whincup Aq Mt henry@techiebod.com ,
807 .An Jukka A. Ukkonen Aq Mt jau@iki.fi ,
808 .An Jean-Fran\(,cois Dockes Aq Mt jf@dockes.org ,
809 .An Michael Gmelin Aq Mt freebsd@grem.de
810 and others.
811 It replaces the older
812 .Nm ftpio
813 library written by
814 .An Poul-Henning Kamp Aq Mt phk@FreeBSD.org
815 and
816 .An Jordan K. Hubbard Aq Mt jkh@FreeBSD.org .
817 .Pp
818 This manual page was written by
819 .An Dag-Erling Sm\(/orgrav Aq Mt des@FreeBSD.org
820 and
821 .An Michael Gmelin Aq Mt freebsd@grem.de .
822 .Sh BUGS
823 Some parts of the library are not yet implemented.
824 The most notable
825 examples of this are
826 .Fn fetchPutHTTP ,
827 .Fn fetchListHTTP ,
828 .Fn fetchListFTP
829 and FTP proxy support.
830 .Pp
831 There is no way to select a proxy at run-time other than setting the
832 .Ev HTTP_PROXY
833 or
834 .Ev FTP_PROXY
835 environment variables as appropriate.
836 .Pp
837 .Nm libfetch
838 does not understand or obey 305 (Use Proxy) replies.
839 .Pp
840 Error numbers are unique only within a certain context; the error
841 codes used for FTP and HTTP overlap, as do those used for resolver and
842 system errors.
843 For instance, error code 202 means "Command not
844 implemented, superfluous at this site" in an FTP context and
845 "Accepted" in an HTTP context.
846 .Pp
847 .Fn fetchStatFTP
848 does not check that the result of an MDTM command is a valid date.
849 .Pp
850 In case password protected keys are used for client certificate based
851 authentication the user is prompted for the password on each and every
852 fetch operation.
853 .Pp
854 The man page is incomplete, poorly written and produces badly
855 formatted text.
856 .Pp
857 The error reporting mechanism is unsatisfactory.
858 .Pp
859 Some parts of the code are not fully reentrant.