Commit 7c59d28b10 for openssl.org

commit 7c59d28b1060509af998cd6e33152d48465e94fe
Author: Jakub Zelenka <jakub.zelenka@openssl.foundation>
Date:   Wed Jul 15 23:59:08 2026 +0200

    apps: cover the req -subj modification of an existing request

    Add a subtest exercising the code path in the req app that rewrites the
    subject of an existing certificate request loaded via -in, i.e. when
    -subj is given without -new/-newkey/-x509.

    Assisted-by: Claude:claude-opus-4-8

    Reviewed-by: Matt Caswell <matt@openssl.foundation>
    Reviewed-by: Ryan Hooper <ryanh@openssl.foundation>
    MergeDate: Mon Jul 27 10:19:06 2026
    (Merged from https://github.com/openssl/openssl/pull/31965)

diff --git a/test/recipes/25-test_req.t b/test/recipes/25-test_req.t
index a37686736f..67ad5b7a17 100644
--- a/test/recipes/25-test_req.t
+++ b/test/recipes/25-test_req.t
@@ -15,7 +15,7 @@ use OpenSSL::Test qw/:DEFAULT srctop_file/;

 setup("test_req");

-plan tests => 131;
+plan tests => 132;

 require_ok(srctop_file('test', 'recipes', 'tconversion.pl'));

@@ -321,6 +321,24 @@ subtest "generating certificate requests" => sub {
        "Verifying signature on request");
 };

+subtest "modifying the subject of an existing certificate request" => sub {
+    plan tests => 3;
+
+    my $req_in = srctop_file("test", "testreq2.pem");
+    my $req_out = "testreq-modified-subj.pem";
+    my $subj_out = "testreq-modified-subj.txt";
+
+    ok(run(app(["openssl", "req", "-config", srctop_file("test", "test.cnf"),
+                "-in", $req_in, "-subj", "/CN=Modified Subject",
+                "-out", $req_out])),
+       "Modifying subject of certificate request");
+
+    run(app(["openssl", "req", "-in", $req_out, "-noout", "-subject",
+             "-out", $subj_out]));
+    test_file_contains("modified request", $subj_out, "CN=Modified Subject", 1);
+    test_file_contains("modified request", $subj_out, "CN=cn4", 0);
+};
+
 subtest "generating SM2 certificate requests" => sub {
     plan tests => 4;