Skip to content

Comments

Add X509 related libctx changes.#12153

Closed
slontis wants to merge 11 commits intoopenssl:masterfrom
slontis:x509_setlibctx
Closed

Add X509 related libctx changes.#12153
slontis wants to merge 11 commits intoopenssl:masterfrom
slontis:x509_setlibctx

Conversation

@slontis
Copy link
Member

@slontis slontis commented Jun 15, 2020

  • In order to not add many X509_XXXX_with_libctx() functions the libctx and propq may be stored in the X509 object via a call to X509_new_with_libctx().
  • Loading via PEM_read_bio_X509() or d2i_X509() should pass in a created cert using X509_new_with_libctx().
  • Renamed some XXXX_ex() to XXX_with_libctx() for X509 API's.
  • Removed the extra parameters in check_purpose..
  • X509_digest() has been modified so that it expects a const EVP_MD object() and then internally it does the fetch when it needs to (via ASN1_item_digest_with_libctx()).
  • Added API's that set the libctx when they load such as X509_STORE_new_with_libctx() so that the cert chains can be verified.
Checklist
  • documentation is added or updated
  • tests are added or updated

@slontis slontis added approval: review pending This pull request needs review by a committer branch: master Applies to master branch labels Jun 15, 2020
@slontis
Copy link
Member Author

slontis commented Jun 15, 2020

The size of PR #11884 is getting quite large - so I have tried to separate out some bits into smaller PR's to make it easier to review.

@slontis slontis mentioned this pull request Jun 15, 2020
2 tasks
@slontis slontis changed the title X509 setlibctx Add X509 setlibctx Jun 17, 2020
@slontis
Copy link
Member Author

slontis commented Jun 26, 2020

