OuhscBbmc / REDCapR

R utilities for interacting with REDCap
https://ouhscbbmc.github.io/REDCapR
Other
112 stars 46 forks source link

SSL certificate problem #454

Closed akang1414 closed 1 year ago

akang1414 commented 1 year ago

Error in curl::curl_fetch_memory(url, handle = handle) : SSL certificate problem: unable to get local issuer certificate Calls: redcap_report ... request_fetch -> request_fetch.write_memory ->

wibeasley commented 1 year ago

Hi @adi2827, can you please provide more background?

akang1414 commented 1 year ago

I am making an api call to REDCap using REDCap R package as below. The code works on the laptop but not on the server. library(REDCapR) my_uri <-'https://redcap-qi.xxx.xxx.xxx/xxx/xxx/API/' my_token <- 'xxxxxxxxxxxxxxxxx' my_data <- redcap_report(redcap_uri = my_uri, token = my_token, report_id = 12345)$data

The following workaround did the job for now but is there a way to read an alternative certificate? new_config <- httr::config(ssl_verifypeer = FALSE) httr::set_config(new_config, override = FALSE) Also, i am running into Error in inherits(ds, "data.frame") : object 'ds' not found. I am reading several reports and some might return zero records, so i'm not sure if that is causing the error.

wibeasley commented 1 year ago
  1. what do you mean by "The code works on the laptop but not on the server."? In the second scenario, you're running R on what server? REDCap's web server?
  2. what version of R, REDCap, & REDCapR (for each scenario's machines)?

edit: also, please address the standard questions in this repo's template for new issues. The troubleshooting document solves a lot of these.

akang1414 commented 1 year ago

1) our organization's own server 2) R=4.0.2, redcap_v12.0.28, REDCapR 1.0.0

wibeasley commented 1 year ago

That version of R is old, and that's what contains the certificates. Update that and I bet things will work. Also see the relevant SSL section of this REDCapR vignette.

It that doesn't work:

  1. I'm sure your organization has many servers. Are you running it from your organization's REDCap web server?
  2. That version of REDCapR was released almost 1.5 years ago. At least update it to the newest CRAN version. The newest GitHub version would be better. Instructions are on the home page & readme.
wibeasley commented 1 year ago

@akang1414, I assume this issue was resolved for you. Please reopen it if not.

Note to self: this is connected to https://stackoverflow.com/q/74746949/1082435

pgcudahy commented 11 months ago

Hello, first of all, thanks for this amazing tool. However, I'm also having a similar problem. On my Mac laptop, REDCapR will connect just fine

R version 4.3.1 (2023-06-16)
Platform: aarch64-apple-darwin23.0.0 (64-bit)
Running under: macOS Sonoma 14.0

Matrix products: default
BLAS:   [/opt/homebrew/Cellar/openblas/0.3.24/lib/libopenblasp-r0.3.24.dylib](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Cellar/openblas/0.3.24/lib/libopenblasp-r0.3.24.dylib) 
LAPACK: [/opt/homebrew/Cellar/r/4.3.1/lib/R/lib/libRlapack.dylib](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Cellar/r/4.3.1/lib/R/lib/libRlapack.dylib);  LAPACK version 3.11.0

locale:
[1] en_US/en_US/en_US/C/en_US/en_US

time zone: Africa/Johannesburg
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] REDCapR_1.1.0   lubridate_1.9.2 forcats_1.0.0   stringr_1.5.0  
 [5] dplyr_1.1.2     purrr_1.0.1     readr_2.1.4     tidyr_1.3.0    
 [9] tibble_3.2.1    ggplot2_3.4.2   tidyverse_2.0.0

loaded via a namespace (and not attached):
 [1] bit_4.0.5        gtable_0.3.3     jsonlite_1.8.7   compiler_4.3.1  
 [5] crayon_1.5.2     tidyselect_1.2.0 IRdisplay_1.1    parallel_4.3.1  
 [9] scales_1.2.1     uuid_1.1-0       fastmap_1.1.1    IRkernel_1.3.2  
