blob: cc82e495a29b9948f5432aecd6f07faef45824b1 [file] [log] [blame]
Ying-Chun Liu (PaulLiu)2dbb7a42022-11-08 14:17:30 +08001.. SPDX-License-Identifier: GPL-2.0+:
2
Heinrich Schuchardt1b0c3162024-01-14 14:53:13 +01003.. index::
4 single: wget (command)
5
Ying-Chun Liu (PaulLiu)2dbb7a42022-11-08 14:17:30 +08006wget command
7============
8
9Synopsis
10--------
11
12::
Heinrich Schuchardt311fe212022-12-22 11:32:03 +010013
Jerome Forissierd67fae62024-11-18 10:18:01 +010014 wget [address] [host:]path
Jerome Forissier6d1225e2025-03-05 15:26:46 +010015 wget [address] url # lwIP only
16 wget cacert none|optional|required # lwIP only
17 wget cacert <address> <size> # lwIP only
Jerome Forissierd67fae62024-11-18 10:18:01 +010018
Ying-Chun Liu (PaulLiu)2dbb7a42022-11-08 14:17:30 +080019
20Description
21-----------
22
Jerome Forissierd67fae62024-11-18 10:18:01 +010023The wget command is used to download a file from an HTTP(S) server.
24In order to use HTTPS you will need to compile wget with lwIP support.
25
26Legacy syntax
27~~~~~~~~~~~~~
Ying-Chun Liu (PaulLiu)2dbb7a42022-11-08 14:17:30 +080028
Jerome Forissierd67fae62024-11-18 10:18:01 +010029The legacy syntax is supported by the legacy network stack (CONFIG_NET=y)
30as well as by the lwIP base network stack (CONFIG_NET_LWIP=y). It supports HTTP
31only.
32
Marek Vasut22a95082023-12-13 22:11:13 +010033By default the destination port is 80 and the source port is pseudo-random.
Jerome Forissierd67fae62024-11-18 10:18:01 +010034On the legacy nework stack the environment variable *httpdstp* can be used to
35set the destination port
Ying-Chun Liu (PaulLiu)2dbb7a42022-11-08 14:17:30 +080036
37address
38 memory address for the data downloaded
39
Jerome Forissierd67fae62024-11-18 10:18:01 +010040host
41 IP address (or host name if `CONFIG_CMD_DNS` is enabled) of the HTTP
42 server, defaults to the value of environment variable *serverip*.
Ying-Chun Liu (PaulLiu)2dbb7a42022-11-08 14:17:30 +080043
44path
45 path of the file to be downloaded.
46
Jerome Forissierd67fae62024-11-18 10:18:01 +010047New syntax (lwIP only)
48~~~~~~~~~~~~~~~~~~~~~~
49
50In addition to the syntax described above, wget accepts URLs if the network
51stack is lwIP.
52
53address
54 memory address for the data downloaded
55
56url
57 HTTP or HTTPS URL, that is: http[s]://<host>[:<port>]/<path>.
58
Jerome Forissier6d1225e2025-03-05 15:26:46 +010059The cacert (stands for 'Certification Authority certificates') subcommand is
60used to provide root certificates for the purpose of HTTPS authentication. It
61also allows to enable or disable authentication.
62
63wget cacert <address> <size>
64
65address
66 memory address of the root certificates in X509 DER format
67
68size
69 the size of the root certificates
70
71wget cacert none|optional|required
72
73none
74 certificate verification is disabled. HTTPS is used without any server
75 authentication (unsafe)
76optional
77 certificate verification is enabled provided root certificates have been
78 provided via wget cacert <addr> <size> or wget cacert builtin. Otherwise
79 HTTPS is used without any server authentication (unsafe).
80required
81 certificate verification is mandatory. If no root certificates have been
82 configured, HTTPS transfers will fail.
83
84
Jerome Forissierd67fae62024-11-18 10:18:01 +010085Examples
86--------
87
88Example with the legacy network stack
89~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ying-Chun Liu (PaulLiu)2dbb7a42022-11-08 14:17:30 +080090
91In the example the following steps are executed:
92
93* setup client network address
94* download a file from the HTTP server
95
96::
97
98 => setenv autoload no
99 => dhcp
100 BOOTP broadcast 1
101 *** Unhandled DHCP Option in OFFER/ACK: 23
102 *** Unhandled DHCP Option in OFFER/ACK: 23
103 DHCP client bound to address 192.168.1.105 (210 ms)
104 => wget ${loadaddr} 192.168.1.254:/index.html
105 HTTP/1.0 302 Found
106 Packets received 4, Transfer Successful
107
Jerome Forissierd67fae62024-11-18 10:18:01 +0100108Example with lwIP
109~~~~~~~~~~~~~~~~~
110
111In the example the following steps are executed:
112
113* setup client network address
114* download a file from the HTTPS server
115
116::
117
118 => dhcp
119 DHCP client bound to address 10.0.2.15 (3 ms)
120 => wget https://download.rockylinux.org/pub/rocky/9/isos/aarch64/Rocky-9.4-aarch64-minimal.iso
121 ##########################################################################
122 ##########################################################################
123 ##########################################################################
124 [...]
125 1694892032 bytes transferred in 492181 ms (3.3 MiB/s)
126 Bytes transferred = 1694892032 (65060000 hex)
127
Jerome Forissier6d1225e2025-03-05 15:26:46 +0100128Here is an example showing how to configure built-in root certificates as
129well as providing some at run time. In this example it is assumed that
130CONFIG_WGET_BUILTIN_CACERT_PATH=DigiCertTLSRSA4096RootG5.crt downloaded from
131https://cacerts.digicert.com/DigiCertTLSRSA4096RootG5.crt.
132
133::
134
135 # Make sure IP is configured
136 => dhcp
137 # When built-in certificates are configured, authentication is mandatory
138 # (i.e., "wget cacert required"). Use a test server...
139 => wget https://digicert-tls-rsa4096-root-g5.chain-demos.digicert.com/
140 1864 bytes transferred in 1 ms (1.8 MiB/s)
141 Bytes transferred = 1864 (748 hex)
142 # Another server not signed against Digicert will fail
143 => wget https://www.google.com/
144 Certificate verification failed
145
146 HTTP client error 4
147 # Disable authentication to allow the command to proceed anyways
148 => wget cacert none
149 => wget https://www.google.com/
150 WARNING: no CA certificates, HTTPS connections not authenticated
151 16683 bytes transferred in 15 ms (1.1 MiB/s)
152 Bytes transferred = 16683 (412b hex)
153 # Force verification but unregister the CA certificates
154 => wget cacert required
155 => wget cacert 0 0
156 # Unsurprisingly, download fails
157 => wget https://digicert-tls-rsa4096-root-g5.chain-demos.digicert.com/
158 Error: cacert authentication mode is 'required' but no CA certificates given
159 # Get the same certificates as above from the network
160 => wget cacert none
161 => wget https://cacerts.digicert.com/DigiCertTLSRSA4096RootG5.crt
162 WARNING: no CA certificates, HTTPS connections not authenticated
163 1386 bytes transferred in 1 ms (1.3 MiB/s)
164 Bytes transferred = 1386 (56a hex)
165 # Register them and force authentication
166 => wget cacert $fileaddr $filesize
167 => wget cacert required
168 # Authentication is operational again
169 => wget https://digicert-tls-rsa4096-root-g5.chain-demos.digicert.com/
170 1864 bytes transferred in 1 ms (1.8 MiB/s)
171 Bytes transferred = 1864 (748 hex)
172 # The builtin certificates can be restored at any time
173 => wget cacert builtin
174
Ying-Chun Liu (PaulLiu)2dbb7a42022-11-08 14:17:30 +0800175Configuration
176-------------
177
178The command is only available if CONFIG_CMD_WGET=y.
Jerome Forissier6d1225e2025-03-05 15:26:46 +0100179To enable lwIP support set CONFIG_NET_LWIP=y. In this case, root certificates
180support can be enabled via CONFIG_WGET_BUILTIN_CACERT=y
181CONFIG_WGET_BUILTIN_CACERT_PATH=<some path> (for built-in certificates) and/or
182CONFIG_WGET_CACERT=y (for the wget cacert command).
Jerome Forissierd67fae62024-11-18 10:18:01 +0100183
184TCP Selective Acknowledgments in the legacy network stack can be enabled via
185CONFIG_PROT_TCP_SACK=y. This will improve the download speed. Selective
186Acknowledgments are enabled by default with lwIP.
187
188.. note::
Ying-Chun Liu (PaulLiu)2dbb7a42022-11-08 14:17:30 +0800189
Jerome Forissierd67fae62024-11-18 10:18:01 +0100190 U-Boot currently has no way to verify certificates for HTTPS.
191 A place to store the root CA certificates is needed, and then MBed TLS would
192 need to walk the entire chain. Therefore, man-in-the middle attacks are
193 possible and HTTPS should not be relied upon for payload authentication.
Ying-Chun Liu (PaulLiu)2dbb7a42022-11-08 14:17:30 +0800194
195Return value
196------------
197
198The return value $? is 0 (true) on success and 1 (false) otherwise.