r58708 - in /branches/upstream/libcrypt-openssl-x509-perl/current: Changes README X509.pm X509.xs t/utf8.t t/x509.t

carnil-guest at users.alioth.debian.org carnil-guest at users.alioth.debian.org
Tue Jun 1 06:32:52 UTC 2010


Author: carnil-guest
Date: Tue Jun  1 06:31:29 2010
New Revision: 58708

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=58708
Log:
[svn-upgrade] new version libcrypt-openssl-x509-perl (1.2)

Modified:
    branches/upstream/libcrypt-openssl-x509-perl/current/Changes
    branches/upstream/libcrypt-openssl-x509-perl/current/README
    branches/upstream/libcrypt-openssl-x509-perl/current/X509.pm
    branches/upstream/libcrypt-openssl-x509-perl/current/X509.xs
    branches/upstream/libcrypt-openssl-x509-perl/current/t/utf8.t
    branches/upstream/libcrypt-openssl-x509-perl/current/t/x509.t

Modified: branches/upstream/libcrypt-openssl-x509-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcrypt-openssl-x509-perl/current/Changes?rev=58708&op=diff
==============================================================================
--- branches/upstream/libcrypt-openssl-x509-perl/current/Changes (original)
+++ branches/upstream/libcrypt-openssl-x509-perl/current/Changes Tue Jun  1 06:31:29 2010
@@ -1,4 +1,9 @@
 Revision history for Perl extension Crypt::OpenSSL::X509.
+
+1.2    Mon May 31 05:59:03 PDT 2010
+	- Compatible with OpenSSL v1.0.0
+	- Incompatible change: Removed fingerprint_md2 method.
+	- Fix leaked memory on module END.
 
 1.1    Fri May 21 17:10:28 PDT 2010
 	- Fix memory leak in sv_bio_final() (CPAN RT #57719)

Modified: branches/upstream/libcrypt-openssl-x509-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcrypt-openssl-x509-perl/current/README?rev=58708&op=diff
==============================================================================
--- branches/upstream/libcrypt-openssl-x509-perl/current/README (original)
+++ branches/upstream/libcrypt-openssl-x509-perl/current/README Tue Jun  1 06:31:29 2010
@@ -1,4 +1,4 @@
-Crypt/OpenSSL/X509 version 0.9
+Crypt/OpenSSL/X509 version 1.2
 ===============================
 
 The README is used to introduce the module and provide instructions on

Modified: branches/upstream/libcrypt-openssl-x509-perl/current/X509.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcrypt-openssl-x509-perl/current/X509.pm?rev=58708&op=diff
==============================================================================
--- branches/upstream/libcrypt-openssl-x509-perl/current/X509.pm (original)
+++ branches/upstream/libcrypt-openssl-x509-perl/current/X509.pm Tue Jun  1 06:31:29 2010
@@ -5,11 +5,11 @@
 use Exporter;
 use base qw(Exporter);
 
-$VERSION = '1.1';
+$VERSION = '1.2';
 
 @EXPORT_OK = qw(
   FORMAT_UNDEF FORMAT_ASN1 FORMAT_TEXT FORMAT_PEM FORMAT_NETSCAPE
-  FORMAT_PKCS12 FORMAT_SMIME FORMAT_ENGINE FORMAT_IISSGC
+  FORMAT_PKCS12 FORMAT_SMIME FORMAT_ENGINE FORMAT_IISSGC OPENSSL_VERSION_NUMBER
 );
 
 sub Crypt::OpenSSL::X509::bit_length {
@@ -90,6 +90,10 @@
   *dl_load_flags = DynaLoader->can('dl_load_flags');
 
   do {__PACKAGE__->can('bootstrap') || \&DynaLoader::bootstrap}->(__PACKAGE__, $VERSION);
+}
+
+END {
+  __PACKAGE__->__X509_cleanup;
 }
 
 1;
@@ -117,7 +121,6 @@
   print $x509->exponent() . "\n";
   print $x509->fingerprint_sha1() . "\n";
   print $x509->fingerprint_md5() . "\n";
-  print $x509->fingerprint_md2() . "\n";
   print $x509->as_string(Crypt::OpenSSL::X509::FORMAT_TEXT) . "\n";
 
   my $x509 = Crypt::OpenSSL::X509->new_from_string(
@@ -247,8 +250,6 @@
 
 =item fingerprint_md5 ( )
 
-=item fingerprint_md2 ( )
-
 =item fingerprint_sha1 ( )
 
 Return the specified message digest for the certificate.

Modified: branches/upstream/libcrypt-openssl-x509-perl/current/X509.xs
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcrypt-openssl-x509-perl/current/X509.xs?rev=58708&op=diff
==============================================================================
--- branches/upstream/libcrypt-openssl-x509-perl/current/X509.xs (original)
+++ branches/upstream/libcrypt-openssl-x509-perl/current/X509.xs Tue Jun  1 06:31:29 2010
@@ -32,6 +32,15 @@
 typedef X509_NAME* Crypt__OpenSSL__X509__Name;
 typedef X509_NAME_ENTRY* Crypt__OpenSSL__X509__Name_Entry;
 
+/* 1.0 backwards compat */
+#ifndef sk_OPENSSL_STRING_num
+#define sk_OPENSSL_STRING_num sk_num
+#endif
+
+#ifndef sk_OPENSSL_STRING_value
+#define sk_OPENSSL_STRING_value sk_value
+#endif
+
 /* Unicode 0xfffd */
 static U8 utf8_substitute_char[3] = { 0xef, 0xbf, 0xbd };
 
@@ -74,6 +83,8 @@
   BIO_set_callback_arg(bio, (void *)NULL);
   BIO_set_callback(bio, (void *)NULL);
   BIO_free_all(bio);
+
+  if (!sv) sv = &PL_sv_undef;
 
   return sv;
 }
@@ -195,6 +206,35 @@
   return RETVAL;
 }
 
