VicenteYago / meteoForecast

A R package for obtain weather forecasts from openWeather, weatherbit & AEMET
0 stars 1 forks source link

curl error when using AEMET #1

Open auroragonzalez opened 3 years ago

auroragonzalez commented 3 years ago

The following code: aemet.df <- getForecastAEMET(codigo = "03140", KEY = key.aemet) returns Error in curl::curl_fetch_memory(url, handle = handle) : error:141A318A:SSL routines:tls_process_ske_dhe:dh key too small

sessionInfo()

R version 4.0.3 (2020-10-10) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Debian GNU/Linux bullseye/sid

Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0 LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

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

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

other attached packages: [1] meteoForecast_0.1.0 magrittr_2.0.1 devtools_2.3.2
[4] usethis_2.0.0

loaded via a namespace (and not attached): [1] rstudioapi_0.13 pkgload_1.1.0 R6_2.5.0 rlang_0.4.10
[5] fastmap_1.1.0 fansi_0.4.2 httr_1.4.2 tools_4.0.3
[9] pkgbuild_1.2.0 sessioninfo_1.1.1 cli_2.3.0 withr_2.4.1
[13] remotes_2.2.0 ellipsis_0.3.1 assertthat_0.2.1 rprojroot_2.0.2
[17] lifecycle_0.2.0 crayon_1.4.0 processx_3.4.5 purrr_0.3.4
[21] callr_3.5.1 fs_1.5.0 ps_1.5.0 curl_4.3
[25] testthat_3.0.1 memoise_2.0.0 glue_1.4.2 cachem_1.0.3
[29] compiler_4.0.3 desc_1.2.0 prettyunits_1.1.1 jsonlite_1.7.2

auroragonzalez commented 3 years ago

A workaround is to set CipherString = DEFAULT@SECLEVEL=1 in the file /etc/ssl/openssl.cnf of your local computer. This is a system-wide change. Ideally, the package should change it only for working with it.

To solve this equivalent issue in python: import requests import urllib3 requests.packages.urllib3.util.ssl_.DEFAULT_CIPHERS = 'ALL:@SECLEVEL=1'

Remains the question on how to do it from R and in a way that does not affect the whole system.

Sources:

  1. https://github.com/outon/HomeAssistant-AEMET/issues/1
  2. https://unix.stackexchange.com/questions/537279/overriding-openssl-cipherstring-at-a-more-granular-level-in-debian-10
VicenteYago commented 3 years ago

Hi, It seems Ubuntu 20.04 have increased the default openssl security level, and so they expect to web servers upgrade their security level accordingly. 1

Currently AEMET only supports the older version, and i wouldnt really expect them to upgrade their certificates anytime soon.

System wide donwgrade of SSL may be dangerous and i am not in favor of doing so i think this is deadend for now.