SYNOPSIS

  use X500::DN;

  my $dn = X500::DN->ParseRFC2253 ('cn=John Doe, o=Acme\\, Inc., c=US') or die;
  print $dn->getRFC2253String(), "\n";

  $dn = new X500::DN (new X500::RDN ('c'=>'US'), new X500::RDN ('cn'=>'John Doe'));
  my $rdn0 = $dn->getRDN (0);
  my $c = $rdn0->getAttributeValue ('c');

NOTE

The \s-1RFC\s0 2253 syntax is explicitely backwards in relation to the \s-1ASN\s0.1 \s-1SEQUENCE\s0.

So the \s-1RFC\s0 2253 string \*(C`cn=John Doe, c=US\*(C' has the same meaning as the X.500 string \*(C`c=US, cn=John Doe\*(C'. The X500::DN objects keep the RDNs in X.500 order!

DESCRIPTION

This module handles X.500 DNs (Distinguished Names). Currently, it parses \s-1DN\s0 strings formatted according to \s-1RFC\s0 2253 syntax into an internal format and produces \s-1RFC\s0 2253 formatted string from it.

Methods

  • $object = new X500::DN (rdn, rdn, ...); Creates a \s-1DN\s0 object from zero or more arguments of type X500::RDN.

  • $object = X500::DN->ParseRFC2253 ('cn=John Doe, o=Acme\\, Inc., c=US'); Creates a \s-1DN\s0 object from an \s-1RFC\s0 2253 formatted \s-1DN\s0 string notation.

  • $object->getRFC2253String(); Returns the \s-1DN\s0 as a string formatted according to \s-1RFC\s0 2253 syntax.

  • $object->getOpenSSLString(); Returns the \s-1DN\s0 as a string formatted suitable for \*(C`openssl req -subj\*(C' and \*(C`openssl ca -subj\*(C'.

  • $object->getX500String(); Returns the \s-1DN\s0 as a string formatted according to X.500 syntax. \s-1NOTE:\s0 This is a hack, there is no definition for a X.500 string syntax!

  • $object->hasMultivaluedRDNs(); Returns whether the \s-1DN\s0 contains multi-valued RDNs.

  • $object->getRDN (num); Returns the \s-1DN\s0's \s-1RDN\s0 at position num as an X500::RDN object. num starts with 0, which will return the first \s-1RDN\s0 in \s-1ASN\s0.1 \s-1SEQUENCE\s0 order.

  • $object->getRDNs(); Returns the \s-1DN\s0's RDNs, a list of objects of type X500::RDN, in \s-1ASN\s0.1 \s-1SEQUENCE\s0 order.

\s-1EXPORT\s0

None.

BUGS

  • Due to Parse::RecDescent's greedyness, white space after attribute values gets into the parsed value. It might be possible to work around this.

AUTHOR

Robert Joop <[email protected]>

COPYRIGHT

Copyright 2002 Robert Joop. All Rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

RELATED TO X500::DN…

X500::RDN, perl.

HISTORY

Early 2002: First idea, discussed on comp.lang.perl.moderated
April 2002: First public release, 0.15