JosiahWI commented on code in PR #13476:
URL: https://github.com/apache/trafficserver/pull/13476#discussion_r3714348112
##########
plugins/certifier/certifier.cc:
##########
@@ -401,12 +402,20 @@ mkcrt(const std::string &commonName, int serial)
X509_gmtime_adj(X509_get_notAfter(cert.get()), static_cast<long>(3650) * 24
* 3600);
// Get handle to subject name
- X509_NAME *n = X509_get_subject_name(cert.get());
+ scoped_X509_NAME n{X509_NAME_dup(X509_get_subject_name(cert.get())),
X509_NAME_free};
+ if (n == nullptr) {
+ TSError("[%s] %s: failed to duplicate certificate subject", PLUGIN_NAME,
__func__);
+ return nullptr;
+ }
// Set common name field
- if (X509_NAME_add_entry_by_txt(n, "CN", MBSTRING_ASC, (unsigned char
*)commonName.c_str(), -1, -1, 0) != 1) {
+ if (X509_NAME_add_entry_by_txt(n.get(), "CN", MBSTRING_ASC, (unsigned char
*)commonName.c_str(), -1, -1, 0) != 1) {
TSError("[%s] %s: failed to add certificate subject CN", PLUGIN_NAME,
__func__);
return nullptr;
}
+ if (X509_set_subject_name(cert.get(), n.get()) != 1) {
+ TSError("[%s] %s: failed to set certificate subject", PLUGIN_NAME,
__func__);
+ return nullptr;
+ }
Review Comment:
That makes sense. Thanks for walking me through that!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]