Enabling HTTPS Support in Curl Installed Through MacPorts on OSX

| Comments

I ran into an issue today when trying to use curl to post something to an https endpoint on one of my Grails applications. Apparently, recent macports versions of curl don’t have full ssl support enabled by default (I have no idea why, this seems like one of the basic use cases of curl).

This is what I was seeing:

% curl -k https://www.google.com
curl: (1) Protocol https not supported or disabled in libcurl

After a bunch of fiddling around looking at the Portfile (located at /opt/local/var/macports/sources/rsync.macports.org/release/ports/net/curl/Portfile), I saw that there was something called a variant that seemed to talk about ssl support.

I’d never needed to install a variant of a port before, but it’s actually pretty easy to do. Just add a “+” with the variant name at the end of the install command.

sudo port install curl +ssl

After that, curl did exactly what I was expecting it to:

% curl -k https://www.google.com

302 Moved

302 Moved

The document has moved here.

So if you’ve already got curl installed with macports, you’ll probably want to uninstall it, then clean to be sure, then reinstall with the variant name:

sudo port uninstall curl
sudo port clean curl
sudo port install curl +ssl

From the documentation, it appears that it also works for the upgrade command as well, so I believe you could force an upgrade and get it to install the curl ssl variant with:

sudo port -f upgrade curl +ssl

I haven’t tested this though, so I can’t say with 100% certainty that it will work.

UPDATE: Brian Michelich tried this and ran into some issues because he had git-core installed through macports. Git-core relies on curl so forcing an upgrade could potentially bork anything that relies on curl. The safest thing is likely to uninstall curl as macports will let you know if anything relies on it before you remove it.

If you want to check if you have any dependencies, you can use the “dependents” command:

port dependents curl

I hope this helps someone (possibly me, in 6 months when I’m setting up my next computer :).