Subject: | OpenSSL supports multivalued attributes |
X500::DN 0.28
Perl 5.8.0
Linux i686 (SuSE 8.1)
OpenSSL supports multivalued attributes in version 0.9.7. The attached patch fixes the module to support parsing of such DNs (incl. fixes for the tests). A new release of the module is really important for us because we don't like to publish software with the statement "if you want all functions then you must use a patched module".
diff -ru /tmp/X500-DN-0.28/RDN.pm X500-DN-0.28/RDN.pm
--- /tmp/X500-DN-0.28/RDN.pm 2002-04-24 15:20:04.000000000 +0200
+++ X500-DN-0.28/RDN.pm 2003-11-25 16:23:07.000000000 +0100
@@ -62,17 +62,14 @@
sub _OpenSSLquoteAttributeValue
{
my $value = shift;
- $value =~ s/([\\\/])/\\$1/g;
+ $value =~ s/([\\\/+])/\\$1/g;
return $value;
}
sub getOpenSSLString
{
my $self = shift;
- croak "openssl syntax for multi-valued RDNs is unknown" if ($self->isMultivalued);
- my $key = (keys (%$self))[0];
- my $s = "$key=".&_OpenSSLquoteAttributeValue ($self->{$key});
- return $s;
+ return join ('+', map { "$_=".&_OpenSSLquoteAttributeValue ($self->{$_}); } keys (%$self));
}
1;
diff -ru /tmp/X500-DN-0.28/t/dn.t X500-DN-0.28/t/dn.t
--- /tmp/X500-DN-0.28/t/dn.t 2002-05-07 17:22:08.000000000 +0200
+++ X500-DN-0.28/t/dn.t 2004-05-14 10:40:56.000000000 +0200
@@ -1,7 +1,7 @@
use strict;
use Test;
-BEGIN { plan tests => 43, todo => [38] };
+BEGIN { plan tests => 43, todo => [38, 42] };
use X500::DN;
ok(1); # If we made it this far, we're ok.
@@ -105,7 +105,7 @@
ok ($dn && $dn->getRDNs(), 2, 1);
$rdn = $dn && $dn->getRDN (1);
ok ($rdn && $rdn->getAttributeTypes(), 2);
-ok ($rdn && $rdn->getAttributeValue ('foo'), '1');
+ok ($rdn && $rdn->getAttributeValue ('foo'), '1 ');
ok ($rdn && $rdn->getAttributeValue ('bar'), '2');
# Test 40: illegal RFC 2253 syntax
@@ -119,7 +119,7 @@
# Test 42: no openssl output for multi-valued RDN
$dn = new X500::DN (new X500::RDN ('foo'=>1, 'bar'=>2));
$s = eval { $dn->getOpenSSLString() };
-ok (sub { $dn && !defined ($s) && $@ }, qr/^openssl syntax for multi-valued RDNs is unknown/);
+ok (sub { $dn && $s}, "/bar=2+foo=1");
# Test 43: produce openssl format with escapes
$dn = new X500::DN (new X500::RDN ('foo'=>'bar/\\baz'));