ropensci / osmdata

R package for downloading OpenStreetMap data
https://docs.ropensci.org/osmdata
316 stars 46 forks source link

Event ultra simple OSM data query fails due to SSL certificate expiration #251

Closed espinielli closed 3 years ago

espinielli commented 3 years ago

I cannot follow the required steps for a bug report, because even downloading OSM data locally fails. I fear this is not really an osmdata package issue and I have seen that a similar issue, #224 was reported in the past. I have no issues using my browser and overpass-turbo:

[out:json][timeout:100];
{{geocodeArea:Italy}};
node["natural"="peak"](area);
// print results
out body;
>;
out skel qt;

Here is my reproducible example:

library(osmdata)
#> Data (c) OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright

# bbox for Italy
q <- getbb("italy") %>% 
   opq(timeout = 200) %>%
   add_osm_feature(key = 'natural', value = 'peak')
#> Error in curl::curl_fetch_memory(url, handle = handle): SSL certificate problem: certificate has expired
#> Request failed [ERROR]. Retrying in 1.4 seconds...
#> Error in curl::curl_fetch_memory(url, handle = handle): SSL certificate problem: certificate has expired
#> Request failed [ERROR]. Retrying in 2.6 seconds...
#> Error in curl::curl_fetch_memory(url, handle = handle): SSL certificate problem: certificate has expired
#> Request failed [ERROR]. Retrying in 7.7 seconds...
#> Error in curl::curl_fetch_memory(url, handle = handle): SSL certificate problem: certificate has expired
#> Request failed [ERROR]. Retrying in 11.1 seconds...
#> Error in curl::curl_fetch_memory(url, handle = handle): SSL certificate problem: certificate has expired
#> Request failed [ERROR]. Retrying in 29.1 seconds...
#> Error in curl::curl_fetch_memory(url, handle = handle): SSL certificate problem: certificate has expired
#> Request failed [ERROR]. Retrying in 55.6 seconds...
#> Error in curl::curl_fetch_memory(url, handle = handle): SSL certificate problem: certificate has expired
#> Request failed [ERROR]. Retrying in 58.4 seconds...
#> Error in curl::curl_fetch_memory(url, handle = handle): SSL certificate problem: certificate has expired
#> Request failed [ERROR]. Retrying in 10.2 seconds...
#> Error in curl::curl_fetch_memory(url, handle = handle): SSL certificate problem: certificate has expired
#> Request failed [ERROR]. Retrying in 34.7 seconds...
#> Error in curl::curl_fetch_memory(url, handle = handle): SSL certificate problem: certificate has expired

df <- q %>%
   osmdata_sf()
#> Error in osmdata_sf(.): q must be an overpass query or a character string

sessionInfo()
#> R version 4.0.3 (2020-10-10)
#> Platform: x86_64-apple-darwin17.0 (64-bit)
#> Running under: macOS High Sierra 10.13.6
#> 
#> Matrix products: default
#> BLAS:   /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
#> 
#> locale:
#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] osmdata_0.1.8
#> 
#> loaded via a namespace (and not attached):
#>  [1] Rcpp_1.0.7        pillar_1.6.4      compiler_4.0.3    highr_0.9        
#>  [5] R.methodsS3_1.8.1 R.utils_2.11.0    tools_4.0.3       digest_0.6.27    
#>  [9] lubridate_1.8.0   jsonlite_1.7.2    evaluate_0.14     lifecycle_1.0.0  
#> [13] tibble_3.1.5      R.cache_0.15.0    lattice_0.20-44   pkgconfig_2.0.3  
#> [17] rlang_0.4.12      reprex_2.0.1      curl_4.3.2        yaml_2.2.1       
#> [21] xfun_0.28         fastmap_1.1.0     xml2_1.3.2        withr_2.4.2      
#> [25] styler_1.6.2      stringr_1.4.0     httr_1.4.2        knitr_1.36       
#> [29] generics_0.1.0    fs_1.5.0          vctrs_0.3.8       grid_4.0.3       
#> [33] glue_1.4.2        R6_2.5.1          fansi_0.5.0       rmarkdown_2.11   
#> [37] sp_1.4-5          purrr_0.3.4       magrittr_2.0.1    backports_1.2.1  
#> [41] ellipsis_0.3.2    htmltools_0.5.2   rvest_1.0.0       utf8_1.2.2       
#> [45] stringi_1.7.5     crayon_1.4.1      R.oo_1.24.0

