]> git.ipfire.org Git - people/ms/ipfire-2.x.git/commitdiff
Partially revert "vpnmain.cgi: Use new system methods"
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 13 Jul 2021 15:30:52 +0000 (15:30 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 13 Jul 2021 15:33:42 +0000 (15:33 +0000)
This reverts commit a81cbf61273536ee36f3d26504aabdcd65d39cca.

It was no longer possible to generate the root/host certificates.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
html/cgi-bin/vpnmain.cgi

index 8f13cf51fa294a3d8d871ccabe51b719514be1b3..80e93ffd3425b290d18b520a6eb32d7385ee46cc 100644 (file)
@@ -226,13 +226,9 @@ sub newcleanssldatabase {
 ###
 sub callssl ($) {
        my $opt = shift;
-
-       # Split the given argument string into single pieces and assign them to an array.
-       my @opts = split(/ /, $opt);
-
-       my @retssl = &General::system_output("/usr/bin/openssl", @opts); #redirect stderr
+       my $retssl = `/usr/bin/openssl $opt 2>&1`; #redirect stderr
        my $ret = '';
-       foreach my $line (split (/\n/, @retssl)) {
+       foreach my $line (split (/\n/, $retssl)) {
                &General::log("ipsec", "$line") if (0); # 1 for verbose logging
                $ret .= '<br>'.$line if ( $line =~ /error|unknown/ );
        }
@@ -246,21 +242,13 @@ sub callssl ($) {
 ###
 sub getCNfromcert ($) {
        #&General::log("ipsec", "Extracting name from $_[0]...");
-       my @temp = &General::system_output("/usr/bin/openssl", "x509", "-text", "-in", "$_[0]");
-       my $temp;
-
-       foreach my $line (@temp) {
-               if ($line =~ /Subject:.*CN = (.*)[\n]/) {
-                       $temp = $1;
-                       $temp =~ s+/Email+, E+;
-                       $temp =~ s/ ST = / S = /;
-                       $temp =~ s/,//g;
-                       $temp =~ s/\'//g;
-
-                       last;
-               }
-       }
-
+       my $temp = `/usr/bin/openssl x509 -text -in $_[0]`;
+       $temp =~ /Subject:.*CN = (.*)[\n]/;
+       $temp = $1;
+       $temp =~ s+/Email+, E+;
+       $temp =~ s/ ST = / S = /;
+       $temp =~ s/,//g;
+       $temp =~ s/\'//g;
        return $temp;
 }
 ###
@@ -268,19 +256,11 @@ sub getCNfromcert ($) {
 ###
 sub getsubjectfromcert ($) {
        #&General::log("ipsec", "Extracting subject from $_[0]...");
-       my @temp = &General::system_output("/usr/bin/openssl", "x509", "-text", "-in", "$_[0]");
-       my $temp;
-
-       foreach my $line (@temp) {
-               if($line =~ /Subject: (.*)[\n]/) {
-                       $temp = $1;
-                       $temp =~ s+/Email+, E+;
-                       $temp =~ s/ ST = / S = /;
-
-                       last;
-               }
-       }
-
+       my $temp = `/usr/bin/openssl x509 -text -in $_[0]`;
+       $temp =~ /Subject: (.*)[\n]/;
+       $temp = $1;
+       $temp =~ s+/Email+, E+;
+       $temp =~ s/ ST = / S = /;
        return $temp;
 }
 ###
@@ -689,8 +669,8 @@ END
                $errormessage = $!;
                goto UPLOADCA_ERROR;
        }
-       my @temp = &General::system_output("/usr/bin/openssl", "x509", "-text", "-in", "$filename");
-       if (! grep(/CA:TRUE/, @temp)) {
+       my $temp = `/usr/bin/openssl x509 -text -in $filename`;
+       if ($temp !~ /CA:TRUE/i) {
                $errormessage = $Lang::tr{'not a valid ca certificate'};
                unlink ($filename);
                goto UPLOADCA_ERROR;