usercertificate attribute fingerprint (possibly OT)
Natxo Asenjo <[email protected]> Sun, 17 May 2015 17:10:44 +0200
| Newsgroups | gmane.comp.lang.perl.modules.ldap |
|---|---|
| Message-ID | <CAHBEJzWVNjMu97_pHaeVNnTsUW7iKfFG7VNDTKqBiYvBx0Tvtw@mail.gmail.com> |
--089e01493d443e694c0516487ba6
Content-Type: text/plain; charset=UTF-8
hi,
connecting to a freeipa ldap host (that uses the 389 directory server under
the hood) I can successfully retrieve certificates belonging to hosts.
I can then use Crypt::X509 to extract info from that. But how could I get
the fingerprints? If I use the apache directory studio ldap client I can
see the md5 and sha1 fingerprints of the attribute but I seem uncapable of
getting it using my script.
my $ldap = Net::LDAP->new( $server ) or die "$@";
my $mesg = $ldap->start_tls(
verify => 'require',
sslversion => 'tlsv1',
);
$mesg = $ldap->bind (
"testuser",
password => 'pwd',
version => 3,
);
my $search = $ldap->search(
base => $base,
scope => 'sub',
filter => '(objectclass=*)',
attr => ['usercertificate'],
);
for my $entry ( $search->entries) {
my $cert = $entry->get_value( 'usercertificate' );;
my $decoded = Crypt::X509->new ( cert => $cert );
if ( $decoded->error ) {
warn "Error parsing certificate: ", $decoded->error;
}
print "Subject: " . $decoded->subject_cn, "\n";
print "notafter: " . gmtime( $decoded->not_after) , "\n";
}
So this works, but I see no method to get the fingerprint. Is there a way
to get it from the info I get from ldap?
Thanks for any pointers.
--
Groeten,
natxo
--089e01493d443e694c0516487ba6
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div><div><div><div>hi,<br><br></div>connecting to a freei=
pa ldap host (that uses the 389 directory server under the hood) I can succ=
essfully retrieve certificates belonging to hosts.<br><br></div>I can then =
use Crypt::X509 to extract info from that. But how could I get the fingerpr=
ints? If I use the apache directory studio ldap client I can see the md5 an=
d sha1 fingerprints of the attribute but I seem uncapable of getting it usi=
ng my script.<br><br>my $ldap =3D Net::LDAP->new( $server ) or die "=
;$@";<br><br>my $mesg =3D $ldap->start_tls(<br>=C2=A0=C2=A0=C2=A0 v=
erify =3D> 'require',<br>=C2=A0=C2=A0=C2=A0 sslversion =3D> &=
#39;tlsv1',<br>);<br><br>$mesg =3D $ldap->bind (<br>=C2=A0=C2=A0=C2=
=A0 "testuser",<br>=C2=A0=C2=A0=C2=A0=C2=A0 password=C2=A0=C2=A0=
=C2=A0 =3D> 'pwd',<br>=C2=A0=C2=A0=C2=A0=C2=A0 version=C2=A0=C2=
=A0=C2=A0=C2=A0 =3D> 3,<br>);<br><br>my $search =3D $ldap->search(<br=
>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 base=C2=
=A0=C2=A0=C2=A0 =3D> $base,<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 scope=C2=A0=C2=A0 =3D> 'sub',<br>=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 filter=C2=A0 =3D&=
gt; '(objectclass=3D*)',<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 attr=C2=A0=C2=A0=C2=A0 =3D> ['usercertifica=
te'],<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 );<br><br><br>for my=
$entry ( $search->entries) {<br>=C2=A0=C2=A0=C2=A0 my $cert =3D=C2=A0 $=
entry->get_value( 'usercertificate' );;<br>=C2=A0=C2=A0=C2=A0 my=
$decoded =3D Crypt::X509->new ( cert =3D> $cert );<br>=C2=A0=C2=A0=
=C2=A0 if ( $decoded->error ) {<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0 warn "Error parsing certificate: ", $decoded->error;<br=
>=C2=A0=C2=A0=C2=A0 }<br>=C2=A0=C2=A0=C2=A0 print "Subject: " . $=
decoded->subject_cn, "\n"; <br>=C2=A0=C2=A0=C2=A0 print "=
notafter: " . gmtime( $decoded->not_after) , "\n";<br>}<b=
r><br></div>So this works, but I see no method to get the fingerprint. Is t=
here a way to get it from the info I get from ldap?<br><br></div>Thanks for=
any pointers.<br><div><div><div><div><div><div>=C2=A0<br><div class=3D"gma=
il_signature">--<br>Groeten,<br>natxo</div>
</div></div></div></div></div></div></div>
--089e01493d443e694c0516487ba6--