rosmar

get_osm function in osmar (R) gives SSL error


Since a couple of months ago the following code run errorless

   library(osmar)
   src <- osmsource_api(url = "https://api.openstreetmap.org/api/0.6/")
   bb <- corner_bbox(13.3,40.79,13.5,40.81)
   ua <- get_osm(bb, source = src)

now it gives me the following error

"Error in function (type, msg, asError = TRUE) : error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version"

I failed to understand the issue. I try to run the code using two other computers with different version (older) of R but it still doesn't work.

Anyone has a possible solution?

Thanks in advance


Solution

  • I had the same issue. In detail the OSMAR package uses the package RCurl to load content which uses somehow an old encryption standard. You can fix the problem by building your "own" OSMAR package with small modifications.

    import(curl)
    
    #' @import RCurl
    #' @import XML
    #' @import gtools
    #' @import methods
    #' @import Curl
    
    get_osm_data.api <- function(source, what, ...) {
      request <- osm_request(source, what, ...)
      #response <- getURL(request, .encoding = "UTF-8")
      response <- paste(readLines(curl::curl(request)), collapse = "")
    }
    

    This helped in my case. Best Andreas Weigert