How do I enable curl SSL on Mac OS X?
Asked Answered
T

7

17

I'm using Terminal on Mac OS X 10.11.2 and I can't process any https requests. I always get this error:

curl: (1) Protocol "https" not supported or disabled in libcurl

I tried this but I get a "wrong directory" error:

./configure --with-ssl=/usr/local/ssl

Any advice would be helpful.

EDIT:

This is the error I get when trying to install with ssl:

configure: error: OpenSSL libs and/or directories were not found where specified!

SOLUTION:

For Mac OS X 10.6 or later use this to enable SSL:

./configure --with-darwinssl
Transalpine answered 21/1, 2016 at 2:41 Comment(4)
Have you tried curl --ssl?Mcgriff
"the installed libcurl version doesn't support this" I tried installing Homebrew but can't through Terminal since it's an https request.Transalpine
what was the location of ./configure file in your case?Haruspicy
curl -V will list supported protocols (in addition to the version)Hodgepodge
S
39

The Homebrew team has recently removed all install options for the cURL formula, which means you will not be able to do brew install curl --with-openssl now. Instead, do brew install curl-openssl. Make sure to uninstall the old one with brew uninstall curl first.

Singleaction answered 9/8, 2019 at 15:25 Comment(3)
This is the info I needed and it shouldn't be at the bottom of the page! Everyone else says to use the "--with-openssl" option which is no longer possible. Further, I also had to turn off my antivirus as it was blocking connections to be able to download the cURL packages.Yacano
just to add that after this you need to close the terminal and reopen it. A hour that I won't get back..Sacco
FYI - in 2021, it is proposed to install openssl curl with brew install curl, see this thread: github.com/Homebrew/discussions/discussions/1268Propositus
I
13

Following steps helped fix the issue: (Note: libcurl will be rebuilt though)

# First simply remove curl and try reinstall with openssl:
brew rm curl && brew install curl --with-openssl # Rerun 

If doesn't fix, download and rebuild libcurl with following steps, which helped me fix the issue

# Download curl from : https://curl.haxx.se/download.html
wget https://curl.haxx.se/download/curl-7.58.0.zip  # or, wget https://curl.haxx.se/download/curl-*.*.*
unzip curl-7.58.0.zip  # or, unzip curl-*.*.*

./configure --with-darwinssl  # However for Linux(ubuntu): ./configure --with-ssl 
make
sudo make install  # Rerun the program
Idonna answered 11/3, 2018 at 17:49 Comment(3)
This is a better answer than Ben's and deserves to be accepted. (Vadym Tyemirov's answer didn't work for me.)Hodgepodge
(for others with similarly lackluster shell skills...) you need to cd into the unzipped curl directory before you can run ./configure --with-darwinssl :-)Tissue
When run ./configure --with-darwinssl there is an error occurred. configure: error: C compiler cannot create executablesNonunionism
T
7

SOLUTION:

For Mac OS X 10.6 or later use this to enable SSL:

./configure --with-darwinssl
Transalpine answered 21/1, 2016 at 6:12 Comment(2)
-bash: ./configure: No such file or directory- WHAT TO DO? My Bounty:#39288406Haruspicy
where is curl installed on mac please ?Steger
V
5

Solved it by replacing standard curl with one with nghttp2 support (require brew)

brew install curl --with-nghttp2
brew link curl --force

include --http2 when doing request

example:

curl --http2 https://www.example.com

or:

curl --header 'Access-Token: o.bFbpTuazstlUZXsnyTWTaJq0biZ' \
--http2 https://www.example.com/

Ref: https://daniel.haxx.se/blog/2016/08/01/curl-and-h2-on-mac/ https://simonecarletti.com/blog/2016/01/http2-curl-macosx/

Veasey answered 17/2, 2017 at 20:55 Comment(0)
R
1

I made one rookie mistake by adding the URL within quotation marks (curl -v -k "https://URL.com"). After putting the link within apostrophes (curl -v -k 'https://URL.com') curl was accepting the https URL.

Rivy answered 29/1, 2019 at 14:43 Comment(1)
Removed the quotations and made the link to be like curl https://example.com instead of curl "https://example.com" and it worked. Thanks!Ayeaye
L
1

For anyone that stumbles upon this in 2021 and later using Xcode 12+ attempting to build their project via commandline and doesn't want to rely on 'brew' or other package managers...

I was hitting the ./configure: No such file or directory issue after getting the curl source from github.

The source from github is missing the configure exec. that you need to generate your makefiles

Apple provides the curl source along with required MacOS/iOS build settings in their Open Source Browser:

https://opensource.apple.com/source/curl/

https://opensource.apple.com/release/macos-112.html

  1. Download & unpack the source

  2. Set your env variables - Apple Platforms (macOS, iOS, tvOS, watchOS, and their simulator counterparts)

    export ARCH=arm64

    export SDK=iphoneos

    export DEPLOYMENT_TARGET=11.0

    export CFLAGS="-arch $ARCH -isysroot $(xcrun -sdk $SDK --show-sdk-path) -m$SDK-version-min=$DEPLOYMENT_TARGET"

  3. cd to the /curl directory

  4. run: ./configure --with-darwinssl

My use case is building an iOS app on a hosted macOS build agent in Azure DevOps

Lemar answered 10/5, 2021 at 5:39 Comment(0)
S
1

An updated solution in 2023 for Ventura. First you want to install openssl and then curl with brew:

brew install openssl
brew install curl

Afterwards you need to export the installed curl version to your zsh or whatever shell you using, with the following (change path to /usr/local if running on Intel):

export PATH="/opt/homebrew/opt/curl/bin:$PATH"' >> ~/.zshrc

Then just check with curl -V the available protocols, where you should see https, sftp, etc.

Sharice answered 29/4, 2023 at 12:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.