[13] R6_2.5.1         generics_0.1.3   curl_5.0.0       backports_1.4.1 
[17] checkmate_2.2.0  munsell_0.5.0    pillar_1.9.0     tzdb_0.4.0      
[21] rlang_1.1.1      utf8_1.2.3       stringi_1.7.12   repr_1.1.6      
[25] bit64_4.0.5      timechange_0.2.0 cli_3.6.1        withr_2.5.0     
[29] magrittr_2.0.3   digest_0.6.33    grid_4.3.1       vroom_1.6.3     
[33] base64enc_0.1-3  hms_1.1.3        pbdZMQ_0.3-9     lifecycle_1.0.3 
[37] vctrs_0.6.3      evaluate_0.21    glue_1.6.2       fansi_1.0.4     
[41] colorspace_2.1-0 httr_1.4.6       tools_4.3.1      pkgconfig_2.0.3 
[45] htmltools_0.5.5

But I get an unable to get local issuer certificate error from my linux desktop

R version 4.3.2 (2023-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.6 LTS

Matrix products: default
BLAS/LAPACK: [/home/linuxbrew/.linuxbrew/Cellar/openblas/0.3.24/lib/libopenblasp-r0.3.24.so](https://vscode-remote+ssh-002dremote-002bwhiteplague.vscode-resource.vscode-cdn.net/home/linuxbrew/.linuxbrew/Cellar/openblas/0.3.24/lib/libopenblasp-r0.3.24.so);  LAPACK version 3.11.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

time zone: America/New_York
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] lubridate_1.9.3 forcats_1.0.0   stringr_1.5.0   dplyr_1.1.3    
 [5] purrr_1.0.2     readr_2.1.4     tidyr_1.3.0     tibble_3.2.1   
 [9] ggplot2_3.4.4   tidyverse_2.0.0 REDCapR_1.1.0  

loaded via a namespace (and not attached):
 [1] gtable_0.3.4      jsonlite_1.8.7    compiler_4.3.2    crayon_1.5.2     
 [5] tidyselect_1.2.0  IRdisplay_1.1     scales_1.2.1      uuid_1.1-1       
 [9] fastmap_1.1.1     IRkernel_1.3.2    R6_2.5.1          generics_0.1.3   
[13] curl_5.1.0        backports_1.4.1   checkmate_2.2.0   munsell_0.5.0    
[17] pillar_1.9.0      tzdb_0.4.0        rlang_1.1.1       utf8_1.2.4       
[21] stringi_1.7.12    repr_1.1.6        timechange_0.2.0  cli_3.6.1        
[25] withr_2.5.1       magrittr_2.0.3    digest_0.6.33     grid_4.3.2       
[29] base64enc_0.1-3   hms_1.1.3         pbdZMQ_0.3-10     lifecycle_1.0.3  
[33] vctrs_0.6.4       evaluate_0.22     glue_1.6.2        fansi_1.0.5      
[37] colorspace_2.1-0  httr_1.4.7        tools_4.3.2       pkgconfig_2.0.3  
[41] htmltools_0.5.6.1

Both using REDCapR 1.1.0 on pretty similar R versions (4.3.1 vs 4.3.2) and the linux box with the error actually has the newer R.

BlairCooper commented 11 months ago

@pgcudahy Does the code below resolve your problem? Is the SSL certificate on the REDCap server self signed and/or are you connecting through a proxy (which you may not be aware of)?

new_config <- httr::config(ssl_verifypeer = FALSE) httr::set_config(new_config, override = FALSE)

Background: I ran into a similar issue a while back where there was a proxy server between me and the server. The SSL certificate on the proxy (Zscaler) was not issued by one of the root certificate authorities that were installed on the computer. My solution was to retrieve the root certificate from Zscaler and install it on the machine.

pgcudahy commented 11 months ago

That works great! Thanks very much