+void _decode_netscape(BIO *bio, X509 *x509) {
+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+
+    NETSCAPE_X509 nx;
+    ASN1_OCTET_STRING os;
+
+    os.data   = (unsigned char *)NETSCAPE_CERT_HDR;
+    os.length = strlen(NETSCAPE_CERT_HDR);
+    nx.header = &os;
+    nx.cert   = x509;
+
+    ASN1_item_i2d_bio(ASN1_ITEM_rptr(NETSCAPE_X509), bio, &nx);
+
+#else
+
+    ASN1_HEADER ah;
+    ASN1_OCTET_STRING os;
+
+    os.data   = (unsigned char *)NETSCAPE_CERT_HDR;
+    os.length = strlen(NETSCAPE_CERT_HDR);
+    ah.header = &os;
+    ah.data   = x509;
+    ah.meth   = X509_asn1_meth();
+
+    ASN1_i2d_bio((i2d_of_void*)i2d_ASN1_HEADER, bio, (unsigned char *)&ah);
+
+#endif
+}
+
 MODULE = Crypt::OpenSSL::X509    PACKAGE = Crypt::OpenSSL::X509
 
 PROTOTYPES: DISABLE
@@ -205,6 +245,7 @@
 
   struct { char *n; I32 v; } Crypt__OpenSSL__X509__const[] = {
 
+  {"OPENSSL_VERSION_NUMBER", OPENSSL_VERSION_NUMBER},
   {"FORMAT_UNDEF", FORMAT_UNDEF},
   {"FORMAT_ASN1", FORMAT_ASN1},
   {"FORMAT_TEXT", FORMAT_TEXT},
@@ -279,9 +320,9 @@
     RETVAL = (X509*)PEM_read_bio_X509(bio, NULL, NULL, NULL);
   }
 
+  if (!RETVAL) croak("%s: failed to read X509 certificate.", SvPV_nolen(class));
+
   BIO_free_all(bio);
-
-  if (!RETVAL) croak("%s: failed to read X509 certificate.", SvPV_nolen(class));
 
   OUTPUT:
   RETVAL
@@ -293,6 +334,16 @@
   PPCODE:
 
   if (x509) X509_free(x509); x509 = 0;
+
+# This is called via an END block in the Perl module to clean up initialization that happened in BOOT.
+void
+__X509_cleanup(void)
+  PPCODE:
+
+  CRYPTO_cleanup_all_ex_data();
+  ERR_free_strings();
+  ERR_remove_state(0);
+  EVP_cleanup();
 
 SV*
 accessor(x509)
