Commit ce24e2cdd1 for openssl.org

commit ce24e2cdd1d1d3c432c13c82877b3bab90d89069
Author: Jakub Zelenka <jakub.zelenka@openssl.foundation>
Date:   Tue Sep 8 17:26:35 2026 +0200

    test framework: add binary mode to slurp_file

    Allow reading back binary output files such as DER encoded
    structures without repeating the open and binmode boilerplate in
    the recipes.

    Assisted-by: Claude:claude-fable-5
    Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
    Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
    Merge-date: Wed Sep 16 14:39:41 2026
    Merged-from: https://github.com/openssl/openssl/pull/32702

diff --git a/util/perl/OpenSSL/Test.pm b/util/perl/OpenSSL/Test.pm
index 67e59b65e6..9fb0f16e83 100644
--- a/util/perl/OpenSSL/Test.pm
+++ b/util/perl/OpenSSL/Test.pm
@@ -838,22 +838,34 @@ sub with {

 =over 4

-=item B<slurp_file FILENAME>
+=item B<slurp_file FILENAME, OPTS>

 C<slurp_file> reads back the whole file FILENAME, usually an output
 captured with the C<stdout> or C<stderr> option of C<cmd> and its
 derivatives, and returns its content as a single string.  If the file
 cannot be opened, an empty string is returned.

+The following options OPTS are available:
+
+=over 4
+
+=item B<binary =E<gt> 0|1>
+
+When set to 1, the file is read in binary mode, for example to read
+back a DER encoded output.  The default is 0, reading in text mode.
+
+=back
+
 =back

 =cut

 sub slurp_file {
-    my ($file) = @_;
+    my ($file, %opts) = @_;
     my $content = '';

     if (open(my $fh, '<', $file)) {
+        binmode $fh if $opts{binary};
         $content = do { local $/; <$fh> };
         close($fh);
     }