Skip to content

Commit

Permalink
Drop explicit check for engines in opt_legacy_okay
Browse files Browse the repository at this point in the history
The providers indication should always indicate that this is not a
legacy request.
This makes a check for engines redundant as the default return is that
legacy is ok if there are no explicit providers.

Fixes #19662

Signed-off-by: Simo Sorce <simo@redhat.com>
  • Loading branch information
simo5 committed Nov 14, 2022
1 parent ce74e3f commit b628e56
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
8 changes: 0 additions & 8 deletions apps/lib/apps.c
Expand Up @@ -3405,14 +3405,6 @@ int opt_legacy_okay(void)
{
int provider_options = opt_provider_option_given();
int libctx = app_get0_libctx() != NULL || app_get0_propq() != NULL;
#ifndef OPENSSL_NO_ENGINE
ENGINE *e = ENGINE_get_first();

if (e != NULL) {
ENGINE_free(e);
return 1;
}
#endif
/*
* Having a provider option specified or a custom library context or
* property query, is a sure sign we're not using legacy.
Expand Down
23 changes: 23 additions & 0 deletions test/recipes/20-test_legacy_okay.t
@@ -0,0 +1,23 @@
#! /usr/bin/env perl
# Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the Apache License 2.0 (the "License"). You may not use
# this file except in compliance with the License. You can obtain a copy
# in the file LICENSE in the source distribution or at
# https://www.openssl.org/source/license.html

use strict;
use warnings;

use OpenSSL::Test;

setup("test_legacy");

plan tests => 3;

ok(run(app(['openssl', 'rand', '-out', 'rand.txt', '256'])), "Generate random file");

ok(run(app(['openssl', 'dgst', '-sha256', 'rand.txt'])), "Generate a digest");

ok(!run(app(['openssl', 'dgst', '-sha256', '-propquery', 'foo=1',
'rand.txt'])), "Fail to generate a digest");

0 comments on commit b628e56

Please sign in to comment.