Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API not working on WSL 2 and google-cloud VM #2

Open
marcoaurelioguerrap opened this issue Feb 23, 2024 · 9 comments
Open

API not working on WSL 2 and google-cloud VM #2

marcoaurelioguerrap opened this issue Feb 23, 2024 · 9 comments
Labels
question Further information is requested

Comments

@marcoaurelioguerrap
Copy link

When making request to the API on WSL 2 or a google-cloud VM with Ubunt I get this error:

> lnic_country <- gdl_request(sess)
Error in `req_perform()`:
! Failed to perform HTTP request.
Caused by error in `curl::curl_fetch_memory()`:
! SSL peer certificate or SSH remote key was not OK: [globaldatalab.org] server certificate verification failed. CAfile: none CRLfile: none

It seems that this is a problem with the website certifications. When I use www.ssllabs.com to get the correct certification bundle (Certification Paths). I manage to access the API.
image
Working using ca-bundle from ssllabs:
image

@marcoaurelioguerrap
Copy link
Author

Note: On windows works fine

@AaronVanGeffen
Copy link
Member

It looks like you're using Ubuntu or Debian on WSL, is that correct? If so, could you verify the ca-certificates package is installed through apt?

@AaronVanGeffen AaronVanGeffen added the question Further information is requested label Feb 23, 2024
@marcoaurelioguerrap
Copy link
Author

Yes, it is.
image

@AaronVanGeffen
Copy link
Member

It seems curl fails to find the certificate bundle, either way (note: CAfile: none CRLfile: none in the error produced by R).

Could you try setting the following environment variable, such that R has access to it?

CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt

@marcoaurelioguerrap
Copy link
Author

How do I do this?

I have tried the curl option --cacert but it also failed. OBS.: I'm not using the API request not to show my API key. but the result is the same.

image

@marcoaurelioguerrap
Copy link
Author

I forgot to mention, not sure if it is important. but my machine that has the WSL 2 does manage to access the API an the website (via curl or API)
image

@AaronVanGeffen
Copy link
Member

It is also working fine for me on both macOS and Linux, which leads me to believe it is a problem with the setup in the VM you're using. Regardless, a very similar issue was reported in #1, so I would like to get to the bottom of this.

However, it is 11pm on my end, and very much the weekend. I'll happily get back to the issue on Monday. If you find out the cause in the mean time, please do leave a comment.

@marcoaurelioguerrap
Copy link
Author

Oh, OK. Sure, no worries, I'm about to finish here as well. It is not a big problem for me. I could download the data on my Windows machine. I thought you guys might want to know about this.

A friend of mine managed to make this work on her Ubuntu so it is problem something on my machine and on the Google Cloud compute engine, I don't know much about network stuff.

@marcoaurelioguerrap
Copy link
Author

This post helped me to run the curl using the ca-bundle
https://askubuntu.com/questions/1127574/ubuntu-curl-not-recognizing-positivessl-certificate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants