iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
😆

Using a better version of curl on macOS

に公開
brew install curl

The following is an explanation. By the way, as of 2021/02/11, curl-openssl has become an alias for curl, so there is no point in using curl-openssl specifically. The following article has also been edited.
Reference: https://github.com/Homebrew/homebrew-core/pull/58274

curl Pre-installed on Mac

curl is installed on macOS by default. The version is relatively new, and basically, you shouldn't have any trouble with the pre-installed curl.

However, if you want to use TLSv1.3, for example, you need a version of curl compiled with an OpenSSL that supports TLSv1.3. The pre-installed curl on Mac uses LibreSSL, but client-side support for TLSv1.3 in LibreSSL was added quite recently. As of 2020/09/27, the pre-installed curl cannot use TLSv1.3.

Also, since curl's HTTP/2 support uses nghttp2, it must be compiled with nghttp2. While the pre-installed curl is configured to support HTTP/2, it is important to note that it is not supported by default.

Notes on TLS

Please be aware that there have been some incompatible changes between older versions of curl and the current versions. Previously, passing an option like --tlsv1.1 meant "Use TLSv1.1," but in newer versions, the behavior has changed to "Use TLSv1.1 or greater." Always check --help to confirm the behavior of the version you are using. Personally, I think this change is quite poor. If they wanted this behavior, the option should have been named something like --tls-min 1.1, but no such option exists.

So, what should you do if you want to communicate specifically using TLSv1.1? While not exactly the same, a --tls-max option has been added in recent versions (check with --help). By passing the --tls-max 1.1 option, it will limit the communication to a maximum of TLSv1.1.

If you understand the above, you should be able to use curl to verify various behaviors of your middleware.

Discussion