-
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7067,8 +7067,10 @@ int wolfSSL_X509_REQ_print(WOLFSSL_BIO* bio, WOLFSSL_X509* x509) | |
return WOLFSSL_FAILURE; | ||
} | ||
|
||
/* print version of cert */ | ||
if (X509PrintVersion(bio, wolfSSL_X509_version(x509), 8) | ||
/* 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) | ||
!= WOLFSSL_SUCCESS) { | ||
return WOLFSSL_FAILURE; | ||
} | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. See |
||
{ | ||
WOLFSSL_ENTER("wolfSSL_X509_REQ_set_version"); | ||
if ((x == NULL) || (version < 0) || (version >= INT_MAX)) { | ||
return WOLFSSL_FAILURE; | ||
} | ||
x->version = (int)version; | ||
return WOLFSSL_SUCCESS; | ||
} | ||
|
||
long wolfSSL_X509_REQ_get_version(const WOLFSSL_X509 *req) | ||
{ | ||
WOLFSSL_ENTER("wolfSSL_X509_REQ_get_version"); | ||
if (req == NULL) { | ||
return 0; /* invalid arg */ | ||
} | ||
return (long)req->version; | ||
} | ||
|
||
int wolfSSL_X509_REQ_sign(WOLFSSL_X509 *req, WOLFSSL_EVP_PKEY *pkey, | ||
const WOLFSSL_EVP_MD *md) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
andwolfSSL_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.