rubysl-openssl 2.2.1 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -4
- data/MRI_LICENSE +56 -0
- data/ext/rubysl/openssl/openssl_missing.c +1 -1
- data/ext/rubysl/openssl/openssl_missing.h +1 -1
- data/ext/rubysl/openssl/ossl.c +17 -16
- data/ext/rubysl/openssl/ossl.h +7 -7
- data/ext/rubysl/openssl/ossl_asn1.c +5 -5
- data/ext/rubysl/openssl/ossl_asn1.h +1 -1
- data/ext/rubysl/openssl/ossl_bio.c +2 -2
- data/ext/rubysl/openssl/ossl_bio.h +1 -1
- data/ext/rubysl/openssl/ossl_bn.c +37 -13
- data/ext/rubysl/openssl/ossl_bn.h +1 -1
- data/ext/rubysl/openssl/ossl_cipher.c +64 -17
- data/ext/rubysl/openssl/ossl_cipher.h +1 -1
- data/ext/rubysl/openssl/ossl_config.c +3 -3
- data/ext/rubysl/openssl/ossl_config.h +1 -1
- data/ext/rubysl/openssl/ossl_digest.c +19 -7
- data/ext/rubysl/openssl/ossl_digest.h +1 -1
- data/ext/rubysl/openssl/ossl_engine.c +24 -17
- data/ext/rubysl/openssl/ossl_engine.h +1 -1
- data/ext/rubysl/openssl/ossl_hmac.c +15 -7
- data/ext/rubysl/openssl/ossl_hmac.h +1 -1
- data/ext/rubysl/openssl/ossl_ns_spki.c +19 -4
- data/ext/rubysl/openssl/ossl_ns_spki.h +1 -1
- data/ext/rubysl/openssl/ossl_ocsp.c +518 -60
- data/ext/rubysl/openssl/ossl_ocsp.h +1 -1
- data/ext/rubysl/openssl/ossl_pkcs12.c +18 -4
- data/ext/rubysl/openssl/ossl_pkcs12.h +1 -1
- data/ext/rubysl/openssl/ossl_pkcs5.c +1 -1
- data/ext/rubysl/openssl/ossl_pkcs7.c +59 -15
- data/ext/rubysl/openssl/ossl_pkcs7.h +1 -1
- data/ext/rubysl/openssl/ossl_pkey.c +16 -2
- data/ext/rubysl/openssl/ossl_pkey.h +4 -3
- data/ext/rubysl/openssl/ossl_pkey_dh.c +3 -3
- data/ext/rubysl/openssl/ossl_pkey_dsa.c +3 -3
- data/ext/rubysl/openssl/ossl_pkey_ec.c +32 -12
- data/ext/rubysl/openssl/ossl_pkey_rsa.c +3 -3
- data/ext/rubysl/openssl/ossl_rand.c +58 -34
- data/ext/rubysl/openssl/ossl_rand.h +1 -1
- data/ext/rubysl/openssl/ossl_ssl.c +75 -46
- data/ext/rubysl/openssl/ossl_ssl.h +8 -2
- data/ext/rubysl/openssl/ossl_ssl_session.c +16 -15
- data/ext/rubysl/openssl/ossl_version.h +1 -1
- data/ext/rubysl/openssl/ossl_x509.c +2 -2
- data/ext/rubysl/openssl/ossl_x509.h +1 -1
- data/ext/rubysl/openssl/ossl_x509attr.c +18 -4
- data/ext/rubysl/openssl/ossl_x509cert.c +27 -33
- data/ext/rubysl/openssl/ossl_x509crl.c +18 -4
- data/ext/rubysl/openssl/ossl_x509ext.c +29 -7
- data/ext/rubysl/openssl/ossl_x509name.c +22 -7
- data/ext/rubysl/openssl/ossl_x509req.c +18 -4
- data/ext/rubysl/openssl/ossl_x509revoked.c +18 -4
- data/ext/rubysl/openssl/ossl_x509store.c +33 -8
- data/ext/rubysl/openssl/ruby_missing.h +1 -1
- data/lib/openssl/bn.rb +8 -1
- data/lib/openssl/buffering.rb +1 -1
- data/lib/openssl/cipher.rb +1 -1
- data/lib/openssl/digest.rb +1 -1
- data/lib/openssl/ssl.rb +65 -7
- data/lib/openssl/x509.rb +22 -2
- data/lib/rubysl/openssl.rb +1 -1
- data/lib/rubysl/openssl/version.rb +1 -1
- metadata +4 -3
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* $Id$
|
2
|
+
* $Id: ossl_ssl.h 48801 2014-12-12 21:58:34Z nobu $
|
3
3
|
* 'OpenSSL for Ruby' project
|
4
4
|
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
|
5
5
|
* All rights reserved.
|
@@ -11,8 +11,12 @@
|
|
11
11
|
#if !defined(_OSSL_SSL_H_)
|
12
12
|
#define _OSSL_SSL_H_
|
13
13
|
|
14
|
+
#define GetSSL(obj, ssl) do { \
|
15
|
+
TypedData_Get_Struct((obj), SSL, &ossl_ssl_type, (ssl)); \
|
16
|
+
} while (0)
|
17
|
+
|
14
18
|
#define GetSSLSession(obj, sess) do { \
|
15
|
-
|
19
|
+
TypedData_Get_Struct((obj), SSL_SESSION, &ossl_ssl_session_type, (sess)); \
|
16
20
|
if (!(sess)) { \
|
17
21
|
ossl_raise(rb_eRuntimeError, "SSL Session wasn't initialized."); \
|
18
22
|
} \
|
@@ -23,6 +27,8 @@
|
|
23
27
|
GetSSLSession((obj), (sess)); \
|
24
28
|
} while (0)
|
25
29
|
|
30
|
+
extern const rb_data_type_t ossl_ssl_type;
|
31
|
+
extern const rb_data_type_t ossl_ssl_session_type;
|
26
32
|
extern VALUE mSSL;
|
27
33
|
extern VALUE eSSLError;
|
28
34
|
extern VALUE cSSLSocket;
|
@@ -4,25 +4,26 @@
|
|
4
4
|
|
5
5
|
#include "ossl.h"
|
6
6
|
|
7
|
-
#define GetSSLSession(obj, sess) do { \
|
8
|
-
Data_Get_Struct((obj), SSL_SESSION, (sess)); \
|
9
|
-
if (!(sess)) { \
|
10
|
-
ossl_raise(rb_eRuntimeError, "SSL Session wasn't initialized."); \
|
11
|
-
} \
|
12
|
-
} while (0)
|
13
|
-
|
14
|
-
#define SafeGetSSLSession(obj, sess) do { \
|
15
|
-
OSSL_Check_Kind((obj), cSSLSession); \
|
16
|
-
GetSSLSession((obj), (sess)); \
|
17
|
-
} while (0)
|
18
|
-
|
19
|
-
|
20
7
|
VALUE cSSLSession;
|
21
8
|
static VALUE eSSLSession;
|
22
9
|
|
10
|
+
static void
|
11
|
+
ossl_ssl_session_free(void *ptr)
|
12
|
+
{
|
13
|
+
SSL_SESSION_free(ptr);
|
14
|
+
}
|
15
|
+
|
16
|
+
const rb_data_type_t ossl_ssl_session_type = {
|
17
|
+
"OpenSSL/SSL/Session",
|
18
|
+
{
|
19
|
+
0, ossl_ssl_session_free,
|
20
|
+
},
|
21
|
+
0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
|
22
|
+
};
|
23
|
+
|
23
24
|
static VALUE ossl_ssl_session_alloc(VALUE klass)
|
24
25
|
{
|
25
|
-
return
|
26
|
+
return TypedData_Wrap_Struct(klass, &ossl_ssl_session_type, NULL);
|
26
27
|
}
|
27
28
|
|
28
29
|
/*
|
@@ -43,7 +44,7 @@ static VALUE ossl_ssl_session_initialize(VALUE self, VALUE arg1)
|
|
43
44
|
if (rb_obj_is_instance_of(arg1, cSSLSocket)) {
|
44
45
|
SSL *ssl;
|
45
46
|
|
46
|
-
|
47
|
+
GetSSL(arg1, ssl);
|
47
48
|
|
48
49
|
if (!ssl || (ctx = SSL_get1_session(ssl)) == NULL)
|
49
50
|
ossl_raise(eSSLSession, "no session available");
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* $Id$
|
2
|
+
* $Id: ossl_x509.c 47744 2014-09-30 05:25:32Z nobu $
|
3
3
|
* 'OpenSSL for Ruby' project
|
4
4
|
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
|
5
5
|
* All rights reserved.
|
@@ -17,7 +17,7 @@ VALUE mX509;
|
|
17
17
|
rb_define_const(mX509, "DEFAULT_" #x, rb_str_new2(X509_get_default_##i()))
|
18
18
|
|
19
19
|
void
|
20
|
-
Init_ossl_x509()
|
20
|
+
Init_ossl_x509(void)
|
21
21
|
{
|
22
22
|
mX509 = rb_define_module_under(mOSSL, "X509");
|
23
23
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* $Id$
|
2
|
+
* $Id: ossl_x509attr.c 48809 2014-12-12 23:38:44Z nobu $
|
3
3
|
* 'OpenSSL for Ruby' project
|
4
4
|
* Copyright (C) 2001 Michal Rokos <m.rokos@sh.cvut.cz>
|
5
5
|
* All rights reserved.
|
@@ -14,10 +14,10 @@
|
|
14
14
|
if (!(attr)) { \
|
15
15
|
ossl_raise(rb_eRuntimeError, "ATTR wasn't initialized!"); \
|
16
16
|
} \
|
17
|
-
(obj) =
|
17
|
+
(obj) = TypedData_Wrap_Struct((klass), &ossl_x509attr_type, (attr)); \
|
18
18
|
} while (0)
|
19
19
|
#define GetX509Attr(obj, attr) do { \
|
20
|
-
|
20
|
+
TypedData_Get_Struct((obj), X509_ATTRIBUTE, &ossl_x509attr_type, (attr)); \
|
21
21
|
if (!(attr)) { \
|
22
22
|
ossl_raise(rb_eRuntimeError, "ATTR wasn't initialized!"); \
|
23
23
|
} \
|
@@ -33,6 +33,20 @@
|
|
33
33
|
VALUE cX509Attr;
|
34
34
|
VALUE eX509AttrError;
|
35
35
|
|
36
|
+
static void
|
37
|
+
ossl_x509attr_free(void *ptr)
|
38
|
+
{
|
39
|
+
X509_ATTRIBUTE_free(ptr);
|
40
|
+
}
|
41
|
+
|
42
|
+
static const rb_data_type_t ossl_x509attr_type = {
|
43
|
+
"OpenSSL/X509/ATTRIBUTE",
|
44
|
+
{
|
45
|
+
0, ossl_x509attr_free,
|
46
|
+
},
|
47
|
+
0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
|
48
|
+
};
|
49
|
+
|
36
50
|
/*
|
37
51
|
* Public
|
38
52
|
*/
|
@@ -260,7 +274,7 @@ ossl_x509attr_to_der(VALUE self)
|
|
260
274
|
* X509_ATTRIBUTE init
|
261
275
|
*/
|
262
276
|
void
|
263
|
-
Init_ossl_x509attr()
|
277
|
+
Init_ossl_x509attr(void)
|
264
278
|
{
|
265
279
|
eX509AttrError = rb_define_class_under(mX509, "AttributeError", eOSSLError);
|
266
280
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* $Id$
|
2
|
+
* $Id: ossl_x509cert.c 48810 2014-12-12 23:38:55Z nobu $
|
3
3
|
* 'OpenSSL for Ruby' project
|
4
4
|
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
|
5
5
|
* All rights reserved.
|
@@ -14,10 +14,10 @@
|
|
14
14
|
if (!(x509)) { \
|
15
15
|
ossl_raise(rb_eRuntimeError, "CERT wasn't initialized!"); \
|
16
16
|
} \
|
17
|
-
(obj) =
|
17
|
+
(obj) = TypedData_Wrap_Struct((klass), &ossl_x509_type, (x509)); \
|
18
18
|
} while (0)
|
19
19
|
#define GetX509(obj, x509) do { \
|
20
|
-
|
20
|
+
TypedData_Get_Struct((obj), X509, &ossl_x509_type, (x509)); \
|
21
21
|
if (!(x509)) { \
|
22
22
|
ossl_raise(rb_eRuntimeError, "CERT wasn't initialized!"); \
|
23
23
|
} \
|
@@ -33,6 +33,20 @@
|
|
33
33
|
VALUE cX509Cert;
|
34
34
|
VALUE eX509CertError;
|
35
35
|
|
36
|
+
static void
|
37
|
+
ossl_x509_free(void *ptr)
|
38
|
+
{
|
39
|
+
X509_free(ptr);
|
40
|
+
}
|
41
|
+
|
42
|
+
static const rb_data_type_t ossl_x509_type = {
|
43
|
+
"OpenSSL/X509",
|
44
|
+
{
|
45
|
+
0, ossl_x509_free,
|
46
|
+
},
|
47
|
+
0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
|
48
|
+
};
|
49
|
+
|
36
50
|
/*
|
37
51
|
* Public
|
38
52
|
*/
|
@@ -693,42 +707,22 @@ ossl_x509_add_extension(VALUE self, VALUE extension)
|
|
693
707
|
static VALUE
|
694
708
|
ossl_x509_inspect(VALUE self)
|
695
709
|
{
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
rb_str_cat2(str, ", ");
|
706
|
-
|
707
|
-
rb_str_cat2(str, "issuer=");
|
708
|
-
rb_str_append(str, rb_inspect(ossl_x509_get_issuer(self)));
|
709
|
-
rb_str_cat2(str, ", ");
|
710
|
-
|
711
|
-
rb_str_cat2(str, "serial=");
|
712
|
-
rb_str_append(str, rb_inspect(ossl_x509_get_serial(self)));
|
713
|
-
rb_str_cat2(str, ", ");
|
714
|
-
|
715
|
-
rb_str_cat2(str, "not_before=");
|
716
|
-
rb_str_append(str, rb_inspect(ossl_x509_get_not_before(self)));
|
717
|
-
rb_str_cat2(str, ", ");
|
718
|
-
|
719
|
-
rb_str_cat2(str, "not_after=");
|
720
|
-
rb_str_append(str, rb_inspect(ossl_x509_get_not_after(self)));
|
721
|
-
|
722
|
-
str = rb_str_cat2(str, ">");
|
723
|
-
|
724
|
-
return str;
|
710
|
+
return rb_sprintf("#<%"PRIsVALUE": subject=%+"PRIsVALUE", "
|
711
|
+
"issuer=%+"PRIsVALUE", serial=%+"PRIsVALUE", "
|
712
|
+
"not_before=%+"PRIsVALUE", not_after=%+"PRIsVALUE">",
|
713
|
+
rb_obj_class(self),
|
714
|
+
ossl_x509_get_subject(self),
|
715
|
+
ossl_x509_get_issuer(self),
|
716
|
+
ossl_x509_get_serial(self),
|
717
|
+
ossl_x509_get_not_before(self),
|
718
|
+
ossl_x509_get_not_after(self));
|
725
719
|
}
|
726
720
|
|
727
721
|
/*
|
728
722
|
* INIT
|
729
723
|
*/
|
730
724
|
void
|
731
|
-
Init_ossl_x509cert()
|
725
|
+
Init_ossl_x509cert(void)
|
732
726
|
{
|
733
727
|
|
734
728
|
#if 0
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* $Id$
|
2
|
+
* $Id: ossl_x509crl.c 48811 2014-12-12 23:39:04Z nobu $
|
3
3
|
* 'OpenSSL for Ruby' project
|
4
4
|
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
|
5
5
|
* All rights reserved.
|
@@ -14,10 +14,10 @@
|
|
14
14
|
if (!(crl)) { \
|
15
15
|
ossl_raise(rb_eRuntimeError, "CRL wasn't initialized!"); \
|
16
16
|
} \
|
17
|
-
(obj) =
|
17
|
+
(obj) = TypedData_Wrap_Struct((klass), &ossl_x509crl_type, (crl)); \
|
18
18
|
} while (0)
|
19
19
|
#define GetX509CRL(obj, crl) do { \
|
20
|
-
|
20
|
+
TypedData_Get_Struct((obj), X509_CRL, &ossl_x509crl_type, (crl)); \
|
21
21
|
if (!(crl)) { \
|
22
22
|
ossl_raise(rb_eRuntimeError, "CRL wasn't initialized!"); \
|
23
23
|
} \
|
@@ -33,6 +33,20 @@
|
|
33
33
|
VALUE cX509CRL;
|
34
34
|
VALUE eX509CRLError;
|
35
35
|
|
36
|
+
static void
|
37
|
+
ossl_x509crl_free(void *ptr)
|
38
|
+
{
|
39
|
+
X509_CRL_free(ptr);
|
40
|
+
}
|
41
|
+
|
42
|
+
static const rb_data_type_t ossl_x509crl_type = {
|
43
|
+
"OpenSSL/X509/CRL",
|
44
|
+
{
|
45
|
+
0, ossl_x509crl_free,
|
46
|
+
},
|
47
|
+
0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
|
48
|
+
};
|
49
|
+
|
36
50
|
/*
|
37
51
|
* PUBLIC
|
38
52
|
*/
|
@@ -502,7 +516,7 @@ ossl_x509crl_add_extension(VALUE self, VALUE extension)
|
|
502
516
|
* INIT
|
503
517
|
*/
|
504
518
|
void
|
505
|
-
Init_ossl_x509crl()
|
519
|
+
Init_ossl_x509crl(void)
|
506
520
|
{
|
507
521
|
eX509CRLError = rb_define_class_under(mX509, "CRLError", eOSSLError);
|
508
522
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* $Id$
|
2
|
+
* $Id: ossl_x509ext.c 48813 2014-12-12 23:46:42Z nobu $
|
3
3
|
* 'OpenSSL for Ruby' project
|
4
4
|
* Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
|
5
5
|
* All rights reserved.
|
@@ -14,10 +14,10 @@
|
|
14
14
|
if (!(ext)) { \
|
15
15
|
ossl_raise(rb_eRuntimeError, "EXT wasn't initialized!"); \
|
16
16
|
} \
|
17
|
-
(obj) =
|
17
|
+
(obj) = TypedData_Wrap_Struct((klass), &ossl_x509ext_type, (ext)); \
|
18
18
|
} while (0)
|
19
19
|
#define GetX509Ext(obj, ext) do { \
|
20
|
-
|
20
|
+
TypedData_Get_Struct((obj), X509_EXTENSION, &ossl_x509ext_type, (ext)); \
|
21
21
|
if (!(ext)) { \
|
22
22
|
ossl_raise(rb_eRuntimeError, "EXT wasn't initialized!"); \
|
23
23
|
} \
|
@@ -30,10 +30,10 @@
|
|
30
30
|
if (!((ctx) = OPENSSL_malloc(sizeof(X509V3_CTX)))) \
|
31
31
|
ossl_raise(rb_eRuntimeError, "CTX wasn't allocated!"); \
|
32
32
|
X509V3_set_ctx((ctx), NULL, NULL, NULL, NULL, 0); \
|
33
|
-
(obj) =
|
33
|
+
(obj) = TypedData_Wrap_Struct((klass), &ossl_x509extfactory_type, (ctx)); \
|
34
34
|
} while (0)
|
35
35
|
#define GetX509ExtFactory(obj, ctx) do { \
|
36
|
-
|
36
|
+
TypedData_Get_Struct((obj), X509V3_CTX, &ossl_x509extfactory_type, (ctx)); \
|
37
37
|
if (!(ctx)) { \
|
38
38
|
ossl_raise(rb_eRuntimeError, "CTX wasn't initialized!"); \
|
39
39
|
} \
|
@@ -46,6 +46,20 @@ VALUE cX509Ext;
|
|
46
46
|
VALUE cX509ExtFactory;
|
47
47
|
VALUE eX509ExtError;
|
48
48
|
|
49
|
+
static void
|
50
|
+
ossl_x509ext_free(void *ptr)
|
51
|
+
{
|
52
|
+
X509_EXTENSION_free(ptr);
|
53
|
+
}
|
54
|
+
|
55
|
+
static const rb_data_type_t ossl_x509ext_type = {
|
56
|
+
"OpenSSL/X509/EXTENSION",
|
57
|
+
{
|
58
|
+
0, ossl_x509ext_free,
|
59
|
+
},
|
60
|
+
0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
|
61
|
+
};
|
62
|
+
|
49
63
|
/*
|
50
64
|
* Public
|
51
65
|
*/
|
@@ -98,11 +112,19 @@ DupX509ExtPtr(VALUE obj)
|
|
98
112
|
* Ext factory
|
99
113
|
*/
|
100
114
|
static void
|
101
|
-
ossl_x509extfactory_free(
|
115
|
+
ossl_x509extfactory_free(void *ctx)
|
102
116
|
{
|
103
117
|
OPENSSL_free(ctx);
|
104
118
|
}
|
105
119
|
|
120
|
+
static const rb_data_type_t ossl_x509extfactory_type = {
|
121
|
+
"OpenSSL/X509/EXTENSION/Factory",
|
122
|
+
{
|
123
|
+
0, ossl_x509extfactory_free,
|
124
|
+
},
|
125
|
+
0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
|
126
|
+
};
|
127
|
+
|
106
128
|
static VALUE
|
107
129
|
ossl_x509extfactory_alloc(VALUE klass)
|
108
130
|
{
|
@@ -436,7 +458,7 @@ ossl_x509ext_to_der(VALUE obj)
|
|
436
458
|
* INIT
|
437
459
|
*/
|
438
460
|
void
|
439
|
-
Init_ossl_x509ext()
|
461
|
+
Init_ossl_x509ext(void)
|
440
462
|
{
|
441
463
|
eX509ExtError = rb_define_class_under(mX509, "ExtensionError", eOSSLError);
|
442
464
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* $Id$
|
2
|
+
* $Id: ossl_x509name.c 48814 2014-12-12 23:59:19Z nobu $
|
3
3
|
* 'OpenSSL for Ruby' project
|
4
4
|
* Copyright (C) 2001 Michal Rokos <m.rokos@sh.cvut.cz>
|
5
5
|
* All rights reserved.
|
@@ -14,10 +14,10 @@
|
|
14
14
|
if (!(name)) { \
|
15
15
|
ossl_raise(rb_eRuntimeError, "Name wasn't initialized."); \
|
16
16
|
} \
|
17
|
-
(obj) =
|
17
|
+
(obj) = TypedData_Wrap_Struct((klass), &ossl_x509name_type, (name)); \
|
18
18
|
} while (0)
|
19
19
|
#define GetX509Name(obj, name) do { \
|
20
|
-
|
20
|
+
TypedData_Get_Struct((obj), X509_NAME, &ossl_x509name_type, (name)); \
|
21
21
|
if (!(name)) { \
|
22
22
|
ossl_raise(rb_eRuntimeError, "Name wasn't initialized."); \
|
23
23
|
} \
|
@@ -38,6 +38,20 @@
|
|
38
38
|
VALUE cX509Name;
|
39
39
|
VALUE eX509NameError;
|
40
40
|
|
41
|
+
static void
|
42
|
+
ossl_x509name_free(void *ptr)
|
43
|
+
{
|
44
|
+
X509_NAME_free(ptr);
|
45
|
+
}
|
46
|
+
|
47
|
+
static const rb_data_type_t ossl_x509name_type = {
|
48
|
+
"OpenSSL/X509/NAME",
|
49
|
+
{
|
50
|
+
0, ossl_x509name_free,
|
51
|
+
},
|
52
|
+
0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
|
53
|
+
};
|
54
|
+
|
41
55
|
/*
|
42
56
|
* Public
|
43
57
|
*/
|
@@ -183,13 +197,14 @@ VALUE ossl_x509name_add_entry(int argc, VALUE *argv, VALUE self)
|
|
183
197
|
{
|
184
198
|
X509_NAME *name;
|
185
199
|
VALUE oid, value, type;
|
200
|
+
const char *oid_name;
|
186
201
|
|
187
202
|
rb_scan_args(argc, argv, "21", &oid, &value, &type);
|
188
|
-
|
203
|
+
oid_name = StringValueCStr(oid);
|
189
204
|
StringValue(value);
|
190
205
|
if(NIL_P(type)) type = rb_aref(OBJECT_TYPE_TEMPLATE, oid);
|
191
206
|
GetX509Name(self, name);
|
192
|
-
if (!X509_NAME_add_entry_by_txt(name,
|
207
|
+
if (!X509_NAME_add_entry_by_txt(name, oid_name, NUM2INT(type),
|
193
208
|
(const unsigned char *)RSTRING_PTR(value), RSTRING_LENINT(value), -1, 0)) {
|
194
209
|
ossl_raise(eX509NameError, NULL);
|
195
210
|
}
|
@@ -425,7 +440,7 @@ ossl_x509name_to_der(VALUE self)
|
|
425
440
|
*/
|
426
441
|
|
427
442
|
void
|
428
|
-
Init_ossl_x509name()
|
443
|
+
Init_ossl_x509name(void)
|
429
444
|
{
|
430
445
|
VALUE utf8str, ptrstr, ia5str, hash;
|
431
446
|
|
@@ -459,7 +474,7 @@ Init_ossl_x509name()
|
|
459
474
|
*/
|
460
475
|
rb_define_const(cX509Name, "DEFAULT_OBJECT_TYPE", utf8str);
|
461
476
|
hash = rb_hash_new();
|
462
|
-
|
477
|
+
RHASH_SET_IFNONE(hash, utf8str);
|
463
478
|
rb_hash_aset(hash, rb_str_new2("C"), ptrstr);
|
464
479
|
rb_hash_aset(hash, rb_str_new2("countryName"), ptrstr);
|
465
480
|
rb_hash_aset(hash, rb_str_new2("serialNumber"), ptrstr);
|