ruby-openssl-1.0.patch
| ruby-1.8.6.369/ruby-1.8.6-p369/ext/openssl/ossl.c 2009-08-26 12:29:41.000000000 +0200 | ||
|---|---|---|
| 92 | 92 | |
| 93 | 93 |
#define OSSL_IMPL_SK2ARY(name, type) \ |
| 94 | 94 |
VALUE \ |
| 95 |
ossl_##name##_sk2ary(STACK *sk) \
|
|
| 95 |
ossl_##name##_sk2ary(STACK_OF(type) *sk) \
|
|
| 96 | 96 |
{ \
|
| 97 | 97 |
type *t; \ |
| 98 | 98 |
int i, num; \ |
| ... | ... | |
| 102 | 102 |
OSSL_Debug("empty sk!"); \
|
| 103 | 103 |
return Qnil; \ |
| 104 | 104 |
} \ |
| 105 |
num = sk_num(sk); \
|
|
| 105 |
num = sk_##type##_num(sk); \
|
|
| 106 | 106 |
if (num < 0) { \
|
| 107 | 107 |
OSSL_Debug("items in sk < -1???"); \
|
| 108 | 108 |
return rb_ary_new(); \ |
| ... | ... | |
| 110 | 110 |
ary = rb_ary_new2(num); \ |
| 111 | 111 |
\ |
| 112 | 112 |
for (i=0; i<num; i++) { \
|
| 113 |
t = (type *)sk_value(sk, i); \
|
|
| 113 |
t = sk_##type##_value(sk, i); \
|
|
| 114 | 114 |
rb_ary_push(ary, ossl_##name##_new(t)); \ |
| 115 | 115 |
} \ |
| 116 | 116 |
return ary; \ |
| ruby-1.8.6.369/ruby-1.8.6-p369/ext/openssl/ossl_pkcs7.c 2009-08-26 12:53:05.000000000 +0200 | ||
|---|---|---|
| 543 | 543 |
return self; |
| 544 | 544 |
} |
| 545 | 545 | |
| 546 |
static STACK * |
|
| 547 |
pkcs7_get_certs_or_crls(VALUE self, int want_certs)
|
|
| 546 |
static STACK_OF(X509) *
|
|
| 547 |
pkcs7_get_certs(VALUE self)
|
|
| 548 | 548 |
{
|
| 549 | 549 |
PKCS7 *pkcs7; |
| 550 | 550 |
STACK_OF(X509) *certs; |
| 551 |
STACK_OF(X509_CRL) *crls; |
|
| 552 | 551 |
int i; |
| 553 | 552 | |
| 554 | 553 |
GetPKCS7(self, pkcs7); |
| ... | ... | |
| 556 | 555 |
switch(i){
|
| 557 | 556 |
case NID_pkcs7_signed: |
| 558 | 557 |
certs = pkcs7->d.sign->cert; |
| 559 |
crls = pkcs7->d.sign->crl; |
|
| 560 | 558 |
break; |
| 561 | 559 |
case NID_pkcs7_signedAndEnveloped: |
| 562 | 560 |
certs = pkcs7->d.signed_and_enveloped->cert; |
| 561 |
break; |
|
| 562 |
default: |
|
| 563 |
certs = NULL; |
|
| 564 |
} |
|
| 565 | ||
| 566 |
return certs; |
|
| 567 |
} |
|
| 568 | ||
| 569 |
static STACK_OF(X509_CRL) * |
|
| 570 |
pkcs7_get_crls(VALUE self) |
|
| 571 |
{
|
|
| 572 |
PKCS7 *pkcs7; |
|
| 573 |
STACK_OF(X509_CRL) *crls; |
|
| 574 |
int i; |
|
| 575 | ||
| 576 |
GetPKCS7(self, pkcs7); |
|
| 577 |
i = OBJ_obj2nid(pkcs7->type); |
|
| 578 |
switch(i){
|
|
| 579 |
case NID_pkcs7_signed: |
|
| 580 |
crls = pkcs7->d.sign->crl; |
|
| 581 |
break; |
|
| 582 |
case NID_pkcs7_signedAndEnveloped: |
|
| 563 | 583 |
crls = pkcs7->d.signed_and_enveloped->crl; |
| 564 | 584 |
break; |
| 565 | 585 |
default: |
| 566 |
certs = crls = NULL;
|
|
| 586 |
crls = NULL; |
|
| 567 | 587 |
} |
| 568 | 588 | |
| 569 |
return want_certs ? certs : crls;
|
|
| 589 |
return crls; |
|
| 570 | 590 |
} |
| 571 | 591 | |
| 572 | 592 |
static VALUE |
| ... | ... | |
| 581 | 601 |
STACK_OF(X509) *certs; |
| 582 | 602 |
X509 *cert; |
| 583 | 603 | |
| 584 |
certs = pkcs7_get_certs_or_crls(self, 1);
|
|
| 604 |
certs = pkcs7_get_certs(self);
|
|
| 585 | 605 |
while((cert = sk_X509_pop(certs))) X509_free(cert); |
| 586 | 606 |
rb_iterate(rb_each, ary, ossl_pkcs7_set_certs_i, self); |
| 587 | 607 | |
| ... | ... | |
| 591 | 611 |
static VALUE |
| 592 | 612 |
ossl_pkcs7_get_certificates(VALUE self) |
| 593 | 613 |
{
|
| 594 |
return ossl_x509_sk2ary(pkcs7_get_certs_or_crls(self, 1));
|
|
| 614 |
return ossl_x509_sk2ary(pkcs7_get_certs(self));
|
|
| 595 | 615 |
} |
| 596 | 616 | |
| 597 | 617 |
static VALUE |
| ... | ... | |
| 621 | 641 |
STACK_OF(X509_CRL) *crls; |
| 622 | 642 |
X509_CRL *crl; |
| 623 | 643 | |
| 624 |
crls = pkcs7_get_certs_or_crls(self, 0);
|
|
| 644 |
crls = pkcs7_get_crls(self);
|
|
| 625 | 645 |
while((crl = sk_X509_CRL_pop(crls))) X509_CRL_free(crl); |
| 626 | 646 |
rb_iterate(rb_each, ary, ossl_pkcs7_set_crls_i, self); |
| 627 | 647 | |
| ... | ... | |
| 631 | 651 |
static VALUE |
| 632 | 652 |
ossl_pkcs7_get_crls(VALUE self) |
| 633 | 653 |
{
|
| 634 |
return ossl_x509crl_sk2ary(pkcs7_get_certs_or_crls(self, 0));
|
|
| 654 |
return ossl_x509crl_sk2ary(pkcs7_get_crls(self));
|
|
| 635 | 655 |
} |
| 636 | 656 | |
| 637 | 657 |
static VALUE |
| ruby-1.8.6.369/ruby-1.8.6-p369/ext/openssl/ossl_ssl.c 2009-08-26 12:08:48.000000000 +0200 | ||
|---|---|---|
| 89 | 89 |
static char *ossl_ssl_attr_readers[] = { "io", "context", };
|
| 90 | 90 |
static char *ossl_ssl_attrs[] = { "sync_close", };
|
| 91 | 91 | |
| 92 |
#if OPENSSL_VERSION_NUMBER >= 0x10000000L |
|
| 93 |
#define OSSL_MORE_CONST const |
|
| 94 |
#define STACK _STACK |
|
| 95 |
#else |
|
| 96 |
#define OSSL_MORE_CONST |
|
| 97 |
#endif |
|
| 92 | 98 |
/* |
| 93 | 99 |
* SSLContext class |
| 94 | 100 |
*/ |
| 95 | 101 |
struct {
|
| 96 | 102 |
const char *name; |
| 97 |
SSL_METHOD *(*func)(void); |
|
| 103 |
OSSL_MORE_CONST SSL_METHOD *(*func)(void);
|
|
| 98 | 104 |
} ossl_ssl_method_tab[] = {
|
| 99 | 105 |
#define OSSL_SSL_METHOD_ENTRY(name) { #name, name##_method }
|
| 100 | 106 |
OSSL_SSL_METHOD_ENTRY(TLSv1), |
| ... | ... | |
| 144 | 150 |
ossl_sslctx_initialize(int argc, VALUE *argv, VALUE self) |
| 145 | 151 |
{
|
| 146 | 152 |
VALUE ssl_method; |
| 147 |
SSL_METHOD *method = NULL; |
|
| 153 |
OSSL_MORE_CONST SSL_METHOD *method = NULL;
|
|
| 148 | 154 |
SSL_CTX *ctx; |
| 149 | 155 |
int i; |
| 150 | 156 |
char *s; |
| ... | ... | |
| 407 | 413 |
} |
| 408 | 414 | |
| 409 | 415 |
static VALUE |
| 410 |
ossl_ssl_cipher_to_ary(SSL_CIPHER *cipher) |
|
| 416 |
ossl_ssl_cipher_to_ary(OSSL_MORE_CONST SSL_CIPHER *cipher)
|
|
| 411 | 417 |
{
|
| 412 | 418 |
VALUE ary; |
| 413 | 419 |
int bits, alg_bits; |
| ... | ... | |
| 805 | 811 |
ossl_ssl_get_cipher(VALUE self) |
| 806 | 812 |
{
|
| 807 | 813 |
SSL *ssl; |
| 808 |
SSL_CIPHER *cipher; |
|
| 814 |
OSSL_MORE_CONST SSL_CIPHER *cipher;
|
|
| 809 | 815 | |
| 810 | 816 |
Data_Get_Struct(self, SSL, ssl); |
| 811 | 817 |
if (!ssl) {
|