|
@@ -0,0 +1,95 @@
|
|
|
|
|
+From 40166fd8d88f33c621d3cca0b936f31816f3fe2e Mon Sep 17 00:00:00 2001
|
|
|
|
|
+From: Robert Marko <[email protected]>
|
|
|
|
|
+Date: Mon, 12 Jan 2026 14:40:23 +0100
|
|
|
|
|
+Subject: [PATCH] cert_create: add LibreSSL 3.9+ compatibility
|
|
|
|
|
+
|
|
|
|
|
+LibreSSL 3.9+ has dropped the whole support for X509V3 extensions.
|
|
|
|
|
+
|
|
|
|
|
+Generated by Gemini 3 Pro.
|
|
|
|
|
+
|
|
|
|
|
+Signed-off-by: Robert Marko <[email protected]>
|
|
|
|
|
+---
|
|
|
|
|
+ tools/cert_create/src/ext.c | 26 ++++++++++++++++++++++----
|
|
|
|
|
+ 1 file changed, 22 insertions(+), 4 deletions(-)
|
|
|
|
|
+
|
|
|
|
|
+--- a/tools/cert_create/src/ext.c
|
|
|
|
|
++++ b/tools/cert_create/src/ext.c
|
|
|
|
|
+@@ -51,15 +51,18 @@ int ext_init(void)
|
|
|
|
|
+ {
|
|
|
|
|
+ cmd_opt_t cmd_opt;
|
|
|
|
|
+ ext_t *ext;
|
|
|
|
|
++#if !defined(LIBRESSL_VERSION_NUMBER) || LIBRESSL_VERSION_NUMBER < 0x40200000L
|
|
|
|
|
+ X509V3_EXT_METHOD *m;
|
|
|
|
|
+- int nid, ret;
|
|
|
|
|
++ int ret, nid;
|
|
|
|
|
++#endif
|
|
|
|
|
+ unsigned int i;
|
|
|
|
|
+
|
|
|
|
|
+ extensions = malloc((num_def_extensions * sizeof(def_extensions[0]))
|
|
|
|
|
+ #ifdef PDEF_EXTS
|
|
|
|
|
+ + (num_pdef_extensions * sizeof(pdef_extensions[0]))
|
|
|
|
|
+ #endif
|
|
|
|
|
+- );
|
|
|
|
|
++ );
|
|
|
|
|
++
|
|
|
|
|
+ if (extensions == NULL) {
|
|
|
|
|
+ ERROR("%s:%d Failed to allocate memory.\n", __func__, __LINE__);
|
|
|
|
|
+ return 1;
|
|
|
|
|
+@@ -69,7 +72,7 @@ int ext_init(void)
|
|
|
|
|
+ (num_def_extensions * sizeof(def_extensions[0])));
|
|
|
|
|
+ #ifdef PDEF_EXTS
|
|
|
|
|
+ memcpy(&extensions[num_def_extensions], &pdef_extensions[0],
|
|
|
|
|
+- (num_pdef_extensions * sizeof(pdef_extensions[0])));
|
|
|
|
|
++ (num_pdef_extensions * sizeof(pdef_extensions[0])));
|
|
|
|
|
+ num_extensions = num_def_extensions + num_pdef_extensions;
|
|
|
|
|
+ #else
|
|
|
|
|
+ num_extensions = num_def_extensions;
|
|
|
|
|
+@@ -86,11 +89,15 @@ int ext_init(void)
|
|
|
|
|
+ cmd_opt.help_msg = ext->help_msg;
|
|
|
|
|
+ cmd_opt_add(&cmd_opt);
|
|
|
|
|
+ }
|
|
|
|
|
++
|
|
|
|
|
+ /* Register the extension OID in OpenSSL */
|
|
|
|
|
+ if (ext->oid == NULL) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
++
|
|
|
|
|
++#if !defined(LIBRESSL_VERSION_NUMBER) || LIBRESSL_VERSION_NUMBER < 0x40200000L
|
|
|
|
|
+ nid = OBJ_create(ext->oid, ext->sn, ext->ln);
|
|
|
|
|
++
|
|
|
|
|
+ if (ext->alias) {
|
|
|
|
|
+ X509V3_EXT_add_alias(nid, ext->alias);
|
|
|
|
|
+ } else {
|
|
|
|
|
+@@ -117,7 +124,16 @@ int ext_init(void)
|
|
|
|
|
+ return 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
++#else
|
|
|
|
|
++ /*
|
|
|
|
|
++ * LibreSSL 4.2.0+ removed X509V3_EXT_add/alias.
|
|
|
|
|
++ * We still register the OID, but ignore the returned NID
|
|
|
|
|
++ * as we skip method registration.
|
|
|
|
|
++ */
|
|
|
|
|
++ OBJ_create(ext->oid, ext->sn, ext->ln);
|
|
|
|
|
++#endif
|
|
|
|
|
+ }
|
|
|
|
|
++
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+@@ -323,12 +339,14 @@ void ext_cleanup(void)
|
|
|
|
|
+ for (i = 0; i < num_extensions; i++) {
|
|
|
|
|
+ if (extensions[i].arg != NULL) {
|
|
|
|
|
+ void *ptr = (void *)extensions[i].arg;
|
|
|
|
|
+-
|
|
|
|
|
+ extensions[i].arg = NULL;
|
|
|
|
|
+ free(ptr);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ free(extensions);
|
|
|
|
|
++
|
|
|
|
|
++#if !defined(LIBRESSL_VERSION_NUMBER) || LIBRESSL_VERSION_NUMBER < 0x40200000L
|
|
|
|
|
+ X509V3_EXT_cleanup();
|
|
|
|
|
++#endif
|
|
|
|
|
+ }
|
|
|
|
|
+
|