Created on 2021-11-07 by the reprex package (v2.0.1)

Robinlovelace commented 3 years ago

I cannot reproduce this, I get:

osmdata_sf(q)
Object of class 'osmdata' with:
                 $bbox : 32.1634093,-96.9079386,32.2066985,-96.8616477
        $overpass_call : The call submitted to the overpass API
                 $meta : metadata including timestamp and version numbers
           $osm_points : 'sf' Simple Features Collection with 0 points
            $osm_lines : NULL
         $osm_polygons : 'sf' Simple Features Collection with 0 polygons
       $osm_multilines : NULL
    $osm_multipolygons : NULL

Have you tried on a different computer/IP?

espinielli commented 3 years ago

It definetly is something with my computer... This basic fails:

> overpass_status(quiet = FALSE)
Error in curl::curl_fetch_memory(url, handle = handle): SSL certificate problem: certificate has expired
Request failed [ERROR]. Retrying in 1.4 seconds...
Error in curl::curl_fetch_memory(url, handle = handle): SSL certificate problem: certificate has expired
Request failed [ERROR]. Retrying in 3.2 seconds...
Error in curl::curl_fetch_memory(url, handle = handle): SSL certificate problem: certificate has expired
Request failed [ERROR]. Retrying in 6.1 seconds...
Error in curl::curl_fetch_memory(url, handle = handle): SSL certificate problem: certificate has expired
Request failed [ERROR]. Retrying in 4.9 seconds...
Error in curl::curl_fetch_memory(url, handle = handle): SSL certificate problem: certificate has expired
Request failed [ERROR]. Retrying in 26.4 seconds...
Error in curl::curl_fetch_memory(url, handle = handle): SSL certificate problem: certificate has expired
Request failed [ERROR]. Retrying in 22.3 seconds...
Error in curl::curl_fetch_memory(url, handle = handle): SSL certificate problem: certificate has expired
Request failed [ERROR]. Retrying in 59.8 seconds...
Error in curl::curl_fetch_memory(url, handle = handle): SSL certificate problem: certificate has expired
Request failed [ERROR]. Retrying in 31.2 seconds...
Error in curl::curl_fetch_memory(url, handle = handle): SSL certificate problem: certificate has expired
Request failed [ERROR]. Retrying in 18.8 seconds...
Error in curl::curl_fetch_memory(url, handle = handle) : 
  SSL certificate problem: certificate has expired

It is strange because curl from command line works. Also I uninstalled/reinstalled the {curl} package to be super sure. And overpass turbo from the browser is ok: I will store the XML from there and import in my R session...but strange!

Robinlovelace commented 3 years ago

Idea: could the OSM server used by osmdata have blocked your IP for excessive use?

Robinlovelace commented 3 years ago

I get

overpass_status(quiet = FALSE)
Rate limit: 0
mpadge commented 3 years ago

Same link i just put in #224 explains why this generally un-repeatable phenomenon happens. It's up to individual services to update their certificate stores, which has to happen at some stage dependent on maintenance schedules, and everything will resolve itself. That's definitely the reason for the behaviour you observe @espinielli, so I'm going to close now. Thanks

mpadge commented 3 years ago

And thanks @Robinlovelace for the super speedy responses :rocket:

espinielli commented 2 years ago

It works on another machine... Thanks for all your feedback and help!