@samitouri / QOSamiQemu / commits / 23c7d4f34b

crypto/x509-utils: Refactor with GNUTLS fallback

Always compile x509-utils.c and add a fallback when GNUTLS is unavailable. These functions will be needed in the s390x code regardless of whether GNUTLS is available. Signed-off-by: Zhuoying Cai <zycai@linux.ibm.com> Acked-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Farhan Ali <alifm@linux.ibm.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Link: https://lore.kernel.org/qemu-devel/20260730214624.2328883-3-zycai@linux.ibm.com Signed-off-by: Eric Farman <farman@linux.ibm.com>

Zhuoying Cai committed Jul 30, 2026 at 17:45 UTC 23c7d4f34b61f3160e00c92e2d38702f198fafbe
2 files changed +17 -1
crypto/meson.build
+1 -1
@@ -22,12 +22,12 @@ crypto_ss.add(files(
22 'tlscredsx509.c',
23 'tlssession.c',
24 'rsakey.c',
25 + 'x509-utils.c',
26 ))
27
28 if gnutls.found()
29 crypto_ss.add(files(
30 'tlscredsbox.c',
30 - 'x509-utils.c',
31 ))
32 endif
33
crypto/x509-utils.c
+16
@@ -11,6 +11,8 @@
11 #include "qemu/osdep.h"
12 #include "qapi/error.h"
13 #include "crypto/x509-utils.h"
14 +
15 +#ifdef CONFIG_GNUTLS
16 #include <gnutls/gnutls.h>
17 #include <gnutls/crypto.h>
18 #include <gnutls/x509.h>
@@ -79,3 +81,17 @@ int qcrypto_get_x509_cert_fingerprint(uint8_t *cert, size_t size,
81 gnutls_x509_crt_deinit(crt);
82 return ret;
83 }
84 +
85 +#else /* ! CONFIG_GNUTLS */
86 +
87 +int qcrypto_get_x509_cert_fingerprint(uint8_t *cert, size_t size,
88 + QCryptoHashAlgo hash,
89 + uint8_t *result,
90 + size_t *resultlen,
91 + Error **errp)
92 +{
93 + error_setg(errp, "GNUTLS is required to get fingerprint");
94 + return -1;
95 +}
96 +
97 +#endif /* ! CONFIG_GNUTLS */