do not force msva-query-client to depend on Crypt::X509
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>
Mon, 18 Oct 2010 06:22:00 +0000 (02:22 -0400)
committerDaniel Kahn Gillmor <dkg@fifthhorseman.net>
Mon, 18 Oct 2010 06:22:00 +0000 (02:22 -0400)
Crypt/Monkeysphere/MSVA/Client.pm

index e2428363a00e0159fb1340fcfb4f81781f01a510..f586f9a0d1511c2370ee5a9f50501540b5c6df7a 100644 (file)
@@ -29,7 +29,6 @@
   use Crypt::Monkeysphere::MSVA::Logger;
   use LWP::UserAgent;
   use HTTP::Request;
-  require Crypt::X509;
 
   sub log {
     my $self = shift;
     $self->log('debug', "pkctype: %s\n", $pkctype);
 
     if ($pkctype eq 'x509der') {
-      my $cert = Crypt::X509->new(cert => $pkcdata);
-      if ($cert->error) {
-       die;
-      };
-      $self->log('info', "x509der certificate loaded.\n");
-      $self->log('verbose', "cert subject: %s\n", $cert->subject_cn());
-      $self->log('verbose', "cert issuer: %s\n", $cert->issuer_cn());
-      $self->log('verbose', "cert pubkey algo: %s\n", $cert->PubKeyAlg());
-      $self->log('verbose', "cert pubkey: %s\n", unpack('H*', $cert->pubkey()));
+      if (Module::Load::Conditional::can_load('modules' => { 'Crypt::X509' => undef })) {
+        my $cert = Crypt::X509->new(cert => $pkcdata);
+        if ($cert->error) {
+          die;
+        };
+        $self->log('info', "x509der certificate loaded.\n");
+        $self->log('verbose', "cert subject: %s\n", $cert->subject_cn());
+        $self->log('verbose', "cert issuer: %s\n", $cert->issuer_cn());
+        $self->log('verbose', "cert pubkey algo: %s\n", $cert->PubKeyAlg());
+        $self->log('verbose', "cert pubkey: %s\n", unpack('H*', $cert->pubkey()));
+      }
     } else {
        $self->log('error', "unknown pkc type '%s'.\n", $pkctype);
     };