From 51363dd4b9332c6cc4a85ce00621d381d96f4203 Mon Sep 17 00:00:00 2001 From: Kun Lai Date: Sat, 23 Sep 2023 14:52:20 +0000 Subject: [PATCH 1/2] openssl/gen_cert: fix error when cert_info->subject is empty Signed-off-by: Kun Lai --- crypto_wrappers/openssl/gen_cert.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/crypto_wrappers/openssl/gen_cert.c b/crypto_wrappers/openssl/gen_cert.c index 699bbe2..e33c2eb 100644 --- a/crypto_wrappers/openssl/gen_cert.c +++ b/crypto_wrappers/openssl/gen_cert.c @@ -160,15 +160,21 @@ crypto_wrapper_err_t openssl_gen_cert(crypto_wrapper_ctx_t *ctx, rats_hash_algo_ if (!name) goto err; - X509_NAME_add_entry_by_txt(name, "O", MBSTRING_ASC, - (const unsigned char *)cert_info->subject.organization, -1, -1, - 0); - X509_NAME_add_entry_by_txt(name, "OU", MBSTRING_ASC, - (const unsigned char *)cert_info->subject.organization_unit, -1, - -1, 0); - X509_NAME_add_entry_by_txt(name, "CN", MBSTRING_ASC, - (const unsigned char *)cert_info->subject.common_name, -1, -1, - 0); + if (cert_info->subject.organization) { + X509_NAME_add_entry_by_txt(name, "O", MBSTRING_ASC, + (const unsigned char *)cert_info->subject.organization, + -1, -1, 0); + } + if (cert_info->subject.organization_unit) { + X509_NAME_add_entry_by_txt( + name, "OU", MBSTRING_ASC, + (const unsigned char *)cert_info->subject.organization_unit, -1, -1, 0); + } + if (cert_info->subject.common_name) { + X509_NAME_add_entry_by_txt(name, "CN", MBSTRING_ASC, + (const unsigned char *)cert_info->subject.common_name, + -1, -1, 0); + } if (!X509_set_issuer_name(cert, name)) goto err; From 7432b615978dde388acec2a1ab902f6eccb36263 Mon Sep 17 00:00:00 2001 From: Kun Lai Date: Mon, 18 Sep 2023 13:15:09 +0000 Subject: [PATCH 2/2] .clang-format: fix conflict style Signed-off-by: Kun Lai --- .clang-format | 2 -- 1 file changed, 2 deletions(-) diff --git a/.clang-format b/.clang-format index b208348..2a1db88 100644 --- a/.clang-format +++ b/.clang-format @@ -56,7 +56,6 @@ BraceWrapping: SplitEmptyFunction: true # Unknown to clang-format-4.0 SplitEmptyRecord: true # Unknown to clang-format-4.0 SplitEmptyNamespace: true # Unknown to clang-format-4.0 -BreakAfterJavaFieldAnnotations: true BreakBeforeBinaryOperators: None BreakBeforeBraces: Custom #BreakBeforeConceptDeclarations: false # Unknown to clang-format-9.0 @@ -141,7 +140,6 @@ SpaceBeforeInheritanceColon: true # Unknown to clang-format-6.0 SpaceBeforeParens: ControlStatements SpaceBeforeRangeBasedForLoopColon: true # Unknown to clang-format-6.0 #SpaceBeforeSquareBrackets: false # Unknown to clang-format-9.0 -SpaceInEmptyParentheses: false #SpaceInEmptyBlock: true # Unknown to clang-format-9.0 SpaceInEmptyParentheses: false SpacesBeforeTrailingComments: 1