Index: tools/c_rehash.in
===================================================================
RCS file: /v/openssl/cvs/openssl/tools/c_rehash.in,v
retrieving revision 1.11.2.2
diff -u -r1.11.2.2 c_rehash.in
--- tools/c_rehash.in	14 Apr 2010 23:07:28 -0000	1.11.2.2
+++ tools/c_rehash.in	20 May 2010 07:32:23 -0000
@@ -9,6 +9,8 @@
 my $dir;
 my $prefix;
 
+my $compat_old;
+
 if(defined $ENV{OPENSSL}) {
 	$openssl = $ENV{OPENSSL};
 } else {
@@ -42,6 +44,18 @@
 	}
 }
 
+if ($ARGV[0] =~ /^-\?$|^-h$|^-?-help$/) {
+    print STDERR "Usage: $0 [-compat_old] [dir [...]]\n";
+    exit 0;
+}
+
+if ($ARGV[0] eq '-compat_old') {
+    shift @ARGV;
+    $compat_old = 1;
+} else {
+    $compat_old = 0;
+}
+
 if(@ARGV) {
 	@dirlist = @ARGV;
 } elsif($ENV{SSL_CERT_DIR}) {
@@ -82,8 +96,14 @@
 			print STDERR "WARNING: $fname does not contain a certificate or CRL: skipping\n";
 			next;
 		}
-		link_hash_cert($fname) if($cert);
-		link_hash_crl($fname) if($crl);
+		if ($cert) {
+		    link_hash_cert('-subject_hash', $fname);
+		    link_hash_cert('-subject_hash_old', $fname) if $compat_old;
+		}
+		if ($crl) {
+		    link_hash_crl('-subject_hash', $fname);
+		    link_hash_crl('-subject_hash_old', $fname) if $compat_old;
+		}
 	}
 }
 
@@ -115,9 +135,10 @@
 # certificate fingerprints
 
 sub link_hash_cert {
+		my $hash = shift @_;
 		my $fname = $_[0];
 		$fname =~ s/'/'\\''/g;
-		my ($hash, $fprint) = `"$openssl" x509 -hash -fingerprint -noout -in "$fname"`;
+		my ($hash, $fprint) = `"$openssl" x509 $hash -fingerprint -noout -in "$fname"`;
 		chomp $hash;
 		chomp $fprint;
 		$fprint =~ s/^.*=//;
@@ -150,9 +171,10 @@
 # Same as above except for a CRL. CRL links are of the form <hash>.r<n>
 
 sub link_hash_crl {
+		my $hash = shift @_;
 		my $fname = $_[0];
 		$fname =~ s/'/'\\''/g;
-		my ($hash, $fprint) = `"$openssl" crl -hash -fingerprint -noout -in '$fname'`;
+		my ($hash, $fprint) = `"$openssl" crl $hash -fingerprint -noout -in '$fname'`;
 		chomp $hash;
 		chomp $fprint;
 		$fprint =~ s/^.*=//;
