DOI-USGS / dataRetrieval

This R package is designed to obtain USGS or EPA water quality sample data, streamflow data, and metadata directly from web services.
https://doi-usgs.github.io/dataRetrieval/
Other
260 stars 84 forks source link

SSL certificate problem #672

Closed crumsey324 closed 1 year ago

crumsey324 commented 1 year ago

Describe the bug When I try to run any dataRetrieval functions, SOMETIMES I get:

Initiating curl with CURL_SSL_BACKEND: openssl Error in curl::curl_fetch_memory(url, handle = handle): SSL peer certificate or SSH remote key was not OK: [waterservices.usgs.gov] SSL certificate problem: unable to get local issuer certificate Request failed [ERROR]. Retrying in 1 seconds... Error in curl::curl_fetch_memory(url, handle = handle): SSL peer certificate or SSH remote key was not OK: [waterservices.usgs.gov] SSL certificate problem: unable to get local issuer certificate Request failed [ERROR]. Retrying in 1.6 seconds... Error in curl::curl_fetch_memory(url, handle = handle) : SSL peer certificate or SSH remote key was not OK: [waterservices.usgs.gov] SSL certificate problem: unable to get local issuer certificate

To Reproduce Steps to reproduce the behavior: pCodes <- c("70305","72263","70301","70300","00095","90095","72013","00915",'00925',"00930","00935","00940","00945") NWIS_cond=whatNWISsites(bBox=c(-112.85,40.668,-112.142,41.227), parameterCd=pCodes)

AND/OR

qw <- readNWISqw(siteNumbers = NWIS_cond$site_no,parameterCd = pCodes) readNWISqw("10010060",parameterCd = "00095",startDate = "",endDate = )

library(dataRetrieval)
problem_query <- readNWISdv("a","b","c","d")

Expected behavior A clear and concise description of what you expected to happen. I expect the data to load.

Screenshots If applicable, add screenshots to help explain your problem. image

Session Info Please include your session info:

sessionInfo()
#OR preferred:
devtools::session_info()

image

Additional context Add any other context about the problem here. Some functions seem to work sometimes. Confusing.

ldecicco-USGS commented 1 year ago

Interesting...I'm able to reproduce but only on versions below R 4.3.1. I'm going to follow up with some questions. I'm not sure if it's an SSL thing, and R/RTools thing, or a dataRetrieval thing yet.

ldecicco-USGS commented 1 year ago

If a non-USGS person is having this problem, please let me know. We think we might have a solution but it is specific to USGS R installations.

crumsey324 commented 1 year ago

I haven't heard anyone outside of USGS having issues, but will let you know.

Thank you!


From: Laura DeCicco @.> Sent: Monday, June 26, 2023 4:23 PM To: DOI-USGS/dataRetrieval @.> Cc: Rumsey, Christine A @.>; Author @.> Subject: [EXTERNAL] Re: [DOI-USGS/dataRetrieval] SSL certificate problem (Issue #672)

This email has been received from outside of DOI - Use caution before clicking on links, opening attachments, or responding.

If a non-USGS person is having this problem, please let me know. We think we might have a solution but it is specific to USGS R installations.

— Reply to this email directly, view it on GitHubhttps://github.com/DOI-USGS/dataRetrieval/issues/672#issuecomment-1608402199, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ASPI6MGIV5KSP7OVGCIRN4LXNIDWDANCNFSM6AAAAAAZUTB77U. You are receiving this because you authored the thread.Message ID: @.***>

crumsey324 commented 1 year ago

Thanks, Laura!


From: Laura DeCicco @.> Sent: Thursday, July 20, 2023 9:38 AM To: DOI-USGS/dataRetrieval @.> Cc: Rumsey, Christine A @.>; Author @.> Subject: [EXTERNAL] Re: [DOI-USGS/dataRetrieval] SSL certificate problem (Issue #672)

This email has been received from outside of DOI - Use caution before clicking on links, opening attachments, or responding.

Closed #672https://github.com/DOI-USGS/dataRetrieval/issues/672 as completed.

— Reply to this email directly, view it on GitHubhttps://github.com/DOI-USGS/dataRetrieval/issues/672#event-9876171533, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ASPI6MD3XNS77V44XQ2QNJTXRFGGHANCNFSM6AAAAAAZUTB77U. You are receiving this because you authored the thread.Message ID: @.***>

pydatawrangler commented 8 months ago

I am having this same issue and a non-USGS user.

I am using R version 4.2.2

Here is the error I get:

library(dataRetrieval) pcode <- readNWISpCode("all") Error in curl::curl_fetch_disk(url, x$path, handle = handle): SSL peer certificate or SSH remote key was not OK: [help.waterdata.usgs.gov] SSL certificate problem: unable to get local issuer certificate Request failed [ERROR]. Retrying in 1.6 seconds... Error in curl::curl_fetch_disk(url, x$path, handle = handle): SSL peer certificate or SSH remote key was not OK: [help.waterdata.usgs.gov] SSL certificate problem: unable to get local issuer certificate Request failed [ERROR]. Retrying in 3.3 seconds... Error in curl::curl_fetch_disk(url, x$path, handle = handle) : SSL peer certificate or SSH remote key was not OK: [help.waterdata.usgs.gov] SSL certificate problem: unable to get local issuer certificate

ldecicco-USGS commented 8 months ago

In the USGS, we needed to specify where our agency's CURL_CA_BUNDLE was located, and it had pretty much affected any attempts to connect to the internet via R - including things like installing packages from CRAN. Are you able to install a CRAN or Github package?

You can see where your bundle should be with:

httr:::find_cert_bundle()

If normal package installations are working:

Is this issue ONLY for the readNWISpCode("all")? Or do all dataRetrieval functions give that error? Specifically do you get errors for both NWIS and WQP functions? For example, do both of these work?

site_id <- "04085427"
startDate <- "2012-01-01"
endDate <- "2012-06-30"
pCode <- "00060"

rawDailyQ <- readNWISdv(site_id, pCode, startDate, endDate)

rawPcode <- readWQPqw("USGS-01594440", "01075", "", "")