crypto: Allow building with GnuTLS but without Libtasn1
PATCH 1/1 crypto: Allow building with GnuTLS but without Libtasn1
We only use Libtasn1 in unit tests. As noted in commit d47b83b118 ("tests: add migration tests of TLS with x509 credentials"), having GnuTLS without Libtasn1 is a valid configuration, so do not require Libtasn1, to avoid:
Dependency gnutls found: YES 3.7.1 (cached) Run-time dependency libtasn1 found: NO (tried pkgconfig)
../meson.build:1914:10: ERROR: Dependency "libtasn1" not found, tried pkgconfig
Restrict the unit test pkix_asn1_tab[] variable to CONFIG_TASN1.
--- meson.build | 1 + tests/unit/crypto-tls-x509-helpers.h | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-)
meson.build +1 -0
@@ -1912,6 +1912,7 @@ endif tasn1 = not_found if gnutls.found() tasn1 = dependency('libtasn1', + required: false, method: 'pkg-config') endif keyutils = not_found
tests/unit/crypto-tls-x509-helpers.h +3 -1
@@ -23,7 +23,6 @@#include <gnutls/gnutls.h> #include <gnutls/x509.h> -#include <libtasn1.h> #define QCRYPTO_TLS_TEST_CLIENT_NAME "ACME QEMU Client"
@@ -171,6 +170,9 @@ void test_tls_cleanup(const char *keyfile); }; \ test_tls_generate_cert(&varname, cavarname.crt) +#ifdef CONFIG_TASN1 +#include <libtasn1.h> extern const asn1_static_node pkix_asn1_tab[]; +#endif #endif
Signature · 1 line
2.41.0
Quoted 11 lines · Philippe Mathieu-Daudé
We only use Libtasn1 in unit tests. As noted in commit
d47b83b118("tests: add migration tests of TLS with x509 credentials"), having GnuTLS without Libtasn1 is a valid configuration, so do not require Libtasn1, to avoid:Dependency gnutls found: YES 3.7.1 (cached) Run-time dependency libtasn1 found: NO (tried pkgconfig)
../meson.build:1914:10: ERROR: Dependency "libtasn1" not found, tried pkgconfig
Restrict the unit test pkix_asn1_tab[] variable to
CONFIG_TASN1.
Otherwise we get:
In file included from tests/unit/crypto-tls-psk-helpers.c:23:
tests/unit/crypto-tls-x509-helpers.h:26:10: fatal error:
libtasn1.h: No such file or directory
26 | #include <libtasn1.h>
| ^~~~~~~~~~~~compilation terminated.
Quoted 41 lines
Fixes ba7ed407e6 ("configure, meson: convert libtasn1 detection to meson")Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- meson.build | 1 + tests/unit/crypto-tls-x509-helpers.h | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-)meson.build +1
-0@@ -1912,6 +1912,7 @@ endif tasn1 = not_found if gnutls.found() tasn1 = dependency('libtasn1', + required: false, method: 'pkg-config') endif keyutils = not_foundtests/unit/crypto-tls-x509-helpers.h +3
-1@@ -23,7 +23,6 @@#include <gnutls/gnutls.h> #include <gnutls/x509.h> -#include <libtasn1.h> #define QCRYPTO_TLS_TEST_CLIENT_NAME "ACME QEMU Client"@@ -171,6 +170,9 @@ void test_tls_cleanup(const char *keyfile); }; \ test_tls_generate_cert(&varname, cavarname.crt) +#ifdef CONFIG_TASN1 +#include <libtasn1.h> extern const asn1_static_node pkix_asn1_tab[]; +#endif #endif
Quoted 13 lines · Philippe Mathieu-Daudé
Quoted 11 lines · Philippe Mathieu-Daudé
We only use Libtasn1 in unit tests. As noted in commit
d47b83b118("tests: add migration tests of TLS with x509 credentials"), having GnuTLS without Libtasn1 is a valid configuration, so do not require Libtasn1, to avoid:Dependency gnutls found: YES 3.7.1 (cached) Run-time dependency libtasn1 found: NO (tried pkgconfig)
../meson.build:1914:10: ERROR: Dependency "libtasn1" not found, tried pkgconfig
Restrict the unit test pkix_asn1_tab[] variable to
CONFIG_TASN1.
Quoted 8 lines
Otherwise we get:
In file included from
tests/unit/crypto-tls-psk-helpers.c:23:
tests/unit/crypto-tls-x509-helpers.h:26:10: fatal error:
libtasn1.h: No such file or directory26 | #include <libtasn1.h> | ^~~~~~~~~~~~compilation terminated.
I'd say that crypto-tls-psk-helpers.c shouldn't be including crypto-tls-x509-helpers.h at all, as PSK auth does not depend on X509 code
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 23 lines · Daniel P. Berrangé
Quoted 13 lines · Philippe Mathieu-Daudé
Quoted 11 lines · Philippe Mathieu-Daudé
We only use Libtasn1 in unit tests. As noted in commit
d47b83b118("tests: add migration tests of TLS with x509 credentials"), having GnuTLS without Libtasn1 is a valid configuration, so do not require Libtasn1, to avoid:Dependency gnutls found: YES 3.7.1 (cached) Run-time dependency libtasn1 found: NO (tried pkgconfig)
../meson.build:1914:10: ERROR: Dependency "libtasn1" not found, tried pkgconfig
Restrict the unit test pkix_asn1_tab[] variable to
CONFIG_TASN1.Quoted 8 lines
Otherwise we get:
In file included from tests/unit/crypto-tls-psk-helpers.c:23: tests/unit/crypto-tls-x509-helpers.h:26:10: fatal error: libtasn1.h: No such file or directory 26 | #include <libtasn1.h> | ^~~~~~~~~~~~ compilation terminated.
Quoted 3 lines
I'd say that
crypto-tls-psk-helpers.cshouldn't be includingcrypto-tls-x509-helpers.hat all, as PSK auth does not depend on X509 code
I agree, I tried the "less code churn" path first :)
Quoted 24 lines · Philippe Mathieu-Daudé
Quoted 23 lines · Daniel P. Berrangé
Quoted 21 lines · Philippe Mathieu-Daudé
Quoted 11 lines · Philippe Mathieu-Daudé
We only use Libtasn1 in unit tests. As noted in commit
d47b83b118("tests: add migration tests of TLS with x509 credentials"), having GnuTLS without Libtasn1 is a valid configuration, so do not require Libtasn1, to avoid:Dependency gnutls found: YES 3.7.1 (cached) Run-time dependency libtasn1 found: NO (tried pkgconfig)
../meson.build:1914:10: ERROR: Dependency "libtasn1" not found, tried pkgconfig
Restrict the unit test pkix_asn1_tab[] variable to
CONFIG_TASN1.Otherwise we get:
In file included from
tests/unit/crypto-tls-psk-helpers.c:23:
tests/unit/crypto-tls-x509-helpers.h:26:10: fatal error:
libtasn1.h: No such file or directory
26 | #include <libtasn1.h>
| ^~~~~~~~~~~~
compilation terminated.
Quoted 5 lines
Quoted 3 lines
I'd say that
crypto-tls-psk-helpers.cshouldn't be includingcrypto-tls-x509-helpers.hat all, as PSK auth does not depend on X509 codeI agree, I tried the "less code churn" path first :)
test_tls_init() calls asn1_array2tree(), test_tls_cleanup() calls asn1_delete_structure() and test_tls_generate_cert() calls:
asn1_create_element(pkix_asn1, "PKIX1.BasicConstraints", ... asn1_write_value(ext, "cA", ... asn1_write_value(ext, "pathLenConstraint", ...