From 5a729a7ef754c6a8faec8cfd4b206df0551094a2 Mon Sep 17 00:00:00 2001 From: ionut-cmd Date: Thu, 25 Jan 2024 14:51:36 +0000 Subject: [PATCH] add: icert/lcert to log --- src/brski/registrar/registrar_api.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/brski/registrar/registrar_api.cpp b/src/brski/registrar/registrar_api.cpp index 60d8e10..e8c1b72 100644 --- a/src/brski/registrar/registrar_api.cpp +++ b/src/brski/registrar/registrar_api.cpp @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include "../http/http.hpp" #include "../http/https_client.hpp" @@ -33,6 +35,21 @@ void save_to_log(CRYPTO_CERT icert, CRYPTO_CERT lcert, char *log_path) { imeta.issuer = init_keyvalue_list(); imeta.subject = init_keyvalue_list(); + + // Convert icert to PEM and write to log + FILE *fc = fopen(log_path, "a"); + if (fc != NULL) { + if (icert != NULL) { + PEM_write_X509(fc, (X509 *)icert); + } + if (lcert != NULL) { + PEM_write_X509(fc, (X509 *)lcert); + } + fclose(fc); + } else { + log_errno("fopen fail"); + } + log_trace("Saving the log"); if (imeta.issuer == NULL || imeta.subject == NULL) {