Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add: icert/lcert to log #45

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/brski/registrar/registrar_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <memory>
#include <new>
#include <string>
#include <openssl/x509.h>
#include <openssl/pem.h>

#include "../http/http.hpp"
#include "../http/https_client.hpp"
Expand All @@ -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) {
Expand Down
Loading