-
Notifications
You must be signed in to change notification settings - Fork 835
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
Fix for setting wrong version in CSRs. #8136
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good otherwise
src/x509.c
Outdated
@@ -14840,6 +14842,23 @@ void wolfSSL_X509_REQ_free(WOLFSSL_X509* req) | |||
wolfSSL_X509_free(req); | |||
} | |||
|
|||
int wolfSSL_X509_REQ_set_version(WOLFSSL_X509 *x, long version) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: Functions use brace on new line.
src/x509.c
Outdated
long wolfSSL_X509_REQ_get_version(const WOLFSSL_X509 *req) { | ||
WOLFSSL_ENTER("wolfSSL_X509_REQ_get_version"); | ||
if (req == NULL) { | ||
return WOLFSSL_FAILURE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would prefer return return 0; /* invalid arg */
here instead of WOLFSSL_FAILURE = 0
.
@@ -14840,6 +14842,25 @@ void wolfSSL_X509_REQ_free(WOLFSSL_X509* req) | |||
wolfSSL_X509_free(req); | |||
} | |||
|
|||
int wolfSSL_X509_REQ_set_version(WOLFSSL_X509 *x, long version) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See wolfSSL_X509_set_version
-> x509->version = (int) v + 1;
/* print version of cert. Note that we increment by 1 because for REQs, | ||
* the value stored in x509->version is the actual value of the field; not | ||
* the version. */ | ||
if (X509PrintVersion(bio, (int)wolfSSL_X509_REQ_get_version(x509) + 1, 8) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really the right way/place to adjust the version? The wolfSSL_X509_get_version
and wolfSSL_X509_set_version
do it differently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think the reason this is correct is because this is specific for REQs; not certificates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn’t the +1 be inside the get function? Or is this the same way openssl does it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the +1 was in the wolfSSL_X509_REQ_get_version() then it would return the wrong value. This behaviour matches OpenSSL.
retest this please |
Fixes ZD 18873
Testing