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

openssl/gen_cert: fix error when cert_info->subject is empty #99

Merged
merged 2 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 0 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
24 changes: 15 additions & 9 deletions crypto_wrappers/openssl/gen_cert.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Loading