pkgdown icon indicating copy to clipboard operation
pkgdown copied to clipboard

build_news curl error schannel: next InitializeSecurityContext failed

Open mabesa opened this issue 2 years ago • 12 comments

Hello,

I'm getting the following an error from curl for a site to the package available here: https://github.com/hydrosolutions/riversCentralAsia/ that seems (to me) to point to a connection error (error message below). It might all be a curl problem but as the news page does not seem to be quite properly deployed on the package site: https://hydrosolutions.github.io/riversCentralAsia/news/index.html I thought I might dare to bother you here.

I would greatly appreciate any help. Below are error message, version infos, and what I tried.

pkgdown::build_news() -- Building news ---------------------------------------------------------------------------------- Error in curl::curl_fetch_memory(url, handle = handle) : schannel: next InitializeSecurityContext failed: SEC_E_ILLEGAL_MESSAGE (0x80090326) - This error usually occurs when a fatal SSL/TLS alert is received (e.g. handshake failed).

I'm working with R version 4.2.1 in RStudio 2022.07.1 Build 554, pkgdown is version 2.0.6

curl::curl_version() $version [1] "7.64.1"

$ssl_version [1] "(OpenSSL/1.1.1k) Schannel"

$libz_version [1] "1.2.12"

$libssh_version [1] "libssh2/1.9.0"

$libidn_version [1] NA

$host [1] "x86_64-w64-mingw32"

$protocols [1] "dict" "file" "ftp" "ftps" "gopher" "http" "https" "imap" "imaps" "ldap"
[11] "ldaps" "pop3" "pop3s" "rtsp" "scp" "sftp" "smtp" "smtps" "telnet" "tftp"

$ipv6 [1] TRUE

$http2 [1] FALSE

$idn [1] TRUE

I tried to test curl_fetch_memory following this thread https://github.com/jeroen/curl/issues/261 Here is the output:

library(curl) Using libcurl 7.64.1 with Schannel h <- new_handle(verbose=TRUE) req <- curl::curl_fetch_memory("https://miktex.org/", handle = h)

  • Trying 5.175.24.104...
  • TCP_NODELAY set
  • Connected to miktex.org (5.175.24.104) port 443 (#3)

GET / HTTP/1.1 Host: miktex.org User-Agent: RStudio Desktop (2022.7.1.554); R (4.2.1 x86_64-w64-mingw32 x86_64 mingw32) Accept: / Accept-Encoding: deflate, gzip

  • schannel: failed to decrypt data, need more data
  • schannel: failed to decrypt data, need more data
  • schannel: failed to decrypt data, need more data
  • schannel: failed to decrypt data, need more data < HTTP/1.1 200 OK < Content-Type: text/html; charset=utf-8 < Server: Microsoft-IIS/10.0 < Strict-Transport-Security: max-age=2592000 < Date: Fri, 14 Oct 2022 15:01:40 GMT < Content-Length: 21113 <
  • schannel: failed to decrypt data, need more data
  • schannel: failed to decrypt data, need more data
  • Connection #3 to host miktex.org left intact

This is where it becomes a tick too geeky for me to follow up on.

mabesa avatar Oct 14 '22 15:10 mabesa

I've cloned your repository and do not get the error but I also see the changelog is empty in the resulting pkgdown website.

The headers in https://github.com/hydrosolutions/riversCentralAsia/blob/master/NEWS.md?plain=1 are not in the format expected by pkgdown, see https://pkgdown.r-lib.org/reference/build_news.html I've made a PR https://github.com/hydrosolutions/riversCentralAsia/pull/107

I'd also recommend not building the website locally yourself: instead you could rely on GitHub Actions. If you

then at each commit to the default branch, the website will be automatically built and deployed to the gh-pages branch. You might need to change the GitHub Pages settings of your repository.

Then if you get a bug again, you can post a link to the log of the GitHub Actions run. :smile_cat:

maelle avatar Oct 14 '22 15:10 maelle

(noting this does not solve the curl problem you saw :thinking: :sweat_smile: )

maelle avatar Oct 14 '22 15:10 maelle

Wow, fantastically quick!

Thank you for noticing the formatting problem in NEWS.md I merged your fix. I also deleted docs and commited after use_github_action. It takes several minutest to set up the dependencies and after adding tidyverse to the Dependencies the pkgdown workflow runs through without error. However, there is still an older workflow pages-build-deployment which errrors because it doesn't find docs. I need to ask my colleague to remove that workflow. Hopefully this will solve the problem!

Thanks a lot for your tips!!

mabesa avatar Oct 14 '22 16:10 mabesa

It was lucky timing. You're welcome! :smile_cat:

To fix the GitHub pages deployment you need to change the source of the GitHub Pages website from the docs folder to the gh-pages branch see https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site#publishing-from-a-branch

After you do that and when it works you can add the URL of the deployed pkgdown website to DESCRIPTION, _pkgdown.yml and the repository description. Good luck!

maelle avatar Oct 14 '22 16:10 maelle

Hi @maelle, have a similar issue for one of my R packages kwb.geosalz, where I have a cron job for pkgdown (which worked fine until 2022-10-14) also crashed today during rendering of NEWS.md.

Here the GH actions log for windows-latest (https://github.com/KWB-R/kwb.geosalz/actions/runs/3263114575/jobs/5362680759#step:11:285)

-- Building news ---------------------------------------------------------------

Error in curl::curl_fetch_memory(url, handle = handle) : 

  schannel: next InitializeSecurityContext failed: SEC_E_ILLEGAL_MESSAGE (0x80090326) - This error usually occurs when a fatal SSL/TLS alert is received (e.g. handshake failed).

Error: 
! error in callr subprocess
Caused by error in `curl::curl_fetch_memory(url, handle = handle)`:
! schannel: next InitializeSecurityContext failed: SEC_E_ILLEGAL_MESSAGE (0x80090326) - This error usually occurs when a fatal SSL/TLS alert is received (e.g. handshake failed).
---
Backtrace:
1. kwb.pkgbuild::deploy_to_branch_with_extra_files(vignettes_file_pattern_to_…
2. pkgdown::build_site(pkg, devel = FALSE, preview = FALSE, install = FALSE, …
3. pkgdown:::build_site_external(pkg = pkg, examples = examples, run_dont_run = run_don…
4. callr::r(function(..., cli_colors, pkgdown_internet) { …
5. callr:::get_result(output = out, options)
6. callr:::throw(callr_remote_error(remerr))
7. callr:::callr_remote_error(remerr)
8. callr:::throw(err, parent = remerr[[3]])
---
Subprocess backtrace:
1. pkgdown::build_site(...)
2. pkgdown:::build_site_local(pkg = pkg, examples = examples, run_dont_run = run_dont_r…
3. pkgdown::build_news(pkg, override = override, preview = FALSE)
4. pkgdown:::build_news_single(pkg)
5. pkgdown:::data_news(pkg)
6. pkgdown:::pkg_timeline(pkg$package)
7. httr::RETRY("GET", url, quiet = TRUE)
8. base::stop(resp)
9. global (function (e) …
── Removing worktree ───────────────────────────────────────────────────────────
Running git worktree remove \
  "C:/Users/RUNNER~1/AppData/Local/Temp/Rtmpcn7Rjz/file176c38c26aaa"
Execution halted

mrustl avatar Oct 17 '22 13:10 mrustl

@gaborcsardi (happy to report this possible bug elsewhere!) pkgdown calls crandb.r-pkg.org

https://github.com/r-lib/pkgdown/blob/7fe9e802df2964d483d0267f1d5a59aa7b3c685d/R/build-news.R#L259-L280

There have been two reports of errors (like in the comment right before this one). Could this be due to something intermittently wrong with the API?

maelle avatar Oct 17 '22 13:10 maelle

Could it be related to the new version of curl (4.3.3) by @jeroen (on CRAN since 2022-10-06) due to the curl::curl_fetch_memory() error?

mrustl avatar Oct 17 '22 13:10 mrustl

There have been two reports of errors (like in the comment right before this one). Could this be due to something intermittently wrong with the API?

Which comment? The original message shows that miktex.org fails as well, so it is more like to be something in Windows or the curl binary.

@mabesa does it work with base R?

download.file("https://miktex.org", tmp <- tempfile())

EDIT: Actually, miktex.org seems to be OK, that message is not an error. Never mind then.

gaborcsardi avatar Oct 17 '22 13:10 gaborcsardi

the error was


Error in curl::curl_fetch_memory(url, handle = handle) : 

  schannel: next InitializeSecurityContext failed: SEC_E_ILLEGAL_MESSAGE (0x80090326) - This error usually occurs when a fatal SSL/TLS alert is received (e.g. handshake failed).

Error: 
! error in callr subprocess
Caused by error in `curl::curl_fetch_memory(url, handle = handle)`:
! schannel: next InitializeSecurityContext failed: SEC_E_ILLEGAL_MESSAGE (0x80090326) - This error usually occurs when a fatal SSL/TLS alert is received (e.g. handshake failed).
---
Backtrace:
1. kwb.pkgbuild::deploy_to_branch_with_extra_files(vignettes_file_pattern_to_…
2. pkgdown::build_site(pkg, devel = FALSE, preview = FALSE, install = FALSE, …
3. pkgdown:::build_site_external(pkg = pkg, examples = examples, run_dont_run = run_don…
4. callr::r(function(..., cli_colors, pkgdown_internet) { …
5. callr:::get_result(output = out, options)
6. callr:::throw(callr_remote_error(remerr))
7. callr:::callr_remote_error(remerr)
8. callr:::throw(err, parent = remerr[[3]])

Locally I didn't get it.

maelle avatar Oct 17 '22 14:10 maelle

@mrustl by the way why build the pkgdown website on Windows on GitHub Actions?

maelle avatar Oct 17 '22 14:10 maelle

@maelle because my vignette uses sftp I could not get to work on macOS

https://github.com/KWB-R/kwb.geosalz/blob/5de3c8841320e8e740514c29814caf6a74bd43ca/.github/workflows/pkgdown.yaml#L40

mrustl avatar Oct 17 '22 14:10 mrustl

A workaround that probably works is to set the CURL_SSL_BACKEND="openssl" env var, before starting R.

gaborcsardi avatar Oct 17 '22 16:10 gaborcsardi

I've also been getting this error for a couple weeks. I was getting it on multiple packages, and multiple versions of pkgdown. Finally I found a workaround by turning off the news release dates in the _pkdown.yml, like this:

news: cran_dates: false

Now it is fixed on all my packages. I'm mentioning this to help anyone with the same error, but also give a clue regarding diagnosis/resolution. Ultimately, I'd like to get the release dates on my news files back.

dbosak01 avatar Oct 26 '22 03:10 dbosak01

@dbosak01 Are you on Windows? Does the workaround suggested above work for you?

gaborcsardi avatar Oct 26 '22 06:10 gaborcsardi

This should be fixed now.

gaborcsardi avatar Oct 26 '22 20:10 gaborcsardi

@gaborcsardi Confirmed! Thanks much!

dbosak01 avatar Oct 26 '22 21:10 dbosak01

Thanks @gaborcsardi!

maelle avatar Oct 27 '22 04:10 maelle

(and thanks @jeroen :smile_cat:)

maelle avatar Oct 27 '22 04:10 maelle