Ying-Chun Liu (PaulLiu) | 2dbb7a4 | 2022-11-08 14:17:30 +0800 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+: |
| 2 | |
Heinrich Schuchardt | 1b0c316 | 2024-01-14 14:53:13 +0100 | [diff] [blame] | 3 | .. index:: |
| 4 | single: wget (command) |
| 5 | |
Ying-Chun Liu (PaulLiu) | 2dbb7a4 | 2022-11-08 14:17:30 +0800 | [diff] [blame] | 6 | wget command |
| 7 | ============ |
| 8 | |
| 9 | Synopsis |
| 10 | -------- |
| 11 | |
| 12 | :: |
Heinrich Schuchardt | 311fe21 | 2022-12-22 11:32:03 +0100 | [diff] [blame] | 13 | |
Jerome Forissier | d67fae6 | 2024-11-18 10:18:01 +0100 | [diff] [blame] | 14 | wget [address] [host:]path |
Jerome Forissier | 6d1225e | 2025-03-05 15:26:46 +0100 | [diff] [blame] | 15 | wget [address] url # lwIP only |
| 16 | wget cacert none|optional|required # lwIP only |
| 17 | wget cacert <address> <size> # lwIP only |
Jerome Forissier | d67fae6 | 2024-11-18 10:18:01 +0100 | [diff] [blame] | 18 | |
Ying-Chun Liu (PaulLiu) | 2dbb7a4 | 2022-11-08 14:17:30 +0800 | [diff] [blame] | 19 | |
| 20 | Description |
| 21 | ----------- |
| 22 | |
Jerome Forissier | d67fae6 | 2024-11-18 10:18:01 +0100 | [diff] [blame] | 23 | The wget command is used to download a file from an HTTP(S) server. |
| 24 | In order to use HTTPS you will need to compile wget with lwIP support. |
| 25 | |
| 26 | Legacy syntax |
| 27 | ~~~~~~~~~~~~~ |
Ying-Chun Liu (PaulLiu) | 2dbb7a4 | 2022-11-08 14:17:30 +0800 | [diff] [blame] | 28 | |
Jerome Forissier | d67fae6 | 2024-11-18 10:18:01 +0100 | [diff] [blame] | 29 | The legacy syntax is supported by the legacy network stack (CONFIG_NET=y) |
| 30 | as well as by the lwIP base network stack (CONFIG_NET_LWIP=y). It supports HTTP |
| 31 | only. |
| 32 | |
Marek Vasut | 22a9508 | 2023-12-13 22:11:13 +0100 | [diff] [blame] | 33 | By default the destination port is 80 and the source port is pseudo-random. |
Jerome Forissier | d67fae6 | 2024-11-18 10:18:01 +0100 | [diff] [blame] | 34 | On the legacy nework stack the environment variable *httpdstp* can be used to |
| 35 | set the destination port |
Ying-Chun Liu (PaulLiu) | 2dbb7a4 | 2022-11-08 14:17:30 +0800 | [diff] [blame] | 36 | |
| 37 | address |
| 38 | memory address for the data downloaded |
| 39 | |
Jerome Forissier | d67fae6 | 2024-11-18 10:18:01 +0100 | [diff] [blame] | 40 | host |
| 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) | 2dbb7a4 | 2022-11-08 14:17:30 +0800 | [diff] [blame] | 43 | |
| 44 | path |
| 45 | path of the file to be downloaded. |
| 46 | |
Jerome Forissier | d67fae6 | 2024-11-18 10:18:01 +0100 | [diff] [blame] | 47 | New syntax (lwIP only) |
| 48 | ~~~~~~~~~~~~~~~~~~~~~~ |
| 49 | |
| 50 | In addition to the syntax described above, wget accepts URLs if the network |
| 51 | stack is lwIP. |
| 52 | |
| 53 | address |
| 54 | memory address for the data downloaded |
| 55 | |
| 56 | url |
| 57 | HTTP or HTTPS URL, that is: http[s]://<host>[:<port>]/<path>. |
| 58 | |
Jerome Forissier | 6d1225e | 2025-03-05 15:26:46 +0100 | [diff] [blame] | 59 | The cacert (stands for 'Certification Authority certificates') subcommand is |
| 60 | used to provide root certificates for the purpose of HTTPS authentication. It |
| 61 | also allows to enable or disable authentication. |
| 62 | |
| 63 | wget cacert <address> <size> |
| 64 | |
| 65 | address |
| 66 | memory address of the root certificates in X509 DER format |
| 67 | |
| 68 | size |
| 69 | the size of the root certificates |
| 70 | |
| 71 | wget cacert none|optional|required |
| 72 | |
| 73 | none |
| 74 | certificate verification is disabled. HTTPS is used without any server |
| 75 | authentication (unsafe) |
| 76 | optional |
| 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). |
| 80 | required |
| 81 | certificate verification is mandatory. If no root certificates have been |
| 82 | configured, HTTPS transfers will fail. |
| 83 | |
| 84 | |
Jerome Forissier | d67fae6 | 2024-11-18 10:18:01 +0100 | [diff] [blame] | 85 | Examples |
| 86 | -------- |
| 87 | |
| 88 | Example with the legacy network stack |
| 89 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
Ying-Chun Liu (PaulLiu) | 2dbb7a4 | 2022-11-08 14:17:30 +0800 | [diff] [blame] | 90 | |
| 91 | In 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 Forissier | d67fae6 | 2024-11-18 10:18:01 +0100 | [diff] [blame] | 108 | Example with lwIP |
| 109 | ~~~~~~~~~~~~~~~~~ |
| 110 | |
| 111 | In 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 Forissier | 6d1225e | 2025-03-05 15:26:46 +0100 | [diff] [blame] | 128 | Here is an example showing how to configure built-in root certificates as |
| 129 | well as providing some at run time. In this example it is assumed that |
| 130 | CONFIG_WGET_BUILTIN_CACERT_PATH=DigiCertTLSRSA4096RootG5.crt downloaded from |
| 131 | https://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) | 2dbb7a4 | 2022-11-08 14:17:30 +0800 | [diff] [blame] | 175 | Configuration |
| 176 | ------------- |
| 177 | |
| 178 | The command is only available if CONFIG_CMD_WGET=y. |
Jerome Forissier | 6d1225e | 2025-03-05 15:26:46 +0100 | [diff] [blame] | 179 | To enable lwIP support set CONFIG_NET_LWIP=y. In this case, root certificates |
| 180 | support can be enabled via CONFIG_WGET_BUILTIN_CACERT=y |
| 181 | CONFIG_WGET_BUILTIN_CACERT_PATH=<some path> (for built-in certificates) and/or |
| 182 | CONFIG_WGET_CACERT=y (for the wget cacert command). |
Jerome Forissier | d67fae6 | 2024-11-18 10:18:01 +0100 | [diff] [blame] | 183 | |
| 184 | TCP Selective Acknowledgments in the legacy network stack can be enabled via |
| 185 | CONFIG_PROT_TCP_SACK=y. This will improve the download speed. Selective |
| 186 | Acknowledgments are enabled by default with lwIP. |
| 187 | |
| 188 | .. note:: |
Ying-Chun Liu (PaulLiu) | 2dbb7a4 | 2022-11-08 14:17:30 +0800 | [diff] [blame] | 189 | |
Jerome Forissier | d67fae6 | 2024-11-18 10:18:01 +0100 | [diff] [blame] | 190 | 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) | 2dbb7a4 | 2022-11-08 14:17:30 +0800 | [diff] [blame] | 194 | |
| 195 | Return value |
| 196 | ------------ |
| 197 | |
| 198 | The return value $? is 0 (true) on success and 1 (false) otherwise. |