rubysl-openssl 2.4.0 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/rubysl/openssl/deprecation.rb +1 -0
- data/ext/rubysl/openssl/extconf.rb +6 -8
- data/ext/rubysl/openssl/openssl_missing.c +1 -3
- data/ext/rubysl/openssl/openssl_missing.h +1 -3
- data/ext/rubysl/openssl/ossl.c +15 -3
- data/ext/rubysl/openssl/ossl.h +5 -4
- data/ext/rubysl/openssl/ossl_asn1.c +19 -13
- data/ext/rubysl/openssl/ossl_asn1.h +1 -2
- data/ext/rubysl/openssl/ossl_bio.c +1 -2
- data/ext/rubysl/openssl/ossl_bio.h +1 -3
- data/ext/rubysl/openssl/ossl_bn.c +227 -90
- data/ext/rubysl/openssl/ossl_bn.h +1 -3
- data/ext/rubysl/openssl/ossl_cipher.c +5 -11
- data/ext/rubysl/openssl/ossl_cipher.h +1 -3
- data/ext/rubysl/openssl/ossl_config.c +1 -2
- data/ext/rubysl/openssl/ossl_config.h +1 -3
- data/ext/rubysl/openssl/ossl_digest.c +6 -7
- data/ext/rubysl/openssl/ossl_digest.h +1 -3
- data/ext/rubysl/openssl/ossl_engine.c +11 -7
- data/ext/rubysl/openssl/ossl_engine.h +1 -2
- data/ext/rubysl/openssl/ossl_hmac.c +1 -2
- data/ext/rubysl/openssl/ossl_hmac.h +1 -2
- data/ext/rubysl/openssl/ossl_ns_spki.c +7 -6
- data/ext/rubysl/openssl/ossl_ns_spki.h +1 -3
- data/ext/rubysl/openssl/ossl_ocsp.c +39 -25
- data/ext/rubysl/openssl/ossl_ocsp.h +1 -2
- data/ext/rubysl/openssl/ossl_pkcs12.c +10 -6
- data/ext/rubysl/openssl/ossl_pkcs12.h +1 -3
- data/ext/rubysl/openssl/ossl_pkcs5.c +0 -1
- data/ext/rubysl/openssl/ossl_pkcs7.c +29 -16
- data/ext/rubysl/openssl/ossl_pkcs7.h +1 -3
- data/ext/rubysl/openssl/ossl_pkey.c +10 -8
- data/ext/rubysl/openssl/ossl_pkey.h +5 -6
- data/ext/rubysl/openssl/ossl_pkey_dh.c +5 -74
- data/ext/rubysl/openssl/ossl_pkey_dsa.c +7 -6
- data/ext/rubysl/openssl/ossl_pkey_ec.c +4 -2
- data/ext/rubysl/openssl/ossl_pkey_rsa.c +5 -5
- data/ext/rubysl/openssl/ossl_rand.c +13 -5
- data/ext/rubysl/openssl/ossl_rand.h +1 -3
- data/ext/rubysl/openssl/ossl_ssl.c +334 -265
- data/ext/rubysl/openssl/ossl_ssl.h +1 -5
- data/ext/rubysl/openssl/ossl_ssl_session.c +5 -1
- data/ext/rubysl/openssl/ossl_version.h +1 -2
- data/ext/rubysl/openssl/ossl_x509.c +1 -3
- data/ext/rubysl/openssl/ossl_x509.h +1 -2
- data/ext/rubysl/openssl/ossl_x509attr.c +9 -6
- data/ext/rubysl/openssl/ossl_x509cert.c +14 -12
- data/ext/rubysl/openssl/ossl_x509crl.c +15 -13
- data/ext/rubysl/openssl/ossl_x509ext.c +13 -8
- data/ext/rubysl/openssl/ossl_x509name.c +9 -6
- data/ext/rubysl/openssl/ossl_x509req.c +12 -10
- data/ext/rubysl/openssl/ossl_x509revoked.c +12 -10
- data/ext/rubysl/openssl/ossl_x509store.c +17 -10
- data/ext/rubysl/openssl/ruby_missing.h +1 -2
- data/lib/openssl/bn.rb +2 -8
- data/lib/openssl/buffering.rb +3 -7
- data/lib/openssl/cipher.rb +3 -9
- data/lib/openssl/config.rb +2 -1
- data/lib/openssl/digest.rb +3 -10
- data/lib/openssl/pkey.rb +37 -0
- data/lib/openssl/ssl.rb +128 -17
- data/lib/openssl/x509.rb +2 -8
- data/lib/rubysl/openssl.rb +4 -7
- data/lib/rubysl/openssl/version.rb +1 -1
- metadata +12 -11
@@ -1,11 +1,10 @@
|
|
1
1
|
/*
|
2
|
-
* $Id: ossl_ssl.h 48801 2014-12-12 21:58:34Z nobu $
|
3
2
|
* 'OpenSSL for Ruby' project
|
4
3
|
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
|
5
4
|
* All rights reserved.
|
6
5
|
*/
|
7
6
|
/*
|
8
|
-
* This program is
|
7
|
+
* This program is licensed under the same licence as Ruby.
|
9
8
|
* (See the file 'LICENCE'.)
|
10
9
|
*/
|
11
10
|
#if !defined(_OSSL_SSL_H_)
|
@@ -30,13 +29,10 @@
|
|
30
29
|
extern const rb_data_type_t ossl_ssl_type;
|
31
30
|
extern const rb_data_type_t ossl_ssl_session_type;
|
32
31
|
extern VALUE mSSL;
|
33
|
-
extern VALUE eSSLError;
|
34
32
|
extern VALUE cSSLSocket;
|
35
|
-
extern VALUE cSSLContext;
|
36
33
|
extern VALUE cSSLSession;
|
37
34
|
|
38
35
|
void Init_ossl_ssl(void);
|
39
36
|
void Init_ossl_ssl_session(void);
|
40
37
|
|
41
38
|
#endif /* _OSSL_SSL_H_ */
|
42
|
-
|
@@ -79,7 +79,11 @@ int SSL_SESSION_cmp(const SSL_SESSION *a,const SSL_SESSION *b)
|
|
79
79
|
if (a->ssl_version != b->ssl_version ||
|
80
80
|
a->session_id_length != b->session_id_length)
|
81
81
|
return 1;
|
82
|
-
|
82
|
+
#if defined(_WIN32)
|
83
|
+
return memcmp(a->session_id, b->session_id, a->session_id_length);
|
84
|
+
#else
|
85
|
+
return CRYPTO_memcmp(a->session_id, b->session_id, a->session_id_length);
|
86
|
+
#endif
|
83
87
|
}
|
84
88
|
#endif
|
85
89
|
|
@@ -1,11 +1,10 @@
|
|
1
1
|
/*
|
2
|
-
* $Id: ossl_version.h 25189 2009-10-02 12:04:37Z akr $
|
3
2
|
* 'OpenSSL for Ruby' project
|
4
3
|
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
|
5
4
|
* All rights reserved.
|
6
5
|
*/
|
7
6
|
/*
|
8
|
-
* This program is
|
7
|
+
* This program is licensed under the same licence as Ruby.
|
9
8
|
* (See the file 'LICENCE'.)
|
10
9
|
*/
|
11
10
|
#if !defined(_OSSL_VERSION_H_)
|
@@ -1,11 +1,10 @@
|
|
1
1
|
/*
|
2
|
-
* $Id: ossl_x509.c 47744 2014-09-30 05:25:32Z nobu $
|
3
2
|
* 'OpenSSL for Ruby' project
|
4
3
|
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
|
5
4
|
* All rights reserved.
|
6
5
|
*/
|
7
6
|
/*
|
8
|
-
* This program is
|
7
|
+
* This program is licensed under the same licence as Ruby.
|
9
8
|
* (See the file 'LICENCE'.)
|
10
9
|
*/
|
11
10
|
#include "ossl.h"
|
@@ -101,4 +100,3 @@ Init_ossl_x509(void)
|
|
101
100
|
DefX509Default(CERT_FILE_ENV, cert_file_env);
|
102
101
|
DefX509Default(PRIVATE_DIR, private_dir);
|
103
102
|
}
|
104
|
-
|
@@ -1,11 +1,10 @@
|
|
1
1
|
/*
|
2
|
-
* $Id: ossl_x509.h 25189 2009-10-02 12:04:37Z akr $
|
3
2
|
* 'OpenSSL for Ruby' project
|
4
3
|
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
|
5
4
|
* All rights reserved.
|
6
5
|
*/
|
7
6
|
/*
|
8
|
-
* This program is
|
7
|
+
* This program is licensed under the same licence as Ruby.
|
9
8
|
* (See the file 'LICENCE'.)
|
10
9
|
*/
|
11
10
|
#if !defined(_OSSL_X509_H_)
|
@@ -1,20 +1,21 @@
|
|
1
1
|
/*
|
2
|
-
* $Id: ossl_x509attr.c 48809 2014-12-12 23:38:44Z nobu $
|
3
2
|
* 'OpenSSL for Ruby' project
|
4
3
|
* Copyright (C) 2001 Michal Rokos <m.rokos@sh.cvut.cz>
|
5
4
|
* All rights reserved.
|
6
5
|
*/
|
7
6
|
/*
|
8
|
-
* This program is
|
7
|
+
* This program is licensed under the same licence as Ruby.
|
9
8
|
* (See the file 'LICENCE'.)
|
10
9
|
*/
|
11
10
|
#include "ossl.h"
|
12
11
|
|
13
|
-
#define
|
12
|
+
#define NewX509Attr(klass) \
|
13
|
+
TypedData_Wrap_Struct((klass), &ossl_x509attr_type, 0)
|
14
|
+
#define SetX509Attr(obj, attr) do { \
|
14
15
|
if (!(attr)) { \
|
15
16
|
ossl_raise(rb_eRuntimeError, "ATTR wasn't initialized!"); \
|
16
17
|
} \
|
17
|
-
(obj) =
|
18
|
+
RTYPEDDATA_DATA(obj) = (attr); \
|
18
19
|
} while (0)
|
19
20
|
#define GetX509Attr(obj, attr) do { \
|
20
21
|
TypedData_Get_Struct((obj), X509_ATTRIBUTE, &ossl_x509attr_type, (attr)); \
|
@@ -56,6 +57,7 @@ ossl_x509attr_new(X509_ATTRIBUTE *attr)
|
|
56
57
|
X509_ATTRIBUTE *new;
|
57
58
|
VALUE obj;
|
58
59
|
|
60
|
+
obj = NewX509Attr(cX509Attr);
|
59
61
|
if (!attr) {
|
60
62
|
new = X509_ATTRIBUTE_new();
|
61
63
|
} else {
|
@@ -64,7 +66,7 @@ ossl_x509attr_new(X509_ATTRIBUTE *attr)
|
|
64
66
|
if (!new) {
|
65
67
|
ossl_raise(eX509AttrError, NULL);
|
66
68
|
}
|
67
|
-
|
69
|
+
SetX509Attr(obj, new);
|
68
70
|
|
69
71
|
return obj;
|
70
72
|
}
|
@@ -91,9 +93,10 @@ ossl_x509attr_alloc(VALUE klass)
|
|
91
93
|
X509_ATTRIBUTE *attr;
|
92
94
|
VALUE obj;
|
93
95
|
|
96
|
+
obj = NewX509Attr(klass);
|
94
97
|
if (!(attr = X509_ATTRIBUTE_new()))
|
95
98
|
ossl_raise(eX509AttrError, NULL);
|
96
|
-
|
99
|
+
SetX509Attr(obj, attr);
|
97
100
|
|
98
101
|
return obj;
|
99
102
|
}
|
@@ -1,20 +1,21 @@
|
|
1
1
|
/*
|
2
|
-
* $Id: ossl_x509cert.c 48810 2014-12-12 23:38:55Z nobu $
|
3
2
|
* 'OpenSSL for Ruby' project
|
4
3
|
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
|
5
4
|
* All rights reserved.
|
6
5
|
*/
|
7
6
|
/*
|
8
|
-
* This program is
|
7
|
+
* This program is licensed under the same licence as Ruby.
|
9
8
|
* (See the file 'LICENCE'.)
|
10
9
|
*/
|
11
10
|
#include "ossl.h"
|
12
11
|
|
13
|
-
#define
|
12
|
+
#define NewX509(klass) \
|
13
|
+
TypedData_Wrap_Struct((klass), &ossl_x509_type, 0)
|
14
|
+
#define SetX509(obj, x509) do { \
|
14
15
|
if (!(x509)) { \
|
15
16
|
ossl_raise(rb_eRuntimeError, "CERT wasn't initialized!"); \
|
16
17
|
} \
|
17
|
-
(obj) =
|
18
|
+
RTYPEDDATA_DATA(obj) = (x509); \
|
18
19
|
} while (0)
|
19
20
|
#define GetX509(obj, x509) do { \
|
20
21
|
TypedData_Get_Struct((obj), X509, &ossl_x509_type, (x509)); \
|
@@ -56,6 +57,7 @@ ossl_x509_new(X509 *x509)
|
|
56
57
|
X509 *new;
|
57
58
|
VALUE obj;
|
58
59
|
|
60
|
+
obj = NewX509(cX509Cert);
|
59
61
|
if (!x509) {
|
60
62
|
new = X509_new();
|
61
63
|
} else {
|
@@ -64,7 +66,7 @@ ossl_x509_new(X509 *x509)
|
|
64
66
|
if (!new) {
|
65
67
|
ossl_raise(eX509CertError, NULL);
|
66
68
|
}
|
67
|
-
|
69
|
+
SetX509(obj, new);
|
68
70
|
|
69
71
|
return obj;
|
70
72
|
}
|
@@ -77,6 +79,7 @@ ossl_x509_new_from_file(VALUE filename)
|
|
77
79
|
VALUE obj;
|
78
80
|
|
79
81
|
SafeStringValue(filename);
|
82
|
+
obj = NewX509(cX509Cert);
|
80
83
|
if (!(fp = fopen(RSTRING_PTR(filename), "r"))) {
|
81
84
|
ossl_raise(eX509CertError, "%s", strerror(errno));
|
82
85
|
}
|
@@ -97,7 +100,7 @@ ossl_x509_new_from_file(VALUE filename)
|
|
97
100
|
if (!x509) {
|
98
101
|
ossl_raise(eX509CertError, NULL);
|
99
102
|
}
|
100
|
-
|
103
|
+
SetX509(obj, x509);
|
101
104
|
|
102
105
|
return obj;
|
103
106
|
}
|
@@ -133,10 +136,10 @@ ossl_x509_alloc(VALUE klass)
|
|
133
136
|
X509 *x509;
|
134
137
|
VALUE obj;
|
135
138
|
|
139
|
+
obj = NewX509(klass);
|
136
140
|
x509 = X509_new();
|
137
141
|
if (!x509) ossl_raise(eX509CertError, NULL);
|
138
|
-
|
139
|
-
WrapX509(klass, obj, x509);
|
142
|
+
SetX509(obj, x509);
|
140
143
|
|
141
144
|
return obj;
|
142
145
|
}
|
@@ -660,18 +663,18 @@ ossl_x509_set_extensions(VALUE self, VALUE ary)
|
|
660
663
|
{
|
661
664
|
X509 *x509;
|
662
665
|
X509_EXTENSION *ext;
|
663
|
-
|
666
|
+
long i;
|
664
667
|
|
665
668
|
Check_Type(ary, T_ARRAY);
|
666
669
|
/* All ary's members should be X509Extension */
|
667
670
|
for (i=0; i<RARRAY_LEN(ary); i++) {
|
668
|
-
OSSL_Check_Kind(
|
671
|
+
OSSL_Check_Kind(RARRAY_AREF(ary, i), cX509Ext);
|
669
672
|
}
|
670
673
|
GetX509(self, x509);
|
671
674
|
sk_X509_EXTENSION_pop_free(x509->cert_info->extensions, X509_EXTENSION_free);
|
672
675
|
x509->cert_info->extensions = NULL;
|
673
676
|
for (i=0; i<RARRAY_LEN(ary); i++) {
|
674
|
-
ext = DupX509ExtPtr(
|
677
|
+
ext = DupX509ExtPtr(RARRAY_AREF(ary, i));
|
675
678
|
|
676
679
|
if (!X509_add_ext(x509, ext, -1)) { /* DUPs ext - FREE it */
|
677
680
|
X509_EXTENSION_free(ext);
|
@@ -857,4 +860,3 @@ Init_ossl_x509cert(void)
|
|
857
860
|
rb_define_method(cX509Cert, "add_extension", ossl_x509_add_extension, 1);
|
858
861
|
rb_define_method(cX509Cert, "inspect", ossl_x509_inspect, 0);
|
859
862
|
}
|
860
|
-
|
@@ -1,20 +1,21 @@
|
|
1
1
|
/*
|
2
|
-
* $Id: ossl_x509crl.c 48811 2014-12-12 23:39:04Z nobu $
|
3
2
|
* 'OpenSSL for Ruby' project
|
4
3
|
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
|
5
4
|
* All rights reserved.
|
6
5
|
*/
|
7
6
|
/*
|
8
|
-
* This program is
|
7
|
+
* This program is licensed under the same licence as Ruby.
|
9
8
|
* (See the file 'LICENCE'.)
|
10
9
|
*/
|
11
10
|
#include "ossl.h"
|
12
11
|
|
13
|
-
#define
|
12
|
+
#define NewX509CRL(klass) \
|
13
|
+
TypedData_Wrap_Struct((klass), &ossl_x509crl_type, 0)
|
14
|
+
#define SetX509CRL(obj, crl) do { \
|
14
15
|
if (!(crl)) { \
|
15
16
|
ossl_raise(rb_eRuntimeError, "CRL wasn't initialized!"); \
|
16
17
|
} \
|
17
|
-
(obj) =
|
18
|
+
RTYPEDDATA_DATA(obj) = (crl); \
|
18
19
|
} while (0)
|
19
20
|
#define GetX509CRL(obj, crl) do { \
|
20
21
|
TypedData_Get_Struct((obj), X509_CRL, &ossl_x509crl_type, (crl)); \
|
@@ -77,9 +78,10 @@ ossl_x509crl_new(X509_CRL *crl)
|
|
77
78
|
X509_CRL *tmp;
|
78
79
|
VALUE obj;
|
79
80
|
|
81
|
+
obj = NewX509CRL(cX509CRL);
|
80
82
|
tmp = crl ? X509_CRL_dup(crl) : X509_CRL_new();
|
81
83
|
if(!tmp) ossl_raise(eX509CRLError, NULL);
|
82
|
-
|
84
|
+
SetX509CRL(obj, tmp);
|
83
85
|
|
84
86
|
return obj;
|
85
87
|
}
|
@@ -93,10 +95,11 @@ ossl_x509crl_alloc(VALUE klass)
|
|
93
95
|
X509_CRL *crl;
|
94
96
|
VALUE obj;
|
95
97
|
|
98
|
+
obj = NewX509CRL(klass);
|
96
99
|
if (!(crl = X509_CRL_new())) {
|
97
100
|
ossl_raise(eX509CRLError, NULL);
|
98
101
|
}
|
99
|
-
|
102
|
+
SetX509CRL(obj, crl);
|
100
103
|
|
101
104
|
return obj;
|
102
105
|
}
|
@@ -299,18 +302,18 @@ ossl_x509crl_set_revoked(VALUE self, VALUE ary)
|
|
299
302
|
{
|
300
303
|
X509_CRL *crl;
|
301
304
|
X509_REVOKED *rev;
|
302
|
-
|
305
|
+
long i;
|
303
306
|
|
304
307
|
Check_Type(ary, T_ARRAY);
|
305
308
|
/* All ary members should be X509 Revoked */
|
306
309
|
for (i=0; i<RARRAY_LEN(ary); i++) {
|
307
|
-
OSSL_Check_Kind(
|
310
|
+
OSSL_Check_Kind(RARRAY_AREF(ary, i), cX509Rev);
|
308
311
|
}
|
309
312
|
GetX509CRL(self, crl);
|
310
313
|
sk_X509_REVOKED_pop_free(crl->crl->revoked, X509_REVOKED_free);
|
311
314
|
crl->crl->revoked = NULL;
|
312
315
|
for (i=0; i<RARRAY_LEN(ary); i++) {
|
313
|
-
rev = DupX509RevokedPtr(
|
316
|
+
rev = DupX509RevokedPtr(RARRAY_AREF(ary, i));
|
314
317
|
if (!X509_CRL_add0_revoked(crl, rev)) { /* NO DUP - don't free! */
|
315
318
|
ossl_raise(eX509CRLError, NULL);
|
316
319
|
}
|
@@ -473,18 +476,18 @@ ossl_x509crl_set_extensions(VALUE self, VALUE ary)
|
|
473
476
|
{
|
474
477
|
X509_CRL *crl;
|
475
478
|
X509_EXTENSION *ext;
|
476
|
-
|
479
|
+
long i;
|
477
480
|
|
478
481
|
Check_Type(ary, T_ARRAY);
|
479
482
|
/* All ary members should be X509 Extensions */
|
480
483
|
for (i=0; i<RARRAY_LEN(ary); i++) {
|
481
|
-
OSSL_Check_Kind(
|
484
|
+
OSSL_Check_Kind(RARRAY_AREF(ary, i), cX509Ext);
|
482
485
|
}
|
483
486
|
GetX509CRL(self, crl);
|
484
487
|
sk_X509_EXTENSION_pop_free(crl->crl->extensions, X509_EXTENSION_free);
|
485
488
|
crl->crl->extensions = NULL;
|
486
489
|
for (i=0; i<RARRAY_LEN(ary); i++) {
|
487
|
-
ext = DupX509ExtPtr(
|
490
|
+
ext = DupX509ExtPtr(RARRAY_AREF(ary, i));
|
488
491
|
if(!X509_CRL_add_ext(crl, ext, -1)) { /* DUPs ext - FREE it */
|
489
492
|
X509_EXTENSION_free(ext);
|
490
493
|
ossl_raise(eX509CRLError, NULL);
|
@@ -548,4 +551,3 @@ Init_ossl_x509crl(void)
|
|
548
551
|
rb_define_method(cX509CRL, "extensions=", ossl_x509crl_set_extensions, 1);
|
549
552
|
rb_define_method(cX509CRL, "add_extension", ossl_x509crl_add_extension, 1);
|
550
553
|
}
|
551
|
-
|
@@ -1,20 +1,21 @@
|
|
1
1
|
/*
|
2
|
-
* $Id: ossl_x509ext.c 48813 2014-12-12 23:46:42Z nobu $
|
3
2
|
* 'OpenSSL for Ruby' project
|
4
3
|
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
|
5
4
|
* All rights reserved.
|
6
5
|
*/
|
7
6
|
/*
|
8
|
-
* This program is
|
7
|
+
* This program is licensed under the same licence as Ruby.
|
9
8
|
* (See the file 'LICENCE'.)
|
10
9
|
*/
|
11
10
|
#include "ossl.h"
|
12
11
|
|
13
|
-
#define
|
12
|
+
#define NewX509Ext(klass) \
|
13
|
+
TypedData_Wrap_Struct((klass), &ossl_x509ext_type, 0)
|
14
|
+
#define SetX509Ext(obj, ext) do { \
|
14
15
|
if (!(ext)) { \
|
15
16
|
ossl_raise(rb_eRuntimeError, "EXT wasn't initialized!"); \
|
16
17
|
} \
|
17
|
-
(obj) =
|
18
|
+
RTYPEDDATA_DATA(obj) = (ext); \
|
18
19
|
} while (0)
|
19
20
|
#define GetX509Ext(obj, ext) do { \
|
20
21
|
TypedData_Get_Struct((obj), X509_EXTENSION, &ossl_x509ext_type, (ext)); \
|
@@ -27,10 +28,11 @@
|
|
27
28
|
GetX509Ext((obj), (ext)); \
|
28
29
|
} while (0)
|
29
30
|
#define MakeX509ExtFactory(klass, obj, ctx) do { \
|
31
|
+
(obj) = TypedData_Wrap_Struct((klass), &ossl_x509extfactory_type, 0); \
|
30
32
|
if (!((ctx) = OPENSSL_malloc(sizeof(X509V3_CTX)))) \
|
31
33
|
ossl_raise(rb_eRuntimeError, "CTX wasn't allocated!"); \
|
32
34
|
X509V3_set_ctx((ctx), NULL, NULL, NULL, NULL, 0); \
|
33
|
-
(obj) =
|
35
|
+
RTYPEDDATA_DATA(obj) = (ctx); \
|
34
36
|
} while (0)
|
35
37
|
#define GetX509ExtFactory(obj, ctx) do { \
|
36
38
|
TypedData_Get_Struct((obj), X509V3_CTX, &ossl_x509extfactory_type, (ctx)); \
|
@@ -69,6 +71,7 @@ ossl_x509ext_new(X509_EXTENSION *ext)
|
|
69
71
|
X509_EXTENSION *new;
|
70
72
|
VALUE obj;
|
71
73
|
|
74
|
+
obj = NewX509Ext(cX509Ext);
|
72
75
|
if (!ext) {
|
73
76
|
new = X509_EXTENSION_new();
|
74
77
|
} else {
|
@@ -77,7 +80,7 @@ ossl_x509ext_new(X509_EXTENSION *ext)
|
|
77
80
|
if (!new) {
|
78
81
|
ossl_raise(eX509ExtError, NULL);
|
79
82
|
}
|
80
|
-
|
83
|
+
SetX509Ext(obj, new);
|
81
84
|
|
82
85
|
return obj;
|
83
86
|
}
|
@@ -258,6 +261,7 @@ ossl_x509extfactory_create_ext(int argc, VALUE *argv, VALUE self)
|
|
258
261
|
valstr = rb_str_new2(RTEST(critical) ? "critical," : "");
|
259
262
|
rb_str_append(valstr, value);
|
260
263
|
GetX509ExtFactory(self, ctx);
|
264
|
+
obj = NewX509Ext(cX509Ext);
|
261
265
|
#ifdef HAVE_X509V3_EXT_NCONF_NID
|
262
266
|
rconf = rb_iv_get(self, "@config");
|
263
267
|
conf = NIL_P(rconf) ? NULL : GetConfigPtr(rconf);
|
@@ -270,7 +274,7 @@ ossl_x509extfactory_create_ext(int argc, VALUE *argv, VALUE self)
|
|
270
274
|
ossl_raise(eX509ExtError, "%s = %s",
|
271
275
|
RSTRING_PTR(oid), RSTRING_PTR(value));
|
272
276
|
}
|
273
|
-
|
277
|
+
SetX509Ext(obj, ext);
|
274
278
|
|
275
279
|
return obj;
|
276
280
|
}
|
@@ -284,10 +288,11 @@ ossl_x509ext_alloc(VALUE klass)
|
|
284
288
|
X509_EXTENSION *ext;
|
285
289
|
VALUE obj;
|
286
290
|
|
291
|
+
obj = NewX509Ext(klass);
|
287
292
|
if(!(ext = X509_EXTENSION_new())){
|
288
293
|
ossl_raise(eX509ExtError, NULL);
|
289
294
|
}
|
290
|
-
|
295
|
+
SetX509Ext(obj, ext);
|
291
296
|
|
292
297
|
return obj;
|
293
298
|
}
|
@@ -1,20 +1,21 @@
|
|
1
1
|
/*
|
2
|
-
* $Id: ossl_x509name.c 48814 2014-12-12 23:59:19Z nobu $
|
3
2
|
* 'OpenSSL for Ruby' project
|
4
3
|
* Copyright (C) 2001 Michal Rokos <m.rokos@sh.cvut.cz>
|
5
4
|
* All rights reserved.
|
6
5
|
*/
|
7
6
|
/*
|
8
|
-
* This program is
|
7
|
+
* This program is licensed under the same licence as Ruby.
|
9
8
|
* (See the file 'LICENCE'.)
|
10
9
|
*/
|
11
10
|
#include "ossl.h"
|
12
11
|
|
13
|
-
#define
|
12
|
+
#define NewX509Name(klass) \
|
13
|
+
TypedData_Wrap_Struct((klass), &ossl_x509name_type, 0)
|
14
|
+
#define SetX509Name(obj, name) do { \
|
14
15
|
if (!(name)) { \
|
15
16
|
ossl_raise(rb_eRuntimeError, "Name wasn't initialized."); \
|
16
17
|
} \
|
17
|
-
(obj) =
|
18
|
+
RTYPEDDATA_DATA(obj) = (name); \
|
18
19
|
} while (0)
|
19
20
|
#define GetX509Name(obj, name) do { \
|
20
21
|
TypedData_Get_Struct((obj), X509_NAME, &ossl_x509name_type, (name)); \
|
@@ -61,6 +62,7 @@ ossl_x509name_new(X509_NAME *name)
|
|
61
62
|
X509_NAME *new;
|
62
63
|
VALUE obj;
|
63
64
|
|
65
|
+
obj = NewX509Name(cX509Name);
|
64
66
|
if (!name) {
|
65
67
|
new = X509_NAME_new();
|
66
68
|
} else {
|
@@ -69,7 +71,7 @@ ossl_x509name_new(X509_NAME *name)
|
|
69
71
|
if (!new) {
|
70
72
|
ossl_raise(eX509NameError, NULL);
|
71
73
|
}
|
72
|
-
|
74
|
+
SetX509Name(obj, new);
|
73
75
|
|
74
76
|
return obj;
|
75
77
|
}
|
@@ -93,10 +95,11 @@ ossl_x509name_alloc(VALUE klass)
|
|
93
95
|
X509_NAME *name;
|
94
96
|
VALUE obj;
|
95
97
|
|
98
|
+
obj = NewX509Name(klass);
|
96
99
|
if (!(name = X509_NAME_new())) {
|
97
100
|
ossl_raise(eX509NameError, NULL);
|
98
101
|
}
|
99
|
-
|
102
|
+
SetX509Name(obj, name);
|
100
103
|
|
101
104
|
return obj;
|
102
105
|
}
|