OpenSSL 1.0.0 support

e$B$3$s$K$A$O!#e(B

NetBSD currente$B$Ke(BOpenSSL 1.0.0e$B7ONs$N$Je(Bsnap
shote$B$,<h$j9~$^$l$F$+$ie(BRubye$B$Ne(B
openssle$B3HD%$,%3%s%Q%$%k$G$-$J$$$H$$$&Js9p$,$"$j$^$7$?!#e(B

e$B$6!<$C$H8+D>$7$F!"%&%)!<%K%s%0$r8:$i$9J}[email protected]$7$F$_$^$7$?$,!"$+$J$je(B
e$B$NJQ992U=j$,e(BOpenSSLe$B$K$"$k$3$H$,2~$a$F$o$+$j$^$7$?!#e(BRubye$B$N%Y!<%9$O!"e(B
Ruby 1.8.7 patchlevel 174e$B$G$9!#e(B

e$B$J$*!“e(Bopenssl_missing.he$B$”$?$j$O;C$/e(Bdowne$B$9$kA0$Ne(Bsvn.ruby-lang.orge$B$NJQ99e(B
[email protected]$r$=$N$^$^:N$jF~$l$F$$$kItJ,$b$"$j$^$9!#0l1~!"e(B

  • OpenSSL 1.1.0-dev 10 Jul 2009 on NetBSD current (5.99.15)
  • OpenSSL 0.9.9-dev 09 May 2008 on NetBSD 5.0_STABLE
  • OpenSSL 0.9.8e 23 Feb 2007 on NetBSD 4.0_STABLE

e$B$G%3%s%Q%$%k$r3NG’$7$^$7$?!#e(BOpenSSL
1.1.0-deve$B0J30$O%&%)!<%K%s%0$r$J$/e(B
e$B$9$3$H$,$G$-$^$7$?!#e(B

OpenSSL
1.1.0-deve$B$O!"e(Bossl_x509attr.ce$B$Ne(Bossl_x509attr_get_value()e$B$G!"e(B

ossl_x509attr.c:220: warning: passing argument 1 of ‘i2d_ASN1_SET’ from
incompat
ible pointer type
ossl_x509attr.c:224: warning: passing argument 1 of ‘i2d_ASN1_SET’ from
incompat
ible pointer type

e$B$H!"$J$j$^$9!#3:Ev2U=j$O!“0J2<$Ne(Bi2d_ASN1_SET_OF_ASN1_TYPEe$B$,E83+$5$l$?e(B
e$B8e$Ne(Bi2d_ASN1_SET()e$B$NBhe(B1e$B0z?t$H$$$&$3$H$K$J$j$^$9$,!”$3$l$O$h$/$o$+$j$^e(B
e$B$;$s$G$7$?$,!"$J$s$+$^$:$=$&$Je(B…?

else{

length = i2d_ASN1_SET_OF_ASN1_TYPE(attr->value.set, NULL,
i2d_ASN1_TYPE, V_ASN1_SET, V_ASN1_UNIVERSAL, 0);
str = rb_str_new(0, length);
p = RSTRING_PTR(str);
i2d_ASN1_SET_OF_ASN1_TYPE(attr->value.set, &p,
i2d_ASN1_TYPE, V_ASN1_SET, V_ASN1_UNIVERSAL, 0);
ossl_str_adjust(str, p);
}

0.9.8e$B$h$j8E$$!"e(BOpenSSLe$B$Ne(B0.9.6e$B$de(B0.9.7e$B$G$N3NG’$O$G$-$F$$$^$;$s!#e(B

e$B0J2<!"%Q%C%A$NFbMF$N$^$H$a$G$9!#e(B

openssl_missing.h

ossl.h

ossl.c

  • OSSL_IMPL_SK2ARY()e$B%^%/%mCf$NJQ99!#e(B
    • OpenSSL
      1.0.0e$B0J9_$Ge(BSTACKe$B$Oe(B_STACKe$B$HL>A0$,JQ99$5$l$F$$e(B
      e$B$k$3$H$b$"$j!"D>@;HMQ$9$kBe$o$j$Ke(BSTACK_OF()e$B%^%/%m$re(B
      e$B;HMQ$9$k$h$&[email protected]!#e(B
    • sk_num()e$B$de(Bsk_value()e$B$r%-%c%9%H$7$F;HMQ$9$k$N$G$O$J$/!"e(B
      e$B<B:][email protected]@.$5$l$F$$$k4X?t$r;HMQ$9$k$h$&[email protected]!#e(B

ossl_asn1.c
ossl_cipher.c
ossl_engine.c
ossl_ns_spki.c
ossl_ocsp.c
ossl_x509attr.c
ossl_x509cert.c
ossl_x509ext.c
ossl_x509name.c

  • conste$BDI2C!#e(B

ossl_config.c

  • IMPLEMENT_LHASH_DOALL_ARG_FN()e$B$N%Q%i%a!<%?$KEO$5$l$?4X?tL>$Oe(B
    e$B$=$N$^$^;HMQ$5$l$:!“e(B”_doall_arg"e$B$rIU2C$7$?4X?t$r8F$S=P$9$h$&e(B
    e$B$KJQ99$5$l$?$3$H$X$NBP1~!#e(B(OpenSSL 1.0.0)e$B0J9_e(B

lh_doall_arg()e$B$rD>@;H$&$N$G$O$J$/!"e(BLHM_lh_doall_arg()e$B$r;HMQe(B
e$B$9$k$h$&$KJQ99!#e(B(OpenSSL 1.0.0)e$B0J9_e(B

  • conste$BDI2C!#e(B

ossl_pkcs7.c
*
certse$B$+e(Bcrlse$B$N$$$:$l$+$rJV$9$H$$$&e(Bpkcs7_get_certs_or_crls()e$B$O!"e(B
e$B<B9TA0$K$I$A$i$rJV$9$+$O7h$^$C$F$$$k$3$H$+$i!“JL!9$N4X?t$KJ,e(B
e$BN%$7$?>e$G!”$=$l$>$l$K1~$8$?7?$rJV$94X?t$KJQ99!#e(B
(e$B85$Ne(Bpkcs7_get_certs_or_crls()e$B$O!"L5M}LpM}%3!<%I$r6&MQ$7$h$&e(B
e$B$H$7$F$$$?$h$&$K8+$($^$9!#e(B)

ossl_ssl.c

e$B%-%c%9%H$H6&$Ke(Bsk_num()e$B$de(Bsk_value()e$B$r;HMQ$9$k$N$G$O$J$/!"$=$le(B
e$B$>$l$N7?$K1~$8$FMQ0U$5$l$F$$$k4X?t$r;HMQ!#e(B

ossl_x509crl.c
*
sk_X509_REVOKED_num()e$B$r;HMQ$9$Y$-$H$3$m$Ke(Bsk_X509_CRL_num()e$B$re(B
e$B;HMQ$7$F$$$ke(B(?)[email protected]!#e(B

e$B0J>e!"$*$=$i$/e(BRuby 1.9e$BEy$bF1MM$N1F6A$O$"$k$H;W$$$^$9!#e(B


e$B?@8Me(B e$BN4Gne(B / Takahiro K.

Index: ext/openssl/openssl_missing.h

— ext/openssl/openssl_missing.h.orig 2008-08-04 13:44:17.000000000
+0900
+++ ext/openssl/openssl_missing.h
@@ -18,6 +18,9 @@ extern “C” {
#ifndef TYPEDEF_D2I_OF
typedef char *d2i_of_void();
#endif
+#ifndef TYPEDEF_I2D_OF
+typedef int i2d_of_void();
+#endif

/*

  • These functions are not included in headers of OPENSSL <= 0.9.6b
    @@ -25,39 +28,39 @@ typedef char *d2i_of_void();

#if !defined(PEM_read_bio_DSAPublicKey)

define PEM_read_bio_DSAPublicKey(bp,x,cb,u) (DSA *)PEM_ASN1_read_bio(

\

  •    (char *(*)())d2i_DSAPublicKey,PEM_STRING_DSA_PUBLIC,bp,(char 
    

**)x,cb,u)

  •    (d2i_of_void 
    

*)d2i_DSAPublicKey,PEM_STRING_DSA_PUBLIC,bp,x,cb,u)
#endif

#if !defined(PEM_write_bio_DSAPublicKey)

define PEM_write_bio_DSAPublicKey(bp,x) \

  • PEM_ASN1_write_bio((int (*)())i2d_DSAPublicKey,\
  • PEM_ASN1_write_bio((i2d_of_void *)i2d_DSAPublicKey,
    PEM_STRING_DSA_PUBLIC,
    bp,(char *)x, NULL, NULL, 0, NULL, NULL)
    #endif

#if !defined(DSAPrivateKey_dup)
-# define DSAPrivateKey_dup(dsa) (DSA )ASN1_dup((int
(
)())i2d_DSAPrivateKey, \

  • (char ()())d2i_DSAPrivateKey,(char *)dsa)
    +# define DSAPrivateKey_dup(dsa) (DSA *)ASN1_dup((i2d_of_void
    *)i2d_DSAPrivateKey, \
  • (d2i_of_void *)d2i_DSAPrivateKey,(char *)dsa)
    #endif

#if !defined(DSAPublicKey_dup)
-# define DSAPublicKey_dup(dsa) (DSA )ASN1_dup((int
(
)())i2d_DSAPublicKey, \

  • (char ()())d2i_DSAPublicKey,(char *)dsa)
    +# define DSAPublicKey_dup(dsa) (DSA *)ASN1_dup((i2d_of_void
    *)i2d_DSAPublicKey, \
  • (d2i_of_void *)d2i_DSAPublicKey,(char *)dsa)
    #endif

#if !defined(X509_REVOKED_dup)
-# define X509_REVOKED_dup(rev) (X509_REVOKED )ASN1_dup((int
(
)())i2d_X509_REVOKED, \

  • (char ()())d2i_X509_REVOKED, (char *)rev)
    +# define X509_REVOKED_dup(rev) (X509_REVOKED *)ASN1_dup((i2d_of_void
    *)i2d_X509_REVOKED, \
  • (d2i_of_void *)d2i_X509_REVOKED, (char *)rev)
    #endif

#if !defined(PKCS7_SIGNER_INFO_dup)
-# define PKCS7_SIGNER_INFO_dup(si) (PKCS7_SIGNER_INFO )ASN1_dup((int
(
)())i2d_PKCS7_SIGNER_INFO, \

  • (char ()())d2i_PKCS7_SIGNER_INFO, (char *)si)
    +# define PKCS7_SIGNER_INFO_dup(si) (PKCS7_SIGNER_INFO
    *)ASN1_dup((i2d_of_void *)i2d_PKCS7_SIGNER_INFO, \
  • (d2i_of_void *)d2i_PKCS7_SIGNER_INFO, (char *)si)
    #endif

#if !defined(PKCS7_RECIP_INFO_dup)
-# define PKCS7_RECIP_INFO_dup(ri) (PKCS7_RECIP_INFO )ASN1_dup((int
(
)())i2d_PKCS7_RECIP_INFO, \

  • (char ()())d2i_PKCS7_RECIP_INFO, (char *)ri)
    +# define PKCS7_RECIP_INFO_dup(ri) (PKCS7_RECIP_INFO
    *)ASN1_dup((i2d_of_void *)i2d_PKCS7_RECIP_INFO, \
  • (d2i_of_void *)d2i_PKCS7_RECIP_INFO, (char *)ri)
    #endif

#if !defined(HAVE_EVP_MD_CTX_INIT)
Index: ext/openssl/ossl.h

— ext/openssl/ossl.h.orig 2008-06-29 17:16:02.000000000 +0900
+++ ext/openssl/ossl.h
@@ -74,6 +74,12 @@ extern “C” {

include <openssl/ocsp.h>

#endif

+#if OPENSSL_VERSION_NUMBER >= 0x00909000L
+#define OSSL_CONST const
+#else
+#define OSSL_CONST
+#endif
+
/*

  • Common Module
    */
    Index: ext/openssl/ossl.c

— ext/openssl/ossl.c.orig 2007-06-09 00:02:04.000000000 +0900
+++ ext/openssl/ossl.c
@@ -92,7 +92,7 @@ ossl_x509_ary2sk(VALUE ary)

#define OSSL_IMPL_SK2ARY(name, type)
VALUE
-ossl_##name##sk2ary(STACK *sk)
+ossl
##name##sk2ary(STACK_OF(type) *sk)
{
type *t;
int i, num;
@@ -102,7 +102,7 @@ ossl
##name##_sk2ary(STACK *sk)
OSSL_Debug(“empty sk!”);
return Qnil;
} \

  • num = sk_num(sk); \
  • num = sk_##type##num(sk);
    if (num < 0) {
    OSSL_Debug(“items in sk < -1???”);
    return rb_ary_new();
    @@ -110,7 +110,7 @@ ossl
    ##name##_sk2ary(STACK *sk)
    ary = rb_ary_new2(num);

    for (i=0; i<num; i++) { \
  • t = (type *)sk_value(sk, i); \
  • t = sk_##type##value(sk, i);
    rb_ary_push(ary, ossl
    ##name##_new(t));
    }
    return ary;
    Index: ext/openssl/ossl_asn1.c

— ext/openssl/ossl_asn1.c.orig 2007-06-09 00:02:04.000000000 +0900
+++ ext/openssl/ossl_asn1.c
@@ -304,10 +304,10 @@ obj_to_asn1derstr(VALUE obj)

  • DER to Ruby converters
    /
    static VALUE
    -decode_bool(unsigned char
    der, int length)
    +decode_bool(const unsigned char* der, int length)
    {
    int bool;
  • unsigned char *p;
  • const unsigned char *p;

    p = der;
    if((bool = d2i_ASN1_BOOLEAN(NULL, &p, length)) < 0)
    @@ -317,10 +317,10 @@ decode_bool(unsigned char* der, int leng
    }

static VALUE
-decode_int(unsigned char* der, int length)
+decode_int(const unsigned char* der, int length)
{
ASN1_INTEGER *ai;

  • unsigned char *p;
  • const unsigned char *p;
    VALUE ret;
    int status = 0;

@@ -336,10 +336,11 @@ decode_int(unsigned char* der, int lengt
}

static VALUE
-decode_bstr(unsigned char* der, int length, long unused_bits)
+decode_bstr(const unsigned char
der, int length, long *unused_bits)
{
ASN1_BIT_STRING *bstr;

  • unsigned char *p, *buf;
  • const unsigned char *p;
  • unsigned char *buf;
    long len;
    VALUE ret;

@@ -362,10 +363,10 @@ decode_bstr(unsigned char* der, int leng
}

static VALUE
-decode_enum(unsigned char* der, int length)
+decode_enum(const unsigned char* der, int length)
{
ASN1_ENUMERATED *ai;

  • unsigned char *p;
  • const unsigned char *p;
    VALUE ret;
    int status = 0;

@@ -381,10 +382,10 @@ decode_enum(unsigned char* der, int leng
}

static VALUE
-decode_null(unsigned char* der, int length)
+decode_null(const unsigned char* der, int length)
{
ASN1_NULL *null;

  • unsigned char *p;
  • const unsigned char *p;

    p = der;
    if(!(null = d2i_ASN1_NULL(NULL, &p, length)))
    @@ -395,10 +396,10 @@ decode_null(unsigned char* der, int leng
    }

static VALUE
-decode_obj(unsigned char* der, int length)
+decode_obj(const unsigned char* der, int length)
{
ASN1_OBJECT *obj;

  • unsigned char *p;
  • const unsigned char *p;
    VALUE ret;
    int nid;
    BIO bio;
    @@ -424,10 +425,10 @@ decode_obj(unsigned char
    der, int lengt
    }

static VALUE
-decode_time(unsigned char* der, int length)
+decode_time(const unsigned char* der, int length)
{
ASN1_TIME *time;

  • unsigned char *p;
  • const unsigned char *p;
    VALUE ret;
    int status = 0;

@@ -712,10 +713,10 @@ ossl_asn1data_to_der(VALUE self)
}

static VALUE
-ossl_asn1_decode0(unsigned char **pp, long length, long *offset, long
depth,

  •  int once, int yield)
    

+ossl_asn1_decode0(const unsigned char **pp, long length, long *offset,

  •  long depth, int once, int yield)
    

{

  • unsigned char *start, *p;
  • const unsigned char *p, *start;
    long len, off = *offset;
    int hlen, tag, tc, j;
    VALUE ary, asn1data, value, tag_class;
    @@ -818,7 +819,7 @@ ossl_asn1_decode0(unsigned char **pp, lo
    static VALUE
    ossl_asn1_traverse(VALUE self, VALUE obj)
    {
  • unsigned char *p;
  • const unsigned char *p;
    long offset = 0;
    volatile VALUE tmp;

@@ -834,7 +835,7 @@ static VALUE
ossl_asn1_decode(VALUE self, VALUE obj)
{
VALUE ret, ary;

  • unsigned char *p;
  • const unsigned char *p;
    long offset = 0;
    volatile VALUE tmp;

@@ -851,7 +852,7 @@ static VALUE
ossl_asn1_decode_all(VALUE self, VALUE obj)
{
VALUE ret;

  • unsigned char *p;
  • const unsigned char *p;
    long offset = 0;
    volatile VALUE tmp;

Index: ext/openssl/ossl_cipher.c

— ext/openssl/ossl_cipher.c.orig 2007-06-09 00:02:04.000000000 +0900
+++ ext/openssl/ossl_cipher.c
@@ -186,7 +186,7 @@ ossl_cipher_init(int argc, VALUE *argv,
* We deprecated the arguments for this method, but we decided
* keeping this behaviour for backward compatibility.
*/

  • char *cname = rb_class2name(rb_obj_class(self));
  • const char *cname = rb_class2name(rb_obj_class(self));
    rb_warn("argumtents for %s#encrypt and %s#decrypt were deprecated; "
    “use %s#pkcs5_keyivgen to derive key and IV”,
    cname, cname, cname);
    @@ -307,7 +307,7 @@ ossl_cipher_pkcs5_keyivgen(int argc, VAL
    static VALUE
    ossl_cipher_update_deprecated(VALUE self, VALUE data)
    {
  • char *cname;
  • const char *cname;

    cname = rb_class2name(rb_obj_class(self));
    rb_warning("%s#<< is deprecated; use %s#update instead", cname,
    cname);
    Index: ext/openssl/ossl_config.c

— ext/openssl/ossl_config.c.orig 2007-07-20 15:22:54.000000000 +0900
+++ ext/openssl/ossl_config.c
@@ -293,12 +293,27 @@ ossl_config_get_section_old(VALUE self,
}

#ifdef IMPLEMENT_LHASH_DOALL_ARG_FN
+
+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+static void
+get_conf_section_doall_arg(void *arg1, void *arg2)
+{

  • CONF_VALUE *cv;
  • VALUE ary;
  • cv = arg1;
  • ary = (VALUE)arg2;
  • if(cv->name) return;
  • rb_ary_push(ary, rb_str_new2(cv->section));
    +}
    +#else
    static void
    get_conf_section(CONF_VALUE *cv, VALUE ary)
    {
    if(cv->name) return;
    rb_ary_push(ary, rb_str_new2(cv->section));
    }
    +#endif

static IMPLEMENT_LHASH_DOALL_ARG_FN(get_conf_section, CONF_VALUE*,
VALUE);

@@ -310,11 +325,44 @@ ossl_config_get_sections(VALUE self)

 GetConfig(self, conf);
 ary = rb_ary_new();

+#if OPENSSL_VERSION_NUMBER >= 0x10000000L

  • LHM_lh_doall_arg(CONF_VALUE, conf->data,
  •     LHASH_DOALL_ARG_FN(get_conf_section), void, (void*)ary);
    

+#else
lh_doall_arg(conf->data, LHASH_DOALL_ARG_FN(get_conf_section),
(void*)ary);
+#endif

 return ary;

}

+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+static void
+dump_conf_value_doall_arg(void *arg1, void *arg2)
+{

  • STACK_OF(CONF_VALUE) *sk;
  • CONF_VALUE *cv, *v;
  • VALUE str;
  • int i, num;
  • cv = arg1;
  • if (cv->name) return;
  • str = (VALUE)arg2;
  • sk = (STACK_OF(CONF_VALUE)*)cv->value;
  • num = sk_CONF_VALUE_num(sk);
  • rb_str_cat2(str, "[ ");
  • rb_str_cat2(str, cv->section);
  • rb_str_cat2(str, " ]\n");
  • for(i = 0; i < num; i++){
  • v = sk_CONF_VALUE_value(sk, i);
  • rb_str_cat2(str, v->name ? v->name : “None”);
  • rb_str_cat2(str, “=”);
  • rb_str_cat2(str, v->value ? v->value : “None”);
  • rb_str_cat2(str, “\n”);
  • }
  • rb_str_cat2(str, “\n”);
    +}
    +#else
    static void
    dump_conf_value(CONF_VALUE *cv, VALUE str)
    {
    @@ -337,6 +385,7 @@ dump_conf_value(CONF_VALUE *cv, VALUE st
    }
    rb_str_cat2(str, “\n”);
    }
    +#endif

static IMPLEMENT_LHASH_DOALL_ARG_FN(dump_conf_value, CONF_VALUE*,
VALUE);

@@ -346,7 +395,12 @@ dump_conf(CONF *conf)
VALUE str;

 str = rb_str_new(0, 0);

+#if OPENSSL_VERSION_NUMBER >= 0x10000000L

  • LHM_lh_doall_arg(CONF_VALUE, conf->data,
  •     LHASH_DOALL_ARG_FN(dump_conf_value), void, (void*)str);
    

+#else
lh_doall_arg(conf->data, LHASH_DOALL_ARG_FN(dump_conf_value),
(void*)str);
+#endif

 return str;

}
@@ -361,8 +415,32 @@ ossl_config_to_s(VALUE self)
return dump_conf(conf);
}

+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+static void
+each_conf_value_doall_arg(void arg1, void dummy)
+{

  • STACK_OF(CONF_VALUE) *sk;
  • CONF_VALUE *cv, *v;
  • VALUE section, name, value, args;
  • int i, num;
  • cv = arg1;
  • if (cv->name) return;
  • sk = (STACK_OF(CONF_VALUE)*)cv->value;
  • num = sk_CONF_VALUE_num(sk);
  • section = rb_str_new2(cv->section);
  • for(i = 0; i < num; i++){
  • v = sk_CONF_VALUE_value(sk, i);
  • name = v->name ? rb_str_new2(v->name) : Qnil;
  • value = v->value ? rb_str_new2(v->value) : Qnil;
  •    args = rb_ary_new3(3, section, name, value);
    
  • rb_yield(args);
  • }
    +}
    +#else
    static void
    -each_conf_value(CONF_VALUE cv, void dummy)
    +each_conf_value
    +(CONF_VALUE cv, void dummy)
    {
    STACK_OF(CONF_VALUE) *sk;
    CONF_VALUE *v;
    @@ -381,6 +459,7 @@ each_conf_value(CONF_VALUE cv, void du
    rb_yield(args);
    }
    }
    +#endif

static IMPLEMENT_LHASH_DOALL_ARG_FN(each_conf_value, CONF_VALUE*,
void*);

@@ -390,7 +469,12 @@ ossl_config_each(VALUE self)
CONF *conf;

 GetConfig(self, conf);

+#if OPENSSL_VERSION_NUMBER >= 0x10000000L

  • LHM_lh_doall_arg(CONF_VALUE, conf->data,
  •     LHASH_DOALL_ARG_FN(each_conf_value), void, (void*)NULL);
    

+#else
lh_doall_arg(conf->data, LHASH_DOALL_ARG_FN(each_conf_value),
(void*)NULL);
+#endif

 return self;

}
@@ -421,7 +505,7 @@ static VALUE
ossl_config_inspect(VALUE self)
{
VALUE str, ary = ossl_config_get_sections(self);

  • char *cname = rb_class2name(rb_obj_class(self));
  • const char *cname = rb_class2name(rb_obj_class(self));

    str = rb_str_new2("#<");
    rb_str_cat2(str, cname);
    Index: ext/openssl/ossl_engine.c

— ext/openssl/ossl_engine.c.orig 2007-06-09 00:02:04.000000000 +0900
+++ ext/openssl/ossl_engine.c
@@ -326,7 +326,7 @@ static VALUE
ossl_engine_inspect(VALUE self)
{
VALUE str;

  • char *cname = rb_class2name(rb_obj_class(self));
  • const char *cname = rb_class2name(rb_obj_class(self));

    str = rb_str_new2("#<");
    rb_str_cat2(str, cname);
    Index: ext/openssl/ossl_ns_spki.c

— ext/openssl/ossl_ns_spki.c.orig 2007-06-09 00:02:04.000000000 +0900
+++ ext/openssl/ossl_ns_spki.c
@@ -56,7 +56,7 @@ ossl_spki_initialize(int argc, VALUE *ar
{
NETSCAPE_SPKI *spki;
VALUE buffer;

  • unsigned char *p;
  • const unsigned char *p;

    if (rb_scan_args(argc, argv, “01”, &buffer) == 0) {
    return self;
    Index: ext/openssl/ossl_ocsp.c

— ext/openssl/ossl_ocsp.c.orig 2009-03-09 20:59:27.000000000 +0900
+++ ext/openssl/ossl_ocsp.c
@@ -103,7 +103,7 @@ static VALUE
ossl_ocspreq_initialize(int argc, VALUE *argv, VALUE self)
{
VALUE arg;

  • unsigned char *p;
  • const unsigned char *p;

    rb_scan_args(argc, argv, “01”, &arg);
    if(!NIL_P(arg)){
    @@ -310,7 +310,7 @@ static VALUE
    ossl_ocspres_initialize(int argc, VALUE *argv, VALUE self)
    {
    VALUE arg;

  • unsigned char *p;
  • const unsigned char *p;

    rb_scan_args(argc, argv, “01”, &arg);
    if(!NIL_P(arg)){
    Index: ext/openssl/ossl_pkcs7.c

— ext/openssl/ossl_pkcs7.c.orig 2007-06-09 00:02:04.000000000 +0900
+++ ext/openssl/ossl_pkcs7.c
@@ -570,12 +570,11 @@ ossl_pkcs7_add_certificate(VALUE self, V
return self;
}

-static STACK *
-pkcs7_get_certs_or_crls(VALUE self, int want_certs)
+static STACK_OF(X509) *
+pkcs7_get_certs(VALUE self)
{
PKCS7 *pkcs7;
STACK_OF(X509) *certs;

  • STACK_OF(X509_CRL) *crls;
    int i;

    GetPKCS7(self, pkcs7);
    @@ -583,17 +582,38 @@ pkcs7_get_certs_or_crls(VALUE self, int
    switch(i){
    case NID_pkcs7_signed:
    certs = pkcs7->d.sign->cert;

  •    crls = pkcs7->d.sign->crl;
       break;
    

    case NID_pkcs7_signedAndEnveloped:
    certs = pkcs7->d.signed_and_enveloped->cert;

  •    break;
    
  • default:
  •    certs = NULL;
    
  • }
  • return certs;
    +}

+static STACK_OF(X509_CRL) *
+pkcs7_get_crls(VALUE self)
+{

  • PKCS7 *pkcs7;
  • STACK_OF(X509_CRL) *crls;
  • int i;
  • GetPKCS7(self, pkcs7);
  • i = OBJ_obj2nid(pkcs7->type);
  • switch(i){
  • case NID_pkcs7_signed:
  •    crls = pkcs7->d.sign->crl;
    
  •    break;
    
  • case NID_pkcs7_signedAndEnveloped:
    crls = pkcs7->d.signed_and_enveloped->crl;
    break;
    default:
  •    certs = crls = NULL;
    
  •    crls = NULL;
    
    }
  • return want_certs ? certs : crls;
  • return crls;
    }

static VALUE
@@ -608,7 +628,7 @@ ossl_pkcs7_set_certificates(VALUE self,
STACK_OF(X509) *certs;
X509 *cert;

  • certs = pkcs7_get_certs_or_crls(self, 1);
  • certs = pkcs7_get_certs(self);
    while((cert = sk_X509_pop(certs))) X509_free(cert);
    rb_block_call(ary, rb_intern(“each”), 0, 0, ossl_pkcs7_set_certs_i,
    self);

@@ -618,7 +638,7 @@ ossl_pkcs7_set_certificates(VALUE self,
static VALUE
ossl_pkcs7_get_certificates(VALUE self)
{

  • return ossl_x509_sk2ary(pkcs7_get_certs_or_crls(self, 1));
  • return ossl_x509_sk2ary(pkcs7_get_certs(self));
    }

static VALUE
@@ -648,7 +668,7 @@ ossl_pkcs7_set_crls(VALUE self, VALUE ar
STACK_OF(X509_CRL) *crls;
X509_CRL *crl;

  • crls = pkcs7_get_certs_or_crls(self, 0);
  • crls = pkcs7_get_crls(self);
    while((crl = sk_X509_CRL_pop(crls))) X509_CRL_free(crl);
    rb_block_call(ary, rb_intern(“each”), 0, 0, ossl_pkcs7_set_crls_i,
    self);

@@ -658,7 +678,7 @@ ossl_pkcs7_set_crls(VALUE self, VALUE ar
static VALUE
ossl_pkcs7_get_crls(VALUE self)
{

  • return ossl_x509crl_sk2ary(pkcs7_get_certs_or_crls(self, 0));
  • return ossl_x509crl_sk2ary(pkcs7_get_crls(self));
    }

static VALUE
Index: ext/openssl/ossl_ssl.c

— ext/openssl/ossl_ssl.c.orig 2008-06-06 17:05:24.000000000 +0900
+++ ext/openssl/ossl_ssl.c
@@ -95,7 +95,7 @@ ID ID_callback_state;
*/
struct {
const char *name;

  • SSL_METHOD *(*func)(void);
  • OSSL_CONST SSL_METHOD *(*func)(void);
    } ossl_ssl_method_tab[] = {
    #define OSSL_SSL_METHOD_ENTRY(name) { #name, name##_method }
    OSSL_SSL_METHOD_ENTRY(TLSv1),
    @@ -144,7 +144,7 @@ ossl_sslctx_s_alloc(VALUE klass)
    static VALUE
    ossl_sslctx_set_ssl_version(VALUE self, VALUE ssl_method)
    {
  • SSL_METHOD *method = NULL;
  • OSSL_CONST SSL_METHOD *method = NULL;
    const char *s;
    int i;

@@ -585,7 +585,7 @@ ossl_sslctx_setup(VALUE self)
}

static VALUE
-ossl_ssl_cipher_to_ary(SSL_CIPHER *cipher)
+ossl_ssl_cipher_to_ary(const SSL_CIPHER *cipher)
{
VALUE ary;
int bits, alg_bits;
@@ -623,10 +623,10 @@ ossl_sslctx_get_ciphers(VALUE self)
if (!ciphers)
return rb_ary_new();

  • num = sk_num((STACK*)ciphers);
  • num = sk_SSL_CIPHER_num(ciphers);
    ary = rb_ary_new2(num);
    for(i = 0; i < num; i++){
  •    cipher = (SSL_CIPHER*)sk_value((STACK*)ciphers, i);
    
  •    cipher = sk_SSL_CIPHER_value(ciphers, i);
       rb_ary_push(ary, ossl_ssl_cipher_to_ary(cipher));
    
    }
    return ary;
    @@ -1196,10 +1196,10 @@ ossl_ssl_get_peer_cert_chain(VALUE self)
    }
    chain = SSL_get_peer_cert_chain(ssl);
    if(!chain) return Qnil;
  • num = sk_num(chain);
  • num = sk_X509_num(chain);
    ary = rb_ary_new2(num);
    for (i = 0; i < num; i++){
  • cert = (X509*)sk_value(chain, i);
  • cert = sk_X509_value(chain, i);
    rb_ary_push(ary, ossl_x509_new(cert));
    }

@@ -1214,7 +1214,7 @@ static VALUE
ossl_ssl_get_cipher(VALUE self)
{
SSL *ssl;

  • SSL_CIPHER *cipher;
  • const SSL_CIPHER *cipher;

    Data_Get_Struct(self, SSL, ssl);
    if (!ssl) {
    Index: ext/openssl/ossl_x509attr.c

— ext/openssl/ossl_x509attr.c.orig 2007-06-09 00:02:04.000000000
+0900
+++ ext/openssl/ossl_x509attr.c
@@ -93,7 +93,7 @@ ossl_x509attr_initialize(int argc, VALUE
{
VALUE oid, value;
X509_ATTRIBUTE *attr;

  • unsigned char *p;
  • const unsigned char *p;

    GetX509Attr(self, attr);
    if(rb_scan_args(argc, argv, “11”, &oid, &value) == 1){
    Index: ext/openssl/ossl_x509cert.c

— ext/openssl/ossl_x509cert.c.orig 2007-06-09 00:02:04.000000000
+0900
+++ ext/openssl/ossl_x509cert.c
@@ -690,7 +690,7 @@ static VALUE
ossl_x509_inspect(VALUE self)
{
VALUE str;

  • char *cname = rb_class2name(rb_obj_class(self));
  • const char *cname = rb_class2name(rb_obj_class(self));

    str = rb_str_new2("#<");
    rb_str_cat2(str, cname);
    Index: ext/openssl/ossl_x509crl.c

— ext/openssl/ossl_x509crl.c.orig 2007-06-09 00:02:04.000000000 +0900
+++ ext/openssl/ossl_x509crl.c
@@ -262,7 +262,7 @@ ossl_x509crl_get_revoked(VALUE self)
VALUE ary, revoked;

 GetX509CRL(self, crl);
  • num = sk_X509_CRL_num(X509_CRL_get_REVOKED(crl));
  • num = sk_X509_REVOKED_num(X509_CRL_get_REVOKED(crl));
    if (num < 0) {
    OSSL_Debug(“num < 0???”);
    return rb_ary_new();
    @@ -270,7 +270,7 @@ ossl_x509crl_get_revoked(VALUE self)
    ary = rb_ary_new2(num);
    for(i=0; i<num; i++) {
    /* NO DUP - don’t free! */
  • rev = (X509_REVOKED *)sk_X509_CRL_value(X509_CRL_get_REVOKED(crl),
    i);
  • rev = sk_X509_REVOKED_value(X509_CRL_get_REVOKED(crl), i);
    revoked = ossl_x509revoked_new(rev);
    rb_ary_push(ary, revoked);
    }
    Index: ext/openssl/ossl_x509ext.c

— ext/openssl/ossl_x509ext.c.orig 2007-06-09 00:02:04.000000000 +0900
+++ ext/openssl/ossl_x509ext.c
@@ -273,7 +273,7 @@ static VALUE
ossl_x509ext_initialize(int argc, VALUE *argv, VALUE self)
{
VALUE oid, value, critical;

  • unsigned char *p;
  • const unsigned char *p;
    X509_EXTENSION *ext;

    GetX509Ext(self, ext);
    Index: ext/openssl/ossl_x509name.c

— ext/openssl/ossl_x509name.c.orig 2007-07-15 22:24:51.000000000
+0900
+++ ext/openssl/ossl_x509name.c
@@ -135,7 +135,7 @@ ossl_x509name_initialize(int argc, VALUE
rb_block_call(tmp, rb_intern(“each”), 0, 0, ossl_x509name_init_i,
args);
}
else{

  •  unsigned char *p;
    
  •  const unsigned char *p;
     VALUE str = ossl_to_der_if_possible(arg);
     StringValue(str);
     p = RSTRING_PTR(str);

e$B$3$s$P$s$O!#e(B

e$B<[email protected]$H%Q%C%A$NNL$r8:$i$9J}[email protected]}$r9T$$$^$7$?!#e(B

e$B$^$?!“e(BRuby 1.9.1 patchlevel 243 e$B$He(B Ruby 1.9.2
preview1e$BMQ$N%Q%C%A$b:[email protected](B
e$B$7$F$_$^$7$?!#$$$:$l$b!”%3%s%Q%$%k$KLdBj$,$J$$$H$3$m$^$G$N3NG’$O$7$F$$e(B
e$B$^$9!#e(B

e$B0J2<$Ne(BURLe$B$G%"%/%;%9$G$-$k$h$&$K$7$F$"$j$^$9!#e(B

ftp://ftp.back-street.net/pub/ruby/openssl-1/ruby-1.8.7p174-openssl1-patch.bz2
ftp://ftp.back-street.net/pub/ruby/openssl-1/ruby-1.9.1p243-openssl1-patch.bz2
ftp://ftp.back-street.net/pub/ruby/openssl-1/ruby-1.9.2pre1-openssl1-patch.bz2

In article [email protected],
Takahiro K. [email protected] writes:

e$B$^$?!“e(BRuby 1.9.1 patchlevel 243 e$B$He(B Ruby 1.9.2 preview1e$BMQ$N%Q%C%A$b:[email protected](B
e$B$7$F$_$^$7$?!#$$$:$l$b!”%3%s%Q%$%k$KLdBj$,$J$$$H$3$m$^$G$N3NG’$O$7$F$$e(B
e$B$^$9!#e(B

ftp://ftp.back-street.net/pub/ruby/openssl-1/ruby-1.9.2pre1-openssl1-patch.bz2

openssl-1.0.0-beta3 e$B$HAH$_9g$o$;$F;n$9$H!"%3%s%Q%$%k$G$-$k$he(B
e$B$&$K$J$k$N$ONI$$$N$G$9$,!"%F%9%H$Ge(B SEGV e$B$7$^$9$M$’!#e(B

% ./ruby test/runner.rb -v openssl
Loaded suite test/runner
Started
OpenSSL::TestASN1#test_decode: 0.03 s: .
OpenSSL::TestCipher#test_AES: 0.10 s: .
OpenSSL::TestCipher#test_ciphers: 0.00 s: .
OpenSSL::TestCipher#test_crypt: 0.02 s: .
OpenSSL::TestCipher#test_dup: 0.00 s: .
OpenSSL::TestCipher#test_empty_data: 0.00 s: .
OpenSSL::TestCipher#test_info: 0.00 s: .
OpenSSL::TestCipher#test_reset: 0.00 s: .
OpenSSL::TestDigest#test_098_features: 0.00 s: .
OpenSSL::TestDigest#test_digest: 0.00 s: .
OpenSSL::TestDigest#test_dup: 0.00 s: .
OpenSSL::TestDigest#test_eql: 0.00 s: .
OpenSSL::TestDigest#test_info: 0.00 s: .
OpenSSL::TestDigest#test_reset: 0.00 s: .
OpenSSL::TestEC#test_check_key: 0.03 s: .
OpenSSL::TestEC#test_curve_names: 0.01 s: .
OpenSSL::TestEC#test_dh_compute_key: 0.03 s: .
OpenSSL::TestEC#test_dsa_sign_verify: 0.03 s: .
OpenSSL::TestEC#test_encoding: 0.07 s: .
OpenSSL::TestEC#test_set_keys: 0.04 s: .
OpenSSL::TestEOF1#test_eof_0: 0.20 s: .
OpenSSL::TestEOF1#test_eof_0_rw: 0.00 s: .
OpenSSL::TestEOF1#test_eof_1: 0.39 s: .
OpenSSL::TestEOF1#test_eof_2: 0.05 s: .
OpenSSL::TestEOF1#test_eof_3: 0.05 s: .
OpenSSL::TestEOF2#test_eof_0: 0.20 s: .
OpenSSL::TestEOF2#test_eof_0_rw: 0.00 s: .
OpenSSL::TestEOF2#test_eof_1:
/home/ruby/openssl/lib/ruby/1.9.1/openssl/buffering.rb:37: [BUG]
Segmentation fault
ruby 1.9.2dev (2009-10-17 trunk 25381) [i686-linux]

– control frame ----------
c:0019 p:---- s:0073 b:0073 l:000072 d:000072 CFUNC :===
c:0018 p:0020 s:0069 b:0069 l:000065 d:000068 BLOCK
/home/ruby/openssl/lib/ruby/1.9.1/openssl/buffering.rb:37
c:0017 p:0026 s:0066 b:0066 l:000065 d:000065 METHOD
/home/ruby/openssl/lib/ruby/1.9.1/openssl/buffering.rb:35
c:0016 p:0094 s:0063 b:0063 l:000062 d:000062 METHOD
/home/ruby/openssl/lib/ruby/1.9.1/openssl/buffering.rb:68
c:0015 p:0016 s:0057 b:0055 l:00136c d:000054 BLOCK
/home/ruby/openssl/ruby/test/ruby/ut_eof.rb:66
c:0014 p:0041 s:0052 b:0052 l:000eb0 d:000eb0 METHOD
/home/ruby/openssl/ruby/test/openssl/test_pair.rb:80
c:0013 p:0061 s:0046 b:0046 l:00136c d:00136c METHOD
/home/ruby/openssl/ruby/test/ruby/ut_eof.rb:65
c:0012 p:0063 s:0043 b:0043 l:000042 d:000042 METHOD
/home/ruby/openssl/lib/ruby/1.9.1/minitest/unit.rb:458
c:0011 p:0091 s:0037 b:0037 l:000018 d:000036 BLOCK
/home/ruby/openssl/lib/ruby/1.9.1/minitest/unit.rb:426
c:0010 p:---- s:0032 b:0032 l:000031 d:000031 FINISH
c:0009 p:---- s:0030 b:0030 l:000029 d:000029 CFUNC :each
c:0008 p:0026 s:0027 b:0027 l:000018 d:000026 BLOCK
/home/ruby/openssl/lib/ruby/1.9.1/minitest/unit.rb:420
c:0007 p:---- s:0024 b:0024 l:000023 d:000023 FINISH
c:0006 p:---- s:0022 b:0022 l:000021 d:000021 CFUNC :each
c:0005 p:0082 s:0019 b:0019 l:000018 d:000018 METHOD
/home/ruby/openssl/lib/ruby/1.9.1/minitest/unit.rb:419
c:0004 p:0154 s:0014 b:0014 l:000013 d:000013 METHOD
/home/ruby/openssl/lib/ruby/1.9.1/minitest/unit.rb:393
c:0003 p:0041 s:0007 b:0007 l:0015dc d:000006 BLOCK
/home/ruby/openssl/lib/ruby/1.9.1/minitest/unit.rb:334
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:001034 d:001034 TOP

/home/ruby/openssl/lib/ruby/1.9.1/minitest/unit.rb:334:in block in autorun' /home/ruby/openssl/lib/ruby/1.9.1/minitest/unit.rb:393:inrun’
/home/ruby/openssl/lib/ruby/1.9.1/minitest/unit.rb:419:in
run_test_suites' /home/ruby/openssl/lib/ruby/1.9.1/minitest/unit.rb:419:ineach’
/home/ruby/openssl/lib/ruby/1.9.1/minitest/unit.rb:420:in block in run_test_suites' /home/ruby/openssl/lib/ruby/1.9.1/minitest/unit.rb:420:ineach’
/home/ruby/openssl/lib/ruby/1.9.1/minitest/unit.rb:426:in block (2 levels) in run_test_suites' /home/ruby/openssl/lib/ruby/1.9.1/minitest/unit.rb:458:inrun’
/home/ruby/openssl/ruby/test/ruby/ut_eof.rb:65:in test_eof_1' /home/ruby/openssl/ruby/test/openssl/test_pair.rb:80:inopen_file’
/home/ruby/openssl/ruby/test/ruby/ut_eof.rb:66:in block in test_eof_1' /home/ruby/openssl/lib/ruby/1.9.1/openssl/buffering.rb:68:inread’
/home/ruby/openssl/lib/ruby/1.9.1/openssl/buffering.rb:35:in
fill_rbuff' /home/ruby/openssl/lib/ruby/1.9.1/openssl/buffering.rb:37:inrescue in
fill_rbuff’
/home/ruby/openssl/lib/ruby/1.9.1/openssl/buffering.rb:37:in `===’

– C level backtrace information

./ruby(rb_vm_bugreport+0x6c) [0x8152552]
./ruby [0x8185599]
./ruby(rb_bug+0x36) [0x81855f4]
./ruby [0x80ec2fa]
[0xb7fd7410]
./ruby [0x80669f5]
./ruby [0x806534b]
./ruby [0x8066ba9]
./ruby [0x8066bbc]
./ruby(rb_gc_finalize_deferred+0x19) [0x8066be2]
./ruby [0x8154aae]
./ruby(rb_threadptr_execute_interrupts+0x19) [0x8154b91]
./ruby [0x814b0d6]
./ruby [0x814ba4c]
./ruby [0x814b709]
./ruby(rb_funcall+0xa2) [0x814bafa]
./ruby [0x814a724]
./ruby(rb_obj_respond_to+0x4f) [0x814a631]
./ruby(rb_respond_to+0x20) [0x814a760]
./ruby [0x8186c58]
./ruby [0x814807d]
./ruby [0x8147ef7]
./ruby [0x8147436]
./ruby [0x814310a]
./ruby [0x814fa96]
./ruby [0x814e7e2]
./ruby [0x814e870]
./ruby [0x814bcc6]
./ruby(rb_yield+0x3a) [0x814bc9c]
./ruby(rb_ary_each+0x7c) [0x81621ab]
./ruby [0x814805e]
./ruby [0x8147ef7]
./ruby [0x8147436]
./ruby [0x814310a]
./ruby [0x814fa96]
./ruby [0x814e7e2]
./ruby [0x814e870]
./ruby [0x814bcc6]
./ruby(rb_yield+0x3a) [0x814bc9c]
./ruby(rb_ary_each+0x7c) [0x81621ab]
./ruby [0x814805e]
./ruby [0x8147ef7]
./ruby [0x8147436]
./ruby [0x814310a]
./ruby [0x814fa96]
./ruby [0x814e7e2]
./ruby(rb_vm_invoke_proc+0xb0) [0x814e922]
./ruby(rb_proc_call+0x8e) [0x8060564]
./ruby(rb_call_end_proc+0x1a) [0x805dcf6]
./ruby(rb_exec_end_proc+0x174) [0x805df97]
./ruby [0x805e1f4]
./ruby(ruby_cleanup+0x92) [0x805e2c0]
./ruby(ruby_run_node+0x43) [0x805e620]
./ruby(main+0x74) [0x805d070]
/lib/i686/cmov/libc.so.6(__libc_start_main+0xe5) [0xb7df7455]
./ruby [0x805ceb1]

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension
libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

zsh: abort ./ruby test/runner.rb -v openssl
% ldd .ext/i686-linux/openssl.so
linux-gate.so.1 => (0xb7f65000)
libssl.so.1.0.0 => /home/ruby/openssl/lib/libssl.so.1.0.0
(0xb7ebc000)
libcrypto.so.1.0.0 => /home/ruby/openssl/lib/libcrypto.so.1.0.0
(0xb7d38000)
libpthread.so.0 => /lib/i686/cmov/libpthread.so.0 (0xb7d04000)
librt.so.1 => /lib/i686/cmov/librt.so.1 (0xb7cfb000)
libdl.so.2 => /lib/i686/cmov/libdl.so.2 (0xb7cf7000)
libcrypt.so.1 => /lib/i686/cmov/libcrypt.so.1 (0xb7cc5000)
libm.so.6 => /lib/i686/cmov/libm.so.6 (0xb7c9f000)
libc.so.6 => /lib/i686/cmov/libc.so.6 (0xb7b44000)
/lib/ld-linux.so.2 (0xb7f66000)
% ./ruby -v
ruby 1.9.2dev (2009-10-17 trunk 25381) [i686-linux]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs