1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

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>
This commit is contained in:
NIIBE Yutaka 2022-03-25 08:38:42 +09:00
parent 4d19759ce5
commit 25d37a0a6a

View File

@ -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,6 +603,7 @@ read_pem_certificate (const char *fname, unsigned char **rbuf, size_t *rbuflen)
}
else if (state != s_waitend)
{
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)