@@ -351,10 +402,10 @@
   } else if (ix == 7) {
 
     int j;
-    STACK *emlst = X509_get1_email(x509);
-
-    for (j = 0; j < sk_num(emlst); j++) {
-      BIO_printf(bio, "%s", sk_value(emlst, j));
+    STACK_OF(OPENSSL_STRING) *emlst = X509_get1_email(x509);
+
+    for (j = 0; j < sk_OPENSSL_STRING_num(emlst); j++) {
+      BIO_printf(bio, "%s", sk_OPENSSL_STRING_value(emlst, j));
     }
 
     X509_email_free(emlst);
@@ -438,16 +489,7 @@
 
   } else if (format == FORMAT_NETSCAPE) {
 
-    ASN1_HEADER ah;
-    ASN1_OCTET_STRING os;
-
-    os.data   = (unsigned char *)NETSCAPE_CERT_HDR;
-    os.length = strlen(NETSCAPE_CERT_HDR);
-    ah.header = &os;
-    ah.data   = (char *)x509;
-    ah.meth   = X509_asn1_meth();
-
-    ASN1_i2d_bio((i2d_of_void*)i2d_ASN1_HEADER, bio, (unsigned char *)&ah);
+    _decode_netscape(bio, x509);
   }
 
   RETVAL = sv_bio_final(bio);
@@ -541,12 +583,11 @@
   Crypt::OpenSSL::X509 x509;
 
   ALIAS:
-  fingerprint_md2  = 1
   fingerprint_sha1 = 2
 
   PREINIT:
 
-  const EVP_MD *mds[] = { EVP_md5(), EVP_md2(), EVP_sha1() };
+  const EVP_MD *mds[] = { EVP_md5(), EVP_sha1() };
   unsigned char md[EVP_MAX_MD_SIZE];
   int i;
   unsigned int n;

Modified: branches/upstream/libcrypt-openssl-x509-perl/current/t/utf8.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcrypt-openssl-x509-perl/current/t/utf8.t?rev=58708&op=diff
==============================================================================
--- branches/upstream/libcrypt-openssl-x509-perl/current/t/utf8.t (original)
+++ branches/upstream/libcrypt-openssl-x509-perl/current/t/utf8.t Tue Jun  1 06:31:29 2010
@@ -5,7 +5,7 @@
 binmode(STDOUT, ":utf8");
 binmode(STDERR, ":utf8");
 
-use Devel::Peek;
+# use Devel::Peek;
 
 my $debug = 0;
 
@@ -39,11 +39,16 @@
 
 ######  and a broken UTF8 cert #####
 
-ok($x509 = Crypt::OpenSSL::X509->new_from_file('certs/broken-utf8.pem'), 'new_from_file()');
-$sub = $x509->subject();
-Dump($sub) if ($debug);
+# OpenSSL v1.0.0 (and higher?) fails to read this cert.
+SKIP: {
+  skip "OpenSSL v1.0.0 can't read broken certs.", 3 if Crypt::OpenSSL::X509::OPENSSL_VERSION_NUMBER >= 0x1000000f;
 
-ok(utf8::is_utf8($sub), "subject is utf8");
-is($sub, "C=PL, ST=mazowieckie, L=Warszawa, O=D.A.S. Towarzystwo Ubezpieczen Ochrony Prawnej S.A., OU=Dzi\x{fffd} Informatyki, CN=das.pl", "utf8 subject as expected");
+  ok($x509 = Crypt::OpenSSL::X509->new_from_file('certs/broken-utf8.pem'), 'new_from_file()');
+  $sub = $x509->subject();
+  Dump($sub) if ($debug);
+
+  ok(utf8::is_utf8($sub), "subject is utf8");
+  is($sub, "C=PL, ST=mazowieckie, L=Warszawa, O=D.A.S. Towarzystwo Ubezpieczen Ochrony Prawnej S.A., OU=Dzi\x{fffd} Informatyki, CN=das.pl", "utf8 subject as expected");
+};
 
 0;

Modified: branches/upstream/libcrypt-openssl-x509-perl/current/t/x509.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcrypt-openssl-x509-perl/current/t/x509.t?rev=58708&op=diff
==============================================================================
--- branches/upstream/libcrypt-openssl-x509-perl/current/t/x509.t (original)
+++ branches/upstream/libcrypt-openssl-x509-perl/current/t/x509.t Tue Jun  1 06:31:29 2010
@@ -15,7 +15,13 @@
 ok($x509->issuer() eq 'C=US, O=VeriSign, Inc., OU=Class 1 Public Primary Certification Authority', 'issuer()');
 ok($x509->subject() eq 'C=US, O=VeriSign, Inc., OU=Class 1 Public Primary Certification Authority', 'subject()');
 
-ok($x509->hash() eq '2edf7016', 'hash()');
+# For some reason the hash hash changed with v1.0.0
+# Verified with the openssl binary.
+if (Crypt::OpenSSL::X509::OPENSSL_VERSION_NUMBER >= 0x1000000f) {
+  ok($x509->hash() eq '24ad0b63', 'hash()');
+} else {
+  ok($x509->hash() eq '2edf7016', 'hash()');
+}
 
 ok($x509 = Crypt::OpenSSL::X509->new_from_file('certs/thawte.pem'), 'new_from_file()');
 




More information about the Pkg-perl-cvs-commits mailing list