[csw-devel] SF.net SVN: gar:[16352] csw/mgar/pkg/ca_certificates/trunk/files/ certdata2pem.pl

chninkel at users.sourceforge.net chninkel at users.sourceforge.net
Sat Dec 3 19:57:50 CET 2011


Revision: 16352
          http://gar.svn.sourceforge.net/gar/?rev=16352&view=rev
Author:   chninkel
Date:     2011-12-03 18:57:50 +0000 (Sat, 03 Dec 2011)
Log Message:
-----------
cacertificates: fixed a mistake in certdata2pem.pl that caused some certificates to be ignored

Modified Paths:
--------------
    csw/mgar/pkg/ca_certificates/trunk/files/certdata2pem.pl

Modified: csw/mgar/pkg/ca_certificates/trunk/files/certdata2pem.pl
===================================================================
--- csw/mgar/pkg/ca_certificates/trunk/files/certdata2pem.pl	2011-12-03 18:34:56 UTC (rev 16351)
+++ csw/mgar/pkg/ca_certificates/trunk/files/certdata2pem.pl	2011-12-03 18:57:50 UTC (rev 16352)
@@ -85,19 +85,21 @@
 	
 	if ($line =~ /^\s*$/) {
 
-		if (exists($certdata_object->{"SERIAL_NUMBER"})) {
+		if (exists ($certdata_object->{"ISSUER"}) and exists ($certdata_object->{"SERIAL_NUMBER"})) {
+
 			my $serial_number = $certdata_object->{"SERIAL_NUMBER"};
-			if (exists ($certificates_list->{$serial_number})) {
-				my $certificate = $certificates_list->{$serial_number};
+			my $issuer = $certdata_object->{"ISSUER"};
 
-				if ($certificate->{"ISSUER"} eq $certdata_object->{"ISSUER"}) {
-					@{$certificate}{ keys (%{$certdata_object}) } = values (%{$certdata_object});
-				}
+			$certificates_list->{$issuer} = {} if (not exists ($certificates_list->{$issuer}));
 
+			if (exists ($certificates_list->{$issuer}->{$serial_number})) {
+
+				my $certificate = $certificates_list->{$issuer}->{$serial_number};
+				@{$certificate}{ keys (%{$certdata_object}) } = values (%{$certdata_object});
+
 			} else {
-				$certificates_list->{$serial_number} = $certdata_object;
+				$certificates_list->{$issuer}->{$serial_number} = $certdata_object;
 			}
-
 		}
 		$certdata_object = {};
 		next;
@@ -124,29 +126,33 @@
 }
 
 
-foreach my $certificate (values(%{$certificates_list})) {
-	my $trusted = 1;
-	foreach my $trust ("TRUST_SERVER_AUTH", 
-		           "TRUST_EMAIL_PROTECTION",
-			   "TRUST_CODE_SIGNING") {
-	   	if ($certificate->{$trust} eq "CKT_NSS_NOT_TRUSTED") {
-			$trusted = 0;
+foreach my $certificates_by_issuer (values (%{$certificates_list})) {
+
+	foreach my $certificate (values (%{$certificates_by_issuer})) {
+
+		my $trusted = 1;
+		foreach my $trust ("TRUST_SERVER_AUTH", 
+				   "TRUST_EMAIL_PROTECTION",
+				   "TRUST_CODE_SIGNING") {
+			if ($certificate->{$trust} eq "CKT_NSS_NOT_TRUSTED") {
+				$trusted = 0;
+			}
 		}
-	}
-	if ($trusted) {
+		if ($trusted) {
 
-		my $filename = label_to_filename ($certificate->{"LABEL"});
+			my $filename = label_to_filename ($certificate->{"LABEL"});
 
-		open (FH, "> $filename");
-		print FH "-----BEGIN CERTIFICATE-----\n";
-		print FH encode_base64 ($certificate->{"VALUE"});
-		print FH "-----END CERTIFICATE-----\n";
-		close (FH);
-		print "Created $filename certificate\n";
+			open (FH, "> $filename");
+			print FH "-----BEGIN CERTIFICATE-----\n";
+			print FH encode_base64 ($certificate->{"VALUE"});
+			print FH "-----END CERTIFICATE-----\n";
+			close (FH);
+			print "Created $filename certificate\n";
 
-	} else {
+		} else {
 
-		print "Certificate " . $certificate->{"LABEL"} . " Not trusted\n";
+			print "Certificate " . $certificate->{"LABEL"} . " Not trusted\n";
+		}
 	}
 }
 

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the devel mailing list