[rt-commit] r138 - in /redwax-tool/trunk: ChangeLog redwax_openssl.c

rt-commit at redwax.eu rt-commit at redwax.eu
Sat Oct 1 14:14:21 CEST 2022


Author: minfrin at redwax.eu
Date: Sat Oct  1 14:14:20 2022
New Revision: 138

Log:
Separate stdout and stderr when generating metadata so
that one doesn't ruin a cut and paste from the other.

Modified:
    redwax-tool/trunk/ChangeLog
    redwax-tool/trunk/redwax_openssl.c

Modified: redwax-tool/trunk/ChangeLog
==============================================================================
--- redwax-tool/trunk/ChangeLog	(original)
+++ redwax-tool/trunk/ChangeLog	Sat Oct  1 14:14:20 2022
@@ -1,5 +1,9 @@
 
 Changes with v0.9.2
+
+ *) Separate stdout and stderr when generating metadata so
+    that one doesn't ruin a cut and paste from the other.
+    [Graham Leggett]
 
  *) Add --der-out, with the ability to split certificates,
     intermediates, roots, crls and keys into individual

Modified: redwax-tool/trunk/redwax_openssl.c
==============================================================================
--- redwax-tool/trunk/redwax_openssl.c	(original)
+++ redwax-tool/trunk/redwax_openssl.c	Sat Oct  1 14:14:20 2022
@@ -4141,11 +4141,7 @@
 static apr_status_t redwax_openssl_process_metadata_out(redwax_tool_t *r,
         const char *file)
 {
-//    X509 *x = NULL;
-
     redwax_metadata_t *m;
-
-//    EVP_PKEY *pkey = NULL;
 
     apr_file_t *out;
     int i;
@@ -4163,11 +4159,7 @@
 
     }
 
-    redwax_metadata_push_root(r->pool, "Vault", redwax_openssl_writev, out, r->format, &m);
-
     if (r->cert_out) {
-
-        redwax_metadata_push_array(m, "Certificates", !r->certs_out->nelts);
 
         for (i = 0; i < r->certs_out->nelts; i++)
         {
@@ -4176,42 +4168,19 @@
 
             redwax_print_error(r, "metadata-out: certificate: %s\n",
                     cert->common.subject);
-
-            redwax_openssl_cert_metadata(r, m, cert);
-        }
-
-        redwax_metadata_pop_array(m);
-
+        }
     }
 
     if (r->chain_out) {
-
-        redwax_metadata_push_array(m, "Chains", !r->intermediates_out->nelts);
 
         for (i = 0; i < r->intermediates_out->nelts; i++)
         {
             const redwax_certificate_t *cert = &APR_ARRAY_IDX(r->intermediates_out,
                     i, const redwax_certificate_t);
 
-#if 0
-            const unsigned char *der = cert->der;
-
-            X509 *xi = d2i_X509(NULL, &der, cert->len);
-
-            if (!xi) {
-                redwax_openssl_print_errors(r);
-                X509_free(x);
-                return APR_ENOENT;
-            }
-#endif
-
             redwax_print_error(r, "metadata-out: intermediate: %s\n",
                     cert->common.subject);
-
-            redwax_openssl_cert_metadata(r, m, cert);
-        }
-
-        redwax_metadata_pop_array(m);
+        }
     }
 
     if (r->trust_out) {
@@ -4219,35 +4188,76 @@
         {
             const redwax_certificate_t *cert = &APR_ARRAY_IDX(r->trusted_out, i, const redwax_certificate_t);
 
-#if 0
-            const unsigned char *der = cert->der;
-
-            X509 *xi = d2i_X509_AUX(NULL, &der, cert->len);
-
-            if (!xi) {
-                redwax_openssl_print_errors(r);
-                X509_free(x);
-                return APR_ENOENT;
-            }
-#endif
-
             redwax_print_error(r, "metadata-out: trusted: %s\n",
                     cert->common.subject);
-
-            redwax_openssl_cert_metadata(r, m, cert);
         }
     }
 
     if (r->key_out) {
-
-        redwax_metadata_push_array(m, "Keys", !r->keys_out->nelts);
-
         for (i = 0; i < r->keys_out->nelts; i++)
         {
             const redwax_key_t
                 *key = &APR_ARRAY_IDX(r->keys_out, i, const redwax_key_t);
 
             redwax_print_error(r, "metadata-out: key\n");
+        }
+    }
+
+    redwax_metadata_push_root(r->pool, "Vault", redwax_openssl_writev, out, r->format, &m);
+
+    if (r->cert_out) {
+
+        redwax_metadata_push_array(m, "Certificates", !r->certs_out->nelts);
+
+        for (i = 0; i < r->certs_out->nelts; i++)
+        {
+            const redwax_certificate_t *cert = &APR_ARRAY_IDX(r->certs_out,
+                    i, const redwax_certificate_t);
+
+            redwax_openssl_cert_metadata(r, m, cert);
+        }
+
+        redwax_metadata_pop_array(m);
+
+    }
+
+    if (r->chain_out) {
+
+        redwax_metadata_push_array(m, "Chains", !r->intermediates_out->nelts);
+
+        for (i = 0; i < r->intermediates_out->nelts; i++)
+        {
+            const redwax_certificate_t *cert = &APR_ARRAY_IDX(r->intermediates_out,
+                    i, const redwax_certificate_t);
+
+            redwax_openssl_cert_metadata(r, m, cert);
+        }
+
+        redwax_metadata_pop_array(m);
+    }
+
+    if (r->trust_out) {
+
+        redwax_metadata_push_array(m, "Trusts", !r->trusted_out->nelts);
+
+    	for (i = 0; i < r->trusted_out->nelts; i++)
+        {
+            const redwax_certificate_t *cert = &APR_ARRAY_IDX(r->trusted_out, i, const redwax_certificate_t);
+
+            redwax_openssl_cert_metadata(r, m, cert);
+        }
+
+    	redwax_metadata_pop_array(m);
+    }
+
+    if (r->key_out) {
+
+        redwax_metadata_push_array(m, "Keys", !r->keys_out->nelts);
+
+        for (i = 0; i < r->keys_out->nelts; i++)
+        {
+            const redwax_key_t
+                *key = &APR_ARRAY_IDX(r->keys_out, i, const redwax_key_t);
 
             redwax_openssl_key_metadata(r, m, key);
         }



More information about the rt-commit mailing list