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

Avoid duplicate dir search #24140

Closed
Closed
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
16 changes: 6 additions & 10 deletions crypto/x509/by_store.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,7 @@ static int by_store_ctrl_ex(X509_LOOKUP *ctx, int cmd, const char *argp,
{
switch (cmd) {
case X509_L_ADD_STORE:
/* If no URI is given, use the default cert dir as default URI */
if (argp == NULL)
argp = ossl_safe_getenv(X509_get_default_cert_dir_env());

if (argp == NULL)
argp = X509_get_default_cert_dir();

{
if (argp != NULL) {
Copy link
Member

Choose a reason for hiding this comment

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

So is this a change in behaviour in the case that someone only adds the store lookup? i.e. could it break someone relying on this?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, they'd have to add some actual URIs to get anything to happen. I believe that's the right behaviour, but yes, it is different. One might for example ask why only the CApath and not the CAfile defaults into the store...

Copy link
Member

Choose a reason for hiding this comment

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

... One might for example ask why only the CApath and not the CAfile defaults into the store...

That was 100% arbitrary, "I have a hunch" style.

STACK_OF(OPENSSL_STRING) *uris = X509_LOOKUP_get_method_data(ctx);
char *data = OPENSSL_strdup(argp);

Expand All @@ -131,12 +124,15 @@ static int by_store_ctrl_ex(X509_LOOKUP *ctx, int cmd, const char *argp,
}
return sk_OPENSSL_STRING_push(uris, data) > 0;
}
/* NOP if no URI is given. */
return 1;
case X509_L_LOAD_STORE:
/* This is a shortcut for quick loading of specific containers */
return cache_objects(ctx, argp, NULL, 0, libctx, propq);
default:
/* Unsupported command */
return 0;
}

return 0;
}

static int by_store_ctrl(X509_LOOKUP *ctx, int cmd,
Expand Down
5 changes: 5 additions & 0 deletions crypto/x509/x509_d2.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ int X509_STORE_set_default_paths_ex(X509_STORE *ctx, OSSL_LIB_CTX *libctx,
lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_store());
if (lookup == NULL)
return 0;
/*
* The NULL URI argument will activate any default URIs (presently none),
* DO NOT pass the default CApath or CAfile, they're already handled above,
* likely much more efficiently.
*/
X509_LOOKUP_add_store_ex(lookup, NULL, libctx, propq);

/* clear any errors */
Expand Down
Loading