I have temporarily merged in @levitte code for OPENSSL_CTX_set0_default().
The commit message needs changing and docs need to be added (once we are happy with the API's that have been added).

X509_set0_libctx() has been replaced by X509_new_with_libctx() (at least in this PR).
The new is important for some of the X509 read functions...
eg..

    cert = X509_new_with_libctx(libctx, NULL);

    PEM_read_bio_X509(in, &cert, ...);
       OR
    d2i_X509(&cert, in, len);

NOTE that d2i_X509() calls X509v3_cache_extensions if the cert object is passed in.

The ssl tests actually passed!!

@slontis slontis mentioned this pull request Jun 27, 2020
2 tasks
@slontis
Copy link
Member Author

slontis commented Jun 29, 2020

Rebased and fixed up documentation.
ping

@slontis slontis changed the title Add X509 setlibctx Add X509 related libctx changes. Jun 29, 2020
@slontis
Copy link
Member Author

slontis commented Jul 22, 2020

@mattcaswell - Some X509 functionality has changed in master which caused an unpleasant rebase.
I have collapsed the reviewed code into the first commit.
The remaining fixup commits are new to address the comments and rebase to master.

@mattcaswell
Copy link
Member

Travis failures are relevant.

@slontis
Copy link
Member Author

slontis commented Jul 22, 2020

Fixed memory leak..
Addressed comments related to store open/attach/load.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Source code style wise, I believe this isn't OK, as parenthesised things should be aligned with the left parenthesis.

However, I see nothing wrong with this, and I believe it fits our coding style:

OSSL_STORE_CTX *OSSL_STORE_open_with_libctx
    (const char *uri, const UI_METHOD *ui_method, void *ui_data,
     OSSL_STORE_post_process_info_fn post_process, void *post_process_data,
     OPENSSL_CTX *libctx, const char *propq);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Err.. this style is done all over the place and is (arguably) more readable than the proposed alternative.

Just as this is more readable (also arguably)

if (....) {
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@levitte are you going to block on either of the above two comments?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea how you think a function declaration compares to an if statement. They are completely different in my mind (apart from using parentheses in their respective syntax)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel strongly about the < name, libctx, propq > tuple staying together. The code style issue, less so, but I am worried that we stray more and more from the style guide, and re-create the mess we had before.

(the coding style needs an update, and there's been several proposals, but not final decisions...)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea how you think a function declaration compares to an if statement.

As far as I am aware the reason for this format

if () {
}

Is related to scan-ability of the line.
So I am not sure why you think this can't also apply to () when it needs to span multiple lines.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have complied in this PR.. It doesn't mean I have to agree :)

@slontis
Copy link
Member Author

slontis commented Jul 22, 2020

Tests pass now - look like it is getting close to a final review.

slontis added 6 commits July 23, 2020 17:57
- In order to not add many X509_XXXX_with_libctx() functions the libctx and propq may be stored in the X509 object via a call to X509_new_with_libctx().
- Loading via PEM_read_bio_X509() or d2i_X509() should pass in a created cert using X509_new_with_libctx().
- Renamed some XXXX_ex() to XXX_with_libctx() for X509 API's.
- Removed the extra parameters in check_purpose..
- X509_digest() has been modified so that it expects a const EVP_MD object() and then internally it does the fetch when it needs to (via ASN1_item_digest_with_libctx()).
- Added API's that set the libctx when they load such as X509_STORE_new_with_libctx() so that the cert chains can be verified.
@slontis
Copy link
Member Author

slontis commented Jul 23, 2020

Had to rebase and apply a small change now that #11948 has been merged (which added the env variable to set the app_lib_ctx.

Copy link
Member

@mattcaswell mattcaswell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All my comments seem to have been addressed and CIs are green. Approving this subject to @levitte's outstanding issues being resolved.

@slontis
Copy link
Member Author

slontis commented Jul 23, 2020

Addressed @levitte's comments.

Copy link
Member

@levitte levitte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not quite there yet...

@slontis
Copy link
Member Author

slontis commented Jul 24, 2020

NOTE that

make update

does not like

void func
   (......
    .......)
{
    ...
    OSSL_STOREerr(0, ERR_R_MALLOC_FAILURE);
    ...
}

I assume it was looking for the '(' on the same line to indicate a function.. So there is still one in store_lib.c
that is doing

void func(
    ....
    ....)

@slontis
Copy link
Member Author

slontis commented Jul 24, 2020

Also removed the dead functions from include/crypto/store.h

@slontis slontis added approval: done This pull request has the required number of approvals and removed approval: review pending This pull request needs review by a committer labels Jul 24, 2020
@slontis
Copy link
Member Author

slontis commented Jul 24, 2020

@levitte function signatures changed now.. Will merge in a few hours in there are no more objections.

@slontis slontis added approval: ready to merge The 24 hour grace period has passed, ready to merge and removed approval: done This pull request has the required number of approvals labels Jul 24, 2020
Copy link
Member

@levitte levitte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok!

Copy link
Member

@mattcaswell mattcaswell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reconfirm

openssl-machine pushed a commit that referenced this pull request Jul 24, 2020
- In order to not add many X509_XXXX_with_libctx() functions the libctx and propq may be stored in the X509 object via a call to X509_new_with_libctx().
- Loading via PEM_read_bio_X509() or d2i_X509() should pass in a created cert using X509_new_with_libctx().
- Renamed some XXXX_ex() to XXX_with_libctx() for X509 API's.
- Removed the extra parameters in check_purpose..
- X509_digest() has been modified so that it expects a const EVP_MD object() and then internally it does the fetch when it needs to (via ASN1_item_digest_with_libctx()).
- Added API's that set the libctx when they load such as X509_STORE_new_with_libctx() so that the cert chains can be verified.

Reviewed-by: Richard Levitte <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from #12153)
@slontis
Copy link
Member Author

slontis commented Jul 24, 2020

Thanks for reviewing. Merged to master.

@slontis slontis closed this Jul 24, 2020
swenkeratmicrosoft pushed a commit to swenkeratmicrosoft/openssl that referenced this pull request Sep 1, 2020
- In order to not add many X509_XXXX_with_libctx() functions the libctx and propq may be stored in the X509 object via a call to X509_new_with_libctx().
- Loading via PEM_read_bio_X509() or d2i_X509() should pass in a created cert using X509_new_with_libctx().
- Renamed some XXXX_ex() to XXX_with_libctx() for X509 API's.
- Removed the extra parameters in check_purpose..
- X509_digest() has been modified so that it expects a const EVP_MD object() and then internally it does the fetch when it needs to (via ASN1_item_digest_with_libctx()).
- Added API's that set the libctx when they load such as X509_STORE_new_with_libctx() so that the cert chains can be verified.

Reviewed-by: Richard Levitte <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from openssl#12153)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approval: ready to merge The 24 hour grace period has passed, ready to merge branch: master Applies to master branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants