Enabling HTTPS support in curl installed through MacPorts on OSX

2009/03/16

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
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
<A HREF="http://www.google.com">here</A>.
</BODY></HTML>

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 :).

There are 18 comments in this article:

  1. 2009/03/17Brian Michelich say:

    The forced upgrade failed for me, probably something hidden in this warning:
    Warning: Uninstall forced. Proceeding despite dependencies.

    The result was curl -k https://www.google.com didn’t error, but no content was displayed.

    This may have been caused by a dependency with git-core and curl. Uninstalling git-core, reinstalling curl +ssl, installing git-core then worked.

  2. 2009/03/17tednaleid say:

    Yep, if you have git-core installed with macports, you’ll want to uninstall that first. Sorry, I did run across that when I was working, but failed to mention that in my post above. That’s partially why I think it’s safer to do the uninstall of curl rather than forcing the upgrade. If you tell curl to uninstall, it will say it can’t because git-core depends on it.

    I’ll edit the above post to have a warning about that, thanks for the feedback.

  3. 2009/04/22Scott say:

    Excellent, this works nicely with git-core as you detailed.

    port uninstall git-core
    port uninstall curl
    port install curl +ssl
    port install git-core

    Thanks for the tip.

  4. 2009/05/10Sharif say:

    thank you thank you thank you. after hours of wondering whether i would have to finally lay my powerpc xserve to rest because i couldn’t get it to poll ebay API, this has worked and given me new hope.

  5. 2009/05/11Gil say:

    I ran into the same issue today. Thanks for the tip!

  6. 2009/05/16Ben say:

    Thanks! This would’ve driven me crazy!

  7. 2009/07/21Björn’s Blog » Blog Archive » Setting up a git repository that is accessible via HTTP WebDAV say:

    [...] curl on OS X does not even have ssl support built in if it is installed via MacPorts. I found a blog article on enabling https support which explains that the remedy is to install curl with options as follows: sudo port install curl [...]

  8. 2009/08/8Adam Rosenfield say:

    This worked for me:

    port deactivate curl
    port install curl +ssl

    I don’t have git-core, but I do have gimp (which depends on curl); gimp still seems to be working fine after the above commands.

  9. 2009/08/17Paul O’Shannessy say:

    Using the upgrade command worked for me. I don’t know if it broke git yet, but curl works. Thanks for the tip!

  10. 2009/08/31Adam say:

    Great tip! Much appreciated

  11. 2009/09/3Mo say:

    Thanks so much,
    This helped me when I was trying to install zen-cart. I installed apache, php, and mysql with macports but curl didn’t come with ssl support.

  12. 2009/10/1Matt White say:

    Thankyouthankyouthankyouthankyou… I was really beating my head against the wall with this one. Your answer took care of it right away!

  13. 2009/10/9Anonymous say:

    Thanks like 9000 times!!

  14. 2009/11/17neslob say:

    Thanks:
    sudo port install curl +ssl
    worked fine for me.

  15. 2009/12/16Eugene say:

    Worked great, thanks much!

  16. 2010/01/29Michael say:

    Thanks. That saved me some time!

  17. 2010/03/2Thomas Glasgow say:

    Thanks for the blog post. I just ran into this https issue. To bad that ssl isn’t compiled by default.

  18. 2010/07/4Chester say:

    Scott’s solution (uninstall git-core, uninstall curl, reinstall curl with ssh, then reinstall git-core) worked fine for me also.

    But I could have tried deactivating instead of uninstalling for git-core (should have read until the end :-P ).

    Anyway, this one really helped me, git is working fine and curl now “speaks” https. Thank you guys!

Write a comment: