[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH] tests: detect gnutls errors



At 07/23/2011 04:13 AM, Eric Blake Write:
> * tests/virnettlscontexttest.c (testTLSLoadKey): Report errors.
> ---
> 
> Something in gnutls 2.8.5 (RHEL 6) was more leniant than gnutls
> 2.8.6 (Fedora 14).  This still doesn't solve the failure, but at
> least gets us to see that newer gnutls_x509_privkey_import doesn't
> like our define of PRIVATE_KEY.
> 
>  tests/virnettlscontexttest.c |   12 ++++++++++--
>  1 files changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/virnettlscontexttest.c b/tests/virnettlscontexttest.c
> index e70cd8b..043ccc2 100644
> --- a/tests/virnettlscontexttest.c
> +++ b/tests/virnettlscontexttest.c
> @@ -410,10 +410,18 @@ static gnutls_x509_privkey_t testTLSLoadKey(void)
>  {
>      gnutls_x509_privkey_t key;
>      const gnutls_datum_t data = { (unsigned char *)PRIVATE_KEY, strlen(PRIVATE_KEY) };
> +    int err;
> 
> -    gnutls_x509_privkey_init(&key);
> +    if ((err = gnutls_x509_privkey_init(&key)) < 0) {
> +        VIR_WARN("Failed to init key %s", gnutls_strerror(err));
> +        abort();
> +    }
> 
> -    gnutls_x509_privkey_import(key, &data, GNUTLS_X509_FMT_PEM);
> +    if ((err = gnutls_x509_privkey_import(key, &data,
> +                                          GNUTLS_X509_FMT_PEM)) < 0) {

This function failed on my box, gnutls_strerror(err) is 'Base64 unexpected header error.'
The OS is RHEL6.1GA, and the gnutls's version is 2.8.5-4

> +        VIR_WARN("Failed to init key %s", gnutls_strerror(err));
> +        abort();
> +    }
> 
>      return key;
>  }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]