Behavior of `curl` and `sudo curl` is different when testing API


#1

I’ve been having a lot of trouble getting various API wrappers working on my computer, and I think I’ve narrowed down the problem, or at least identified a problem.

I went to oauth tools and constructed a query, and then copied the curl command to my command line.

The regular curl failed as follows:

`* Hostname was NOT found in DNS cache

  • Trying 199.59.149.232…
  • Connected to api.twitter.com (199.59.149.232) port 443 (#0)
  • error setting certificate verify locations:
    CAfile: /etc/pki/tls/certs/ca-bundle.crt
    CApath: none
  • Closing connection 0
    curl: (77) error setting certificate verify locations:
    CAfile: /etc/pki/tls/certs/ca-bundle.crt
    CApath: none`

However, running sudo curl worked just fine, and I received the expected output.

I can’t figure out why this is the case, and it doesn’t yet help me with getting my API wrapper calls working, since I can’t elevate a python script with sudo.

I’m running Ubuntu 14.10 if that helps.

Thanks!

Tanner


#2

According to this Stack Overflow answer you need to install the ca-certificates with apt-get.


#3

I already had that installed, but that ended up leading me to a fix:

I found the CA cert bundle in:
/etc/ssl/certs/ca-certificates.crt
which is where ca-certificates puts its certs.

I then made a symlink to the place that curl was expecting to find the certs:
/etc/pki/tls/certs/ca-bundle.crt

It worked just fine after that. It seems to be an issue with Ubuntu more so than anything.

Thank you for your help!

Regards,

Tanner


#4