unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: Mark H Weaver <mhw@netris.org>
Cc: 26948@debbugs.gnu.org
Subject: bug#26948: gnutls errors on multiple guix commands
Date: Sun, 28 May 2017 21:36:00 -0700	[thread overview]
Message-ID: <87poess2j3.fsf@gmail.com> (raw)
In-Reply-To: <87poes25dw.fsf@netris.org> (Mark H. Weaver's message of "Sun, 28 May 2017 14:38:51 -0400")

Mark H Weaver <mhw@netris.org> writes:

> ludo@gnu.org (Ludovic Courtès) writes:
>
>> Hi Maxim,
>>
>> Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:
>>
>>> It seems that the problem is caused by the file:
>>> "/etc/ssl/certs/AC_Ra\303\255z_Certic\303\241mara_S.A.:2.15.7.126.82.147.123.224.21.227.87.240.105.140.203.236.12.p".
>
> This reminds me of a bug that I found in the Guile binding in GnuTLS a
> while ago, but forgot to report.  Maybe it's related:
>
> In 'set_certificate_file' in gnutls-3.5.9/guile/src/core.c:
>
>   static unsigned int
>   set_certificate_file (certificate_set_file_function_t set_file,
>                         SCM cred, SCM file, SCM format, const char *func_name)
>   #define FUNC_NAME func_name
>   {
>     int err;
>     char *c_file;
>     size_t c_file_len;
>   
>     gnutls_certificate_credentials_t c_cred;
>     gnutls_x509_crt_fmt_t c_format;
>   
>     c_cred = scm_to_gnutls_certificate_credentials (cred, 1, FUNC_NAME);
>     SCM_VALIDATE_STRING (2, file);
>     c_format = scm_to_gnutls_x509_certificate_format (format, 3, FUNC_NAME);
>   
>     c_file_len = scm_c_string_length (file);
>     c_file = alloca (c_file_len + 1);
>   
>     (void) scm_to_locale_stringbuf (file, c_file, c_file_len + 1);
>     c_file[c_file_len] = '\0';
>   
>     err = set_file (c_cred, c_file, c_format);
>     if (EXPECT_FALSE (err < 0))
>       scm_gnutls_error (err, FUNC_NAME);
>   
>     /* Return the number of certificates processed.  */
>     return ((unsigned int) err);
>   }
>
> 'scm_c_string_length' is inappropriately assumed to return the length
> of the encoded C string in bytes, whereas it actually returns the
> number of characters (code points).
>
> This led to:
>
> stat("/etc/ssl/certs/AC_Ra\303\255z_Certic\303\241mara_S.A.:2.15.7.126.82.147.123.224.21.227.87.240.105.140.203.236.12.pem", {st_mode=S_IFREG|0444, st_size=2444, ...}) = 0
> open("/etc/ssl/certs/AC_Ra\303\255z_Certic\303\241mara_S.A.:2.15.7.126.82.147.123.224.21.227.87.240.105.140.203.236.12.p", O_RDONLY) = -1 ENOENT (No such file or directory)
>
> While doing this:
>
> mhw@jojen ~$ strace -o trace.out guix import gem rails
> Backtrace:
> In unknown file:
>    ?: 19 [apply-smob/1 #<catch-closure 2793e20>]
> In ice-9/boot-9.scm:
>   66: 18 [call-with-prompt prompt0 ...]
> In ice-9/eval.scm:
>  432: 17 [eval # #]
> In ice-9/boot-9.scm:
> 2412: 16 [save-module-excursion #<procedure 27b4900 at ice-9/boot-9.scm:4084:3 ()>]
> 4089: 15 [#<procedure 27b4900 at ice-9/boot-9.scm:4084:3 ()>]
> 1734: 14 [%start-stack load-stack ...]
> 1739: 13 [#<procedure 27c6b40 ()>]
> In unknown file:
>    ?: 12 [primitive-load "/home/mhw/guix/scripts/guix"]
> In guix/ui.scm:
> 1255: 11 [run-guix-command import "gem" "rails"]
> In guix/scripts/import.scm:
>  114: 10 [guix-import "gem" "rails"]
> In guix/scripts/import/gem.scm:
>   84: 9 [guix-import-gem "rails"]
> In guix/import/gem.scm:
>  121: 8 [gem->guix-package "rails" #f]
> In ice-9/boot-9.scm:
>  160: 7 [catch srfi-34 #<procedure 3518440 at guix/import/json.scm:29:2 ()> ...]
> In guix/import/json.scm:
>   32: 6 [#<procedure 3518440 at guix/import/json.scm:29:2 ()>]
> In guix/http-client.scm:
>  239: 5 [loop #]
> In guix/build/download.scm:
>  520: 4 [open-connection-for-uri # # #f ...]
>  391: 3 [tls-wrap #<input-output: socket 10> "rubygems.org" ...]
>  308: 2 [make-credendials-with-ca-trust-files "/etc/ssl/certs"]
> In srfi/srfi-1.scm:
>  616: 1 [for-each #<procedure 351f090 at guix/build/download.scm:308:14 (file)> #]
> In unknown file:
>    ?: 0 [set-certificate-credentials-x509-trust-file! # ...]
>
> ERROR: In procedure set-certificate-credentials-x509-trust-file!:
> ERROR: Throw to key `gnutls-error' with args `(#<gnutls-error-enum Error while reading file.> set-certificate-credentials-x509-trust-file!)'.
> mhw@jojen ~$
>
> The problem can be worked around by using the C locale:
>
> mhw@jojen ~$ LC_ALL=C guix import gem rails
> (package
>   (name "ruby-rails")
>   (version "5.1.0")
>   (source
>     (origin
>       (method url-fetch)
>       (uri (rubygems-uri "rails" version))
>       (sha256
>         (base32
>           "0cpcnrlqg1am2jfdz6pf9snh89qzbny9ikbpg3xz31qrqv9f4hyq"))))
>   (build-system ruby-build-system)
>   (propagated-inputs
>     `(("ruby-actioncable" ,ruby-actioncable)
>       ("ruby-actionmailer" ,ruby-actionmailer)
>       ("ruby-actionpack" ,ruby-actionpack)
>       ("ruby-actionview" ,ruby-actionview)
>       ("ruby-activejob" ,ruby-activejob)
>       ("ruby-activemodel" ,ruby-activemodel)
>       ("ruby-activerecord" ,ruby-activerecord)
>       ("ruby-activesupport" ,ruby-activesupport)
>       ("bundler" ,bundler)
>       ("ruby-railties" ,ruby-railties)
>       ("ruby-sprockets-rails" ,ruby-sprockets-rails)))
>   (synopsis
>     "Ruby on Rails is a full-stack web framework optimized for programmer happiness and sustainable productivity. It encourages beautiful code by favoring convention over configuration.")
>   (description
>     "Ruby on Rails is a full-stack web framework optimized for programmer happiness and sustainable productivity.  It encourages beautiful code by favoring convention over configuration.")
>   (home-page "http://rubyonrails.org")
>   (license license:expat))
> mhw@jojen ~$ 

This is it! Setting "LC_ALL=C" works around the problem. Thanks for
chipping in. I've investigated on the Guile side and isolated the
problem to be with the file name only, which corroborates your finding:

--8<---------------cut here---------------start------------->8---
(use-modules (ice-9 ftw)
	     (gnutls))

(define ffile "/etc/ssl/certs/AC_Raíz_Certicámara_S.A.:2.15.7.126.82.147.123.224.21.227.87.240.105.140.203.236.12.pem")

;; Simply copied to my home dir.
(define ffile-2 "/home/maxim/AC_Raíz_Certicámara_S.A.:2.15.7.126.82.147.123.224.21.227.87.240.105.140.203.236.12.pem")

;; s/í/i/ & s/á/a/
(define ffile-3 "/home/maxim/AC_Raiz_Certicamara_S.A.:2.15.7.126.82.147.123.224.21.227.87.240.105.140.203.236.12.pem")

(define cred (make-certificate-credentials))

(set-certificate-credentials-x509-trust-file! cred ffile-2
					      x509-certificate-format/pem)
;; => ERROR: Throw to key `gnutls-error' with args `(#<gnutls-error-enum Error while reading file.> set-certificate-credentials-x509-trust-file!)'.


(set-certificate-credentials-x509-trust-file! cred ffile-2
					      x509-certificate-format/pem)
;; => ERROR: Throw to key `gnutls-error' with args `(#<gnutls-error-enum Error while reading file.> set-certificate-credentials-x509-trust-file!)'.

(set-certificate-credentials-x509-trust-file! cred ffile-3
					      x509-certificate-format/pem)
;; => 1
--8<---------------cut here---------------end--------------->8---

Maxim

  reply	other threads:[~2017-05-29  4:37 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-16  5:19 bug#26948: gnutls errors on multiple guix commands Maxim Cournoyer
2017-05-17 12:56 ` Ludovic Courtès
2017-05-25  7:26   ` Maxim Cournoyer
2017-05-26  8:56     ` Ludovic Courtès
2017-05-28 18:38       ` Mark H Weaver
2017-05-29  4:36         ` Maxim Cournoyer [this message]
2017-05-29  9:31         ` Ludovic Courtès
2017-05-29 21:26           ` Mark H Weaver
2017-05-30 11:25             ` Ludovic Courtès
2017-05-28 21:00       ` Maxim Cournoyer
2017-05-29  9:12         ` bug#26948: ‘write-file’ output should not be locale-dependent Ludovic Courtès
2017-05-29 20:15           ` Maxim Cournoyer
2017-05-30 11:57             ` Ludovic Courtès
2017-06-16 15:09               ` Ludovic Courtès
2017-07-27 12:55           ` Ludovic Courtès
2021-01-08 22:04             ` bug#26948: 'guix publish' file name decoding is locale-dependent Maxim Cournoyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87poess2j3.fsf@gmail.com \
    --to=maxim.cournoyer@gmail.com \
    --cc=26948@debbugs.gnu.org \
    --cc=mhw@netris.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).