diff options
author | NIIBE Yutaka <gniibe@fsij.org> | 2022-03-25 00:38:42 +0100 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2022-03-25 00:41:51 +0100 |
commit | 25d37a0a6a9c42326777c2949054a8bd6f276f8a (patch) | |
tree | d7992871fd61479f341c24a4cdfebe01ab64f21c /dirmngr/dirmngr-client.c | |
parent | dirmngr: Clear the error count to try certificate as binary. (diff) | |
download | gnupg2-25d37a0a6a9c42326777c2949054a8bd6f276f8a.tar.xz gnupg2-25d37a0a6a9c42326777c2949054a8bd6f276f8a.zip |
dirmngr: Suppress error message on trial reading as PEM format.
* dirmngr/dirmngr-client.c (read_pem_certificate): Add NO_ERRMSG
argument to suppress the error message.
(read_certificate, squid_loop_body): Follow the change.
--
GnuPG-bug-id: 5531
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Diffstat (limited to '')
-rw-r--r-- | dirmngr/dirmngr-client.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/dirmngr/dirmngr-client.c b/dirmngr/dirmngr-client.c index 67052c92e..3912bf47b 100644 --- a/dirmngr/dirmngr-client.c +++ b/dirmngr/dirmngr-client.c @@ -459,7 +459,8 @@ data_cb (void *opaque, const void *buffer, size_t length) returned in an alloced buffer whose address will be returned in RBUF and its length in RBUFLEN. */ static gpg_error_t -read_pem_certificate (const char *fname, unsigned char **rbuf, size_t *rbuflen) +read_pem_certificate (const char *fname, unsigned char **rbuf, size_t *rbuflen, + int no_errmsg) { estream_t fp; int c; @@ -602,7 +603,8 @@ read_pem_certificate (const char *fname, unsigned char **rbuf, size_t *rbuflen) } else if (state != s_waitend) { - log_error ("no certificate or invalid encoded\n"); + if (!no_errmsg) + log_error ("no certificate or invalid encoded\n"); xfree (buf); return gpg_error (GPG_ERR_INV_ARMOR); } @@ -625,13 +627,13 @@ read_certificate (const char *fname, unsigned char **rbuf, size_t *rbuflen) size_t nread, bufsize, buflen; if (opt.pem) - return read_pem_certificate (fname, rbuf, rbuflen); + return read_pem_certificate (fname, rbuf, rbuflen, 0); else if (fname) { /* A filename has been given. Let's just assume it is in PEM format and decode it, and fall back to interpreting it as binary certificate if that fails. */ - err = read_pem_certificate (fname, rbuf, rbuflen); + err = read_pem_certificate (fname, rbuf, rbuflen, 1); if (! err) return 0; /* Clear the error count to try as binary certificate. */ @@ -905,7 +907,7 @@ squid_loop_body (assuan_context_t ctx) unsigned char *certbuf; size_t certbuflen = 0; - err = read_pem_certificate (NULL, &certbuf, &certbuflen); + err = read_pem_certificate (NULL, &certbuf, &certbuflen, 0); if (gpg_err_code (err) == GPG_ERR_EOF) return err; if (err) |