openssl 4.0.0 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.md +42 -0
- data/ext/openssl/extconf.rb +3 -0
- data/ext/openssl/openssl_missing.h +23 -0
- data/ext/openssl/ossl.c +17 -5
- data/ext/openssl/ossl_asn1.c +26 -21
- data/ext/openssl/ossl_bio.c +5 -1
- data/ext/openssl/ossl_cipher.c +6 -7
- data/ext/openssl/ossl_ocsp.c +4 -5
- data/ext/openssl/ossl_pkcs7.c +1 -1
- data/ext/openssl/ossl_pkey.h +0 -1
- data/ext/openssl/ossl_pkey_ec.c +1 -1
- data/ext/openssl/ossl_ssl.c +57 -31
- data/ext/openssl/ossl_ts.c +1 -1
- data/ext/openssl/ossl_x509.h +6 -6
- data/ext/openssl/ossl_x509attr.c +5 -4
- data/ext/openssl/ossl_x509cert.c +6 -6
- data/ext/openssl/ossl_x509crl.c +5 -5
- data/ext/openssl/ossl_x509ext.c +14 -5
- data/ext/openssl/ossl_x509name.c +3 -2
- data/ext/openssl/ossl_x509req.c +2 -2
- data/ext/openssl/ossl_x509revoked.c +4 -3
- data/ext/openssl/ossl_x509store.c +4 -6
- data/lib/openssl/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d14d5404847b546dc00b3603c37199ae79377a8459f8c7570fbc959aac6e0c0c
|
|
4
|
+
data.tar.gz: ed9ddd41814af2938ba6ba52d5d5cc44cc6fc7eec6e50d3a301f7ec3a10dc93f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fce02041d9b11cb6a5e0f6a6ef218d92da8d033c0c0f6a1be6f45bd9c7a541eab413b42181bb95fd3fb39d82a81a39bbd521e528dd33563c12073c6e3a748a63
|
|
7
|
+
data.tar.gz: 0ea3ff3553029192225eee748397cd4ba8b57ac18d86be3a4899e05501eb710c3752562186be6fdf87bec148f8ae0eea4724342d6940cacb3ee58273435eba50
|
data/History.md
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
Version 4.0.2
|
|
2
|
+
=============
|
|
3
|
+
|
|
4
|
+
Merged changes in 3.2.4 and 3.3.3.
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Version 4.0.1
|
|
8
|
+
=============
|
|
9
|
+
|
|
10
|
+
Notable changes
|
|
11
|
+
---------------
|
|
12
|
+
|
|
13
|
+
* Add `sync_close` keyword argument to `OpenSSL::SSL::SSLSocket.new` as a
|
|
14
|
+
short-hand for setting `sync_close` attribute on the created `SSLSocket`
|
|
15
|
+
instance.
|
|
16
|
+
[[GitHub #955]](https://github.com/ruby/openssl/issues/955)
|
|
17
|
+
[[GitHub #996]](https://github.com/ruby/openssl/pull/996)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
Bug fixes
|
|
21
|
+
---------
|
|
22
|
+
|
|
23
|
+
* Fix uninitialized variables in `OpenSSL::OCSP::BasicResponse#status`.
|
|
24
|
+
[[GitHub #1004]](https://github.com/ruby/openssl/pull/1004)
|
|
25
|
+
|
|
26
|
+
|
|
1
27
|
Version 4.0.0
|
|
2
28
|
=============
|
|
3
29
|
|
|
@@ -83,6 +109,12 @@ Notable changes
|
|
|
83
109
|
[[GitHub #983]](https://github.com/ruby/openssl/pull/983)
|
|
84
110
|
|
|
85
111
|
|
|
112
|
+
Version 3.3.3
|
|
113
|
+
=============
|
|
114
|
+
|
|
115
|
+
Merged changes in 3.2.4.
|
|
116
|
+
|
|
117
|
+
|
|
86
118
|
Version 3.3.2
|
|
87
119
|
=============
|
|
88
120
|
|
|
@@ -171,6 +203,16 @@ And various non-user-visible changes and bug fixes. Please see the commit
|
|
|
171
203
|
history for more details.
|
|
172
204
|
|
|
173
205
|
|
|
206
|
+
Version 3.2.4
|
|
207
|
+
=============
|
|
208
|
+
|
|
209
|
+
Notable changes
|
|
210
|
+
---------------
|
|
211
|
+
|
|
212
|
+
* Add support for OpenSSL 4.0.
|
|
213
|
+
[[GitHub #1051]](https://github.com/ruby/openssl/pull/1051)
|
|
214
|
+
|
|
215
|
+
|
|
174
216
|
Version 3.2.3
|
|
175
217
|
=============
|
|
176
218
|
|
data/ext/openssl/extconf.rb
CHANGED
|
@@ -169,6 +169,9 @@ have_func("TS_VERIFY_CTX_set0_certs(NULL, NULL)", ts_h)
|
|
|
169
169
|
# added in 3.5.0
|
|
170
170
|
have_func("SSL_get0_peer_signature_name(NULL, NULL)", ssl_h)
|
|
171
171
|
|
|
172
|
+
# added in 4.0.0
|
|
173
|
+
have_func("ASN1_BIT_STRING_set1(NULL, NULL, 0, 0)", "openssl/asn1.h")
|
|
174
|
+
|
|
172
175
|
Logging::message "=== Checking done. ===\n"
|
|
173
176
|
|
|
174
177
|
# Append flags from environment variables.
|
|
@@ -29,4 +29,27 @@
|
|
|
29
29
|
# define EVP_PKEY_eq(a, b) EVP_PKEY_cmp(a, b)
|
|
30
30
|
#endif
|
|
31
31
|
|
|
32
|
+
/* added in 4.0.0 */
|
|
33
|
+
#ifndef HAVE_ASN1_BIT_STRING_SET1
|
|
34
|
+
static inline int
|
|
35
|
+
ASN1_BIT_STRING_set1(ASN1_BIT_STRING *bitstr, const uint8_t *data,
|
|
36
|
+
size_t length, int unused_bits)
|
|
37
|
+
{
|
|
38
|
+
if (length > INT_MAX || !ASN1_STRING_set(bitstr, data, (int)length))
|
|
39
|
+
return 0;
|
|
40
|
+
bitstr->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07);
|
|
41
|
+
bitstr->flags |= ASN1_STRING_FLAG_BITS_LEFT | unused_bits;
|
|
42
|
+
return 1;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static inline int
|
|
46
|
+
ASN1_BIT_STRING_get_length(const ASN1_BIT_STRING *bitstr, size_t *length,
|
|
47
|
+
int *unused_bits)
|
|
48
|
+
{
|
|
49
|
+
*length = bitstr->length;
|
|
50
|
+
*unused_bits = bitstr->flags & 0x07;
|
|
51
|
+
return 1;
|
|
52
|
+
}
|
|
53
|
+
#endif
|
|
54
|
+
|
|
32
55
|
#endif /* _OSSL_OPENSSL_MISSING_H_ */
|
data/ext/openssl/ossl.c
CHANGED
|
@@ -34,7 +34,11 @@ ossl_##name##_ary2sk0(VALUE ary) \
|
|
|
34
34
|
" of class ##type##"); \
|
|
35
35
|
} \
|
|
36
36
|
x = dup(val); /* NEED TO DUP */ \
|
|
37
|
-
sk_##type##_push(sk, x)
|
|
37
|
+
if (!sk_##type##_push(sk, x)) { \
|
|
38
|
+
type##_free(x); \
|
|
39
|
+
sk_##type##_pop_free(sk, type##_free); \
|
|
40
|
+
ossl_raise(eOSSLError, NULL); \
|
|
41
|
+
} \
|
|
38
42
|
} \
|
|
39
43
|
return (VALUE)sk; \
|
|
40
44
|
} \
|
|
@@ -523,10 +527,18 @@ ossl_fips_mode_set(VALUE self, VALUE enabled)
|
|
|
523
527
|
static VALUE
|
|
524
528
|
ossl_crypto_fixed_length_secure_compare(VALUE dummy, VALUE str1, VALUE str2)
|
|
525
529
|
{
|
|
526
|
-
const unsigned char *p1
|
|
527
|
-
const unsigned char *p2
|
|
528
|
-
long len1
|
|
529
|
-
long len2
|
|
530
|
+
const unsigned char *p1;
|
|
531
|
+
const unsigned char *p2;
|
|
532
|
+
long len1;
|
|
533
|
+
long len2;
|
|
534
|
+
|
|
535
|
+
StringValue(str1);
|
|
536
|
+
StringValue(str2);
|
|
537
|
+
|
|
538
|
+
p1 = (const unsigned char *)RSTRING_PTR(str1);
|
|
539
|
+
p2 = (const unsigned char *)RSTRING_PTR(str2);
|
|
540
|
+
len1 = RSTRING_LEN(str1);
|
|
541
|
+
len2 = RSTRING_LEN(str2);
|
|
530
542
|
|
|
531
543
|
if (len1 != len2) {
|
|
532
544
|
ossl_raise(rb_eArgError, "inputs must be of equal length");
|
data/ext/openssl/ossl_asn1.c
CHANGED
|
@@ -130,15 +130,17 @@ asn1integer_to_num(const ASN1_INTEGER *ai)
|
|
|
130
130
|
if (!ai) {
|
|
131
131
|
ossl_raise(rb_eTypeError, "ASN1_INTEGER is NULL!");
|
|
132
132
|
}
|
|
133
|
+
|
|
134
|
+
num = ossl_bn_new(BN_value_one());
|
|
135
|
+
bn = GetBNPtr(num);
|
|
136
|
+
|
|
133
137
|
if (ASN1_STRING_type(ai) == V_ASN1_ENUMERATED)
|
|
134
|
-
bn = ASN1_ENUMERATED_to_BN(ai,
|
|
138
|
+
bn = ASN1_ENUMERATED_to_BN(ai, bn);
|
|
135
139
|
else
|
|
136
|
-
bn = ASN1_INTEGER_to_BN(ai,
|
|
140
|
+
bn = ASN1_INTEGER_to_BN(ai, bn);
|
|
137
141
|
|
|
138
142
|
if (!bn)
|
|
139
143
|
ossl_raise(eOSSLError, NULL);
|
|
140
|
-
num = ossl_bn_new(bn);
|
|
141
|
-
BN_free(bn);
|
|
142
144
|
|
|
143
145
|
return num;
|
|
144
146
|
}
|
|
@@ -226,7 +228,7 @@ obj_to_asn1int(VALUE obj)
|
|
|
226
228
|
}
|
|
227
229
|
|
|
228
230
|
static ASN1_BIT_STRING*
|
|
229
|
-
obj_to_asn1bstr(VALUE obj,
|
|
231
|
+
obj_to_asn1bstr(VALUE obj, int unused_bits)
|
|
230
232
|
{
|
|
231
233
|
ASN1_BIT_STRING *bstr;
|
|
232
234
|
|
|
@@ -234,11 +236,11 @@ obj_to_asn1bstr(VALUE obj, long unused_bits)
|
|
|
234
236
|
ossl_raise(eASN1Error, "unused_bits for a bitstring value must be in "\
|
|
235
237
|
"the range 0 to 7");
|
|
236
238
|
StringValue(obj);
|
|
237
|
-
if(!(bstr = ASN1_BIT_STRING_new()))
|
|
238
|
-
ossl_raise(eASN1Error,
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
239
|
+
if (!(bstr = ASN1_BIT_STRING_new()))
|
|
240
|
+
ossl_raise(eASN1Error, "ASN1_BIT_STRING_new");
|
|
241
|
+
if (!ASN1_BIT_STRING_set1(bstr, (uint8_t *)RSTRING_PTR(obj),
|
|
242
|
+
RSTRING_LEN(obj), unused_bits))
|
|
243
|
+
ossl_raise(eASN1Error, "ASN1_BIT_STRING_set1");
|
|
242
244
|
|
|
243
245
|
return bstr;
|
|
244
246
|
}
|
|
@@ -362,22 +364,25 @@ decode_int(unsigned char* der, long length)
|
|
|
362
364
|
}
|
|
363
365
|
|
|
364
366
|
static VALUE
|
|
365
|
-
decode_bstr(unsigned char* der, long length,
|
|
367
|
+
decode_bstr(unsigned char* der, long length, int *unused_bits)
|
|
366
368
|
{
|
|
367
369
|
ASN1_BIT_STRING *bstr;
|
|
368
370
|
const unsigned char *p;
|
|
369
|
-
|
|
371
|
+
size_t len;
|
|
370
372
|
VALUE ret;
|
|
373
|
+
int state;
|
|
371
374
|
|
|
372
375
|
p = der;
|
|
373
|
-
if(!(bstr = d2i_ASN1_BIT_STRING(NULL, &p, length)))
|
|
374
|
-
ossl_raise(eASN1Error,
|
|
375
|
-
len
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
ret =
|
|
376
|
+
if (!(bstr = d2i_ASN1_BIT_STRING(NULL, &p, length)))
|
|
377
|
+
ossl_raise(eASN1Error, "d2i_ASN1_BIT_STRING");
|
|
378
|
+
if (!ASN1_BIT_STRING_get_length(bstr, &len, unused_bits)) {
|
|
379
|
+
ASN1_BIT_STRING_free(bstr);
|
|
380
|
+
ossl_raise(eASN1Error, "ASN1_BIT_STRING_get_length");
|
|
381
|
+
}
|
|
382
|
+
ret = ossl_str_new((const char *)ASN1_STRING_get0_data(bstr), len, &state);
|
|
380
383
|
ASN1_BIT_STRING_free(bstr);
|
|
384
|
+
if (state)
|
|
385
|
+
rb_jump_tag(state);
|
|
381
386
|
|
|
382
387
|
return ret;
|
|
383
388
|
}
|
|
@@ -761,7 +766,7 @@ int_ossl_asn1_decode0_prim(unsigned char **pp, long length, long hlen, int tag,
|
|
|
761
766
|
{
|
|
762
767
|
VALUE value, asn1data;
|
|
763
768
|
unsigned char *p;
|
|
764
|
-
|
|
769
|
+
int flag = 0;
|
|
765
770
|
|
|
766
771
|
p = *pp;
|
|
767
772
|
|
|
@@ -818,7 +823,7 @@ int_ossl_asn1_decode0_prim(unsigned char **pp, long length, long hlen, int tag,
|
|
|
818
823
|
asn1data = rb_obj_alloc(klass);
|
|
819
824
|
ossl_asn1_initialize(4, args, asn1data);
|
|
820
825
|
if(tag == V_ASN1_BIT_STRING){
|
|
821
|
-
rb_ivar_set(asn1data, sivUNUSED_BITS,
|
|
826
|
+
rb_ivar_set(asn1data, sivUNUSED_BITS, INT2NUM(flag));
|
|
822
827
|
}
|
|
823
828
|
}
|
|
824
829
|
else {
|
data/ext/openssl/ossl_bio.c
CHANGED
|
@@ -32,7 +32,11 @@ ossl_membio2str(BIO *bio)
|
|
|
32
32
|
int state;
|
|
33
33
|
BUF_MEM *buf;
|
|
34
34
|
|
|
35
|
-
BIO_get_mem_ptr(bio, &buf)
|
|
35
|
+
if (BIO_get_mem_ptr(bio, &buf) <= 0) {
|
|
36
|
+
BIO_free(bio);
|
|
37
|
+
ossl_raise(eOSSLError, "BIO_get_mem_ptr");
|
|
38
|
+
}
|
|
39
|
+
|
|
36
40
|
ret = ossl_str_new(buf->data, buf->length, &state);
|
|
37
41
|
BIO_free(bio);
|
|
38
42
|
if (state)
|
data/ext/openssl/ossl_cipher.c
CHANGED
|
@@ -401,9 +401,9 @@ ossl_cipher_update(int argc, VALUE *argv, VALUE self)
|
|
|
401
401
|
}
|
|
402
402
|
out_len = in_len + EVP_MAX_BLOCK_LENGTH;
|
|
403
403
|
|
|
404
|
-
if (NIL_P(str))
|
|
405
|
-
str =
|
|
406
|
-
|
|
404
|
+
if (NIL_P(str))
|
|
405
|
+
str = rb_str_buf_new(out_len);
|
|
406
|
+
else {
|
|
407
407
|
StringValue(str);
|
|
408
408
|
if ((long)rb_str_capacity(str) >= out_len)
|
|
409
409
|
rb_str_modify(str);
|
|
@@ -411,9 +411,9 @@ ossl_cipher_update(int argc, VALUE *argv, VALUE self)
|
|
|
411
411
|
rb_str_modify_expand(str, out_len - RSTRING_LEN(str));
|
|
412
412
|
}
|
|
413
413
|
|
|
414
|
-
if (!ossl_cipher_update_long(ctx, (unsigned char *)RSTRING_PTR(str),
|
|
415
|
-
|
|
416
|
-
|
|
414
|
+
if (!ossl_cipher_update_long(ctx, (unsigned char *)RSTRING_PTR(str),
|
|
415
|
+
&out_len, in, in_len))
|
|
416
|
+
ossl_raise(eCipherError, "EVP_CipherUpdate");
|
|
417
417
|
rb_str_set_len(str, out_len);
|
|
418
418
|
|
|
419
419
|
return str;
|
|
@@ -456,7 +456,6 @@ ossl_cipher_final(VALUE self)
|
|
|
456
456
|
ossl_raise(eCipherError, "cipher final failed");
|
|
457
457
|
}
|
|
458
458
|
}
|
|
459
|
-
assert(out_len <= RSTRING_LEN(str));
|
|
460
459
|
rb_str_set_len(str, out_len);
|
|
461
460
|
|
|
462
461
|
return str;
|
data/ext/openssl/ossl_ocsp.c
CHANGED
|
@@ -905,8 +905,8 @@ ossl_ocspbres_get_status(VALUE self)
|
|
|
905
905
|
int count = OCSP_resp_count(bs);
|
|
906
906
|
for (int i = 0; i < count; i++) {
|
|
907
907
|
OCSP_SINGLERESP *single = OCSP_resp_get0(bs, i);
|
|
908
|
-
ASN1_TIME *revtime, *thisupd, *nextupd;
|
|
909
|
-
int reason;
|
|
908
|
+
ASN1_TIME *revtime = NULL, *thisupd = NULL, *nextupd = NULL;
|
|
909
|
+
int reason = -1;
|
|
910
910
|
|
|
911
911
|
int status = OCSP_single_get0_status(single, &reason, &revtime, &thisupd, &nextupd);
|
|
912
912
|
if (status < 0)
|
|
@@ -922,7 +922,7 @@ ossl_ocspbres_get_status(VALUE self)
|
|
|
922
922
|
VALUE ext = rb_ary_new();
|
|
923
923
|
int ext_count = OCSP_SINGLERESP_get_ext_count(single);
|
|
924
924
|
for (int j = 0; j < ext_count; j++) {
|
|
925
|
-
X509_EXTENSION *x509ext = OCSP_SINGLERESP_get_ext(single, j);
|
|
925
|
+
const X509_EXTENSION *x509ext = OCSP_SINGLERESP_get_ext(single, j);
|
|
926
926
|
rb_ary_push(ext, ossl_x509ext_new(x509ext));
|
|
927
927
|
}
|
|
928
928
|
rb_ary_push(ary, ext);
|
|
@@ -1341,7 +1341,6 @@ static VALUE
|
|
|
1341
1341
|
ossl_ocspsres_get_extensions(VALUE self)
|
|
1342
1342
|
{
|
|
1343
1343
|
OCSP_SINGLERESP *sres;
|
|
1344
|
-
X509_EXTENSION *ext;
|
|
1345
1344
|
int count, i;
|
|
1346
1345
|
VALUE ary;
|
|
1347
1346
|
|
|
@@ -1350,7 +1349,7 @@ ossl_ocspsres_get_extensions(VALUE self)
|
|
|
1350
1349
|
count = OCSP_SINGLERESP_get_ext_count(sres);
|
|
1351
1350
|
ary = rb_ary_new2(count);
|
|
1352
1351
|
for (i = 0; i < count; i++) {
|
|
1353
|
-
ext = OCSP_SINGLERESP_get_ext(sres, i);
|
|
1352
|
+
const X509_EXTENSION *ext = OCSP_SINGLERESP_get_ext(sres, i);
|
|
1354
1353
|
rb_ary_push(ary, ossl_x509ext_new(ext)); /* will dup */
|
|
1355
1354
|
}
|
|
1356
1355
|
|
data/ext/openssl/ossl_pkcs7.c
CHANGED
data/ext/openssl/ossl_pkey.h
CHANGED
data/ext/openssl/ossl_pkey_ec.c
CHANGED
|
@@ -702,7 +702,7 @@ static VALUE ossl_ec_group_initialize(int argc, VALUE *argv, VALUE self)
|
|
|
702
702
|
|
|
703
703
|
break;
|
|
704
704
|
default:
|
|
705
|
-
ossl_raise(rb_eArgError, "wrong number of arguments");
|
|
705
|
+
ossl_raise(rb_eArgError, "wrong number of arguments (given %d, expected 1 or 4)", argc);
|
|
706
706
|
}
|
|
707
707
|
|
|
708
708
|
ASSUME(group);
|
data/ext/openssl/ossl_ssl.c
CHANGED
|
@@ -47,7 +47,7 @@ static ID id_i_cert_store, id_i_ca_file, id_i_ca_path, id_i_verify_mode,
|
|
|
47
47
|
id_i_session_remove_cb, id_i_npn_select_cb, id_i_npn_protocols,
|
|
48
48
|
id_i_alpn_select_cb, id_i_alpn_protocols, id_i_servername_cb,
|
|
49
49
|
id_i_verify_hostname, id_i_keylog_cb, id_i_tmp_dh_callback;
|
|
50
|
-
static ID id_i_io, id_i_context, id_i_hostname;
|
|
50
|
+
static ID id_i_io, id_i_context, id_i_hostname, id_i_sync_close;
|
|
51
51
|
|
|
52
52
|
static int ossl_ssl_ex_ptr_idx;
|
|
53
53
|
static int ossl_sslctx_ex_ptr_idx;
|
|
@@ -1590,32 +1590,31 @@ ossl_ssl_s_alloc(VALUE klass)
|
|
|
1590
1590
|
}
|
|
1591
1591
|
|
|
1592
1592
|
static VALUE
|
|
1593
|
-
peer_ip_address(VALUE
|
|
1593
|
+
peer_ip_address(VALUE io)
|
|
1594
1594
|
{
|
|
1595
|
-
VALUE remote_address = rb_funcall(
|
|
1595
|
+
VALUE remote_address = rb_funcall(io, rb_intern("remote_address"), 0);
|
|
1596
1596
|
|
|
1597
1597
|
return rb_funcall(remote_address, rb_intern("inspect_sockaddr"), 0);
|
|
1598
1598
|
}
|
|
1599
1599
|
|
|
1600
1600
|
static VALUE
|
|
1601
|
-
fallback_peer_ip_address(VALUE self, VALUE
|
|
1601
|
+
fallback_peer_ip_address(VALUE self, VALUE exc)
|
|
1602
1602
|
{
|
|
1603
1603
|
return rb_str_new_cstr("(null)");
|
|
1604
1604
|
}
|
|
1605
1605
|
|
|
1606
1606
|
static VALUE
|
|
1607
|
-
peeraddr_ip_str(VALUE
|
|
1607
|
+
peeraddr_ip_str(VALUE io)
|
|
1608
1608
|
{
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
return rb_rescue2(peer_ip_address, self, fallback_peer_ip_address, (VALUE)0, rb_eSystemCallError, NULL);
|
|
1609
|
+
return rb_rescue2(peer_ip_address, io, fallback_peer_ip_address, Qnil,
|
|
1610
|
+
rb_eSystemCallError, (VALUE)0);
|
|
1613
1611
|
}
|
|
1614
1612
|
|
|
1615
1613
|
/*
|
|
1616
1614
|
* call-seq:
|
|
1617
1615
|
* SSLSocket.new(io) => aSSLSocket
|
|
1618
1616
|
* SSLSocket.new(io, ctx) => aSSLSocket
|
|
1617
|
+
* SSLSocket.new(io, ctx, sync_close:) => aSSLSocket
|
|
1619
1618
|
*
|
|
1620
1619
|
* Creates a new SSL socket from _io_ which must be a real IO object (not an
|
|
1621
1620
|
* IO-like object that responds to read/write).
|
|
@@ -1623,6 +1622,10 @@ peeraddr_ip_str(VALUE self)
|
|
|
1623
1622
|
* If _ctx_ is provided the SSL Sockets initial params will be taken from
|
|
1624
1623
|
* the context.
|
|
1625
1624
|
*
|
|
1625
|
+
* The optional _sync_close_ keyword parameter sets the _sync_close_ instance
|
|
1626
|
+
* variable. Setting this to +true+ will cause the underlying socket to be
|
|
1627
|
+
* closed when the SSL/TLS connection is shut down.
|
|
1628
|
+
*
|
|
1626
1629
|
* The OpenSSL::Buffering module provides additional IO methods.
|
|
1627
1630
|
*
|
|
1628
1631
|
* This method will freeze the SSLContext if one is provided;
|
|
@@ -1631,6 +1634,10 @@ peeraddr_ip_str(VALUE self)
|
|
|
1631
1634
|
static VALUE
|
|
1632
1635
|
ossl_ssl_initialize(int argc, VALUE *argv, VALUE self)
|
|
1633
1636
|
{
|
|
1637
|
+
static ID kw_ids[1];
|
|
1638
|
+
VALUE kw_args[1];
|
|
1639
|
+
VALUE opts;
|
|
1640
|
+
|
|
1634
1641
|
VALUE io, v_ctx;
|
|
1635
1642
|
SSL *ssl;
|
|
1636
1643
|
SSL_CTX *ctx;
|
|
@@ -1639,9 +1646,18 @@ ossl_ssl_initialize(int argc, VALUE *argv, VALUE self)
|
|
|
1639
1646
|
if (ssl)
|
|
1640
1647
|
ossl_raise(eSSLError, "SSL already initialized");
|
|
1641
1648
|
|
|
1642
|
-
if (rb_scan_args(argc, argv, "11", &io, &v_ctx) == 1)
|
|
1649
|
+
if (rb_scan_args(argc, argv, "11:", &io, &v_ctx, &opts) == 1)
|
|
1643
1650
|
v_ctx = rb_funcall(cSSLContext, rb_intern("new"), 0);
|
|
1644
1651
|
|
|
1652
|
+
if (!kw_ids[0]) {
|
|
1653
|
+
kw_ids[0] = rb_intern_const("sync_close");
|
|
1654
|
+
}
|
|
1655
|
+
|
|
1656
|
+
rb_get_kwargs(opts, kw_ids, 0, 1, kw_args);
|
|
1657
|
+
if (kw_args[0] != Qundef) {
|
|
1658
|
+
rb_ivar_set(self, id_i_sync_close, kw_args[0]);
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1645
1661
|
GetSSLCTX(v_ctx, ctx);
|
|
1646
1662
|
rb_ivar_set(self, id_i_context, v_ctx);
|
|
1647
1663
|
ossl_sslctx_setup(v_ctx);
|
|
@@ -1696,11 +1712,15 @@ ossl_ssl_setup(VALUE self)
|
|
|
1696
1712
|
return Qtrue;
|
|
1697
1713
|
}
|
|
1698
1714
|
|
|
1715
|
+
static int
|
|
1716
|
+
errno_mapped(void)
|
|
1717
|
+
{
|
|
1699
1718
|
#ifdef _WIN32
|
|
1700
|
-
|
|
1719
|
+
return rb_w32_map_errno(WSAGetLastError());
|
|
1701
1720
|
#else
|
|
1702
|
-
|
|
1721
|
+
return errno;
|
|
1703
1722
|
#endif
|
|
1723
|
+
}
|
|
1704
1724
|
|
|
1705
1725
|
static void
|
|
1706
1726
|
write_would_block(int nonblock)
|
|
@@ -1741,13 +1761,13 @@ static void
|
|
|
1741
1761
|
io_wait_writable(VALUE io)
|
|
1742
1762
|
{
|
|
1743
1763
|
#ifdef HAVE_RB_IO_MAYBE_WAIT
|
|
1744
|
-
if (!
|
|
1764
|
+
if (!rb_io_wait(io, INT2NUM(RUBY_IO_WRITABLE), RUBY_IO_TIMEOUT_DEFAULT)) {
|
|
1745
1765
|
rb_raise(IO_TIMEOUT_ERROR, "Timed out while waiting to become writable!");
|
|
1746
1766
|
}
|
|
1747
1767
|
#else
|
|
1748
1768
|
rb_io_t *fptr;
|
|
1749
1769
|
GetOpenFile(io, fptr);
|
|
1750
|
-
|
|
1770
|
+
rb_thread_fd_writable(fptr->fd);
|
|
1751
1771
|
#endif
|
|
1752
1772
|
}
|
|
1753
1773
|
|
|
@@ -1755,13 +1775,13 @@ static void
|
|
|
1755
1775
|
io_wait_readable(VALUE io)
|
|
1756
1776
|
{
|
|
1757
1777
|
#ifdef HAVE_RB_IO_MAYBE_WAIT
|
|
1758
|
-
if (!
|
|
1778
|
+
if (!rb_io_wait(io, INT2NUM(RUBY_IO_READABLE), RUBY_IO_TIMEOUT_DEFAULT)) {
|
|
1759
1779
|
rb_raise(IO_TIMEOUT_ERROR, "Timed out while waiting to become readable!");
|
|
1760
1780
|
}
|
|
1761
1781
|
#else
|
|
1762
1782
|
rb_io_t *fptr;
|
|
1763
1783
|
GetOpenFile(io, fptr);
|
|
1764
|
-
|
|
1784
|
+
rb_thread_wait_fd(fptr->fd);
|
|
1765
1785
|
#endif
|
|
1766
1786
|
}
|
|
1767
1787
|
|
|
@@ -1769,7 +1789,6 @@ static VALUE
|
|
|
1769
1789
|
ossl_start_ssl(VALUE self, int (*func)(SSL *), const char *funcname, VALUE opts)
|
|
1770
1790
|
{
|
|
1771
1791
|
SSL *ssl;
|
|
1772
|
-
int ret, ret2;
|
|
1773
1792
|
VALUE cb_state;
|
|
1774
1793
|
int nonblock = opts != Qfalse;
|
|
1775
1794
|
|
|
@@ -1779,7 +1798,8 @@ ossl_start_ssl(VALUE self, int (*func)(SSL *), const char *funcname, VALUE opts)
|
|
|
1779
1798
|
|
|
1780
1799
|
VALUE io = rb_attr_get(self, id_i_io);
|
|
1781
1800
|
for (;;) {
|
|
1782
|
-
ret = func(ssl);
|
|
1801
|
+
int ret = func(ssl);
|
|
1802
|
+
int saved_errno = errno_mapped();
|
|
1783
1803
|
|
|
1784
1804
|
cb_state = rb_attr_get(self, ID_callback_state);
|
|
1785
1805
|
if (!NIL_P(cb_state)) {
|
|
@@ -1791,7 +1811,8 @@ ossl_start_ssl(VALUE self, int (*func)(SSL *), const char *funcname, VALUE opts)
|
|
|
1791
1811
|
if (ret > 0)
|
|
1792
1812
|
break;
|
|
1793
1813
|
|
|
1794
|
-
|
|
1814
|
+
int code = SSL_get_error(ssl, ret);
|
|
1815
|
+
switch (code) {
|
|
1795
1816
|
case SSL_ERROR_WANT_WRITE:
|
|
1796
1817
|
if (no_exception_p(opts)) { return sym_wait_writable; }
|
|
1797
1818
|
write_would_block(nonblock);
|
|
@@ -1805,10 +1826,11 @@ ossl_start_ssl(VALUE self, int (*func)(SSL *), const char *funcname, VALUE opts)
|
|
|
1805
1826
|
case SSL_ERROR_SYSCALL:
|
|
1806
1827
|
#ifdef __APPLE__
|
|
1807
1828
|
/* See ossl_ssl_write_internal() */
|
|
1808
|
-
if (
|
|
1829
|
+
if (saved_errno == EPROTOTYPE)
|
|
1809
1830
|
continue;
|
|
1810
1831
|
#endif
|
|
1811
|
-
if (
|
|
1832
|
+
if (saved_errno)
|
|
1833
|
+
rb_exc_raise(rb_syserr_new(saved_errno, funcname));
|
|
1812
1834
|
/* fallthrough */
|
|
1813
1835
|
default: {
|
|
1814
1836
|
VALUE error_append = Qnil;
|
|
@@ -1829,10 +1851,10 @@ ossl_start_ssl(VALUE self, int (*func)(SSL *), const char *funcname, VALUE opts)
|
|
|
1829
1851
|
ossl_raise(eSSLError,
|
|
1830
1852
|
"%s%s returned=%d errno=%d peeraddr=%"PRIsVALUE" state=%s%"PRIsVALUE,
|
|
1831
1853
|
funcname,
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
peeraddr_ip_str(
|
|
1854
|
+
code == SSL_ERROR_SYSCALL ? " SYSCALL" : "",
|
|
1855
|
+
code,
|
|
1856
|
+
saved_errno,
|
|
1857
|
+
peeraddr_ip_str(io),
|
|
1836
1858
|
SSL_state_string_long(ssl),
|
|
1837
1859
|
error_append);
|
|
1838
1860
|
}
|
|
@@ -1974,6 +1996,7 @@ ossl_ssl_read_internal(int argc, VALUE *argv, VALUE self, int nonblock)
|
|
|
1974
1996
|
for (;;) {
|
|
1975
1997
|
rb_str_locktmp(str);
|
|
1976
1998
|
int nread = SSL_read(ssl, RSTRING_PTR(str), ilen);
|
|
1999
|
+
int saved_errno = errno_mapped();
|
|
1977
2000
|
rb_str_unlocktmp(str);
|
|
1978
2001
|
|
|
1979
2002
|
cb_state = rb_attr_get(self, ID_callback_state);
|
|
@@ -1983,7 +2006,7 @@ ossl_ssl_read_internal(int argc, VALUE *argv, VALUE self, int nonblock)
|
|
|
1983
2006
|
rb_jump_tag(NUM2INT(cb_state));
|
|
1984
2007
|
}
|
|
1985
2008
|
|
|
1986
|
-
switch (
|
|
2009
|
+
switch (SSL_get_error(ssl, nread)) {
|
|
1987
2010
|
case SSL_ERROR_NONE:
|
|
1988
2011
|
rb_str_set_len(str, nread);
|
|
1989
2012
|
return str;
|
|
@@ -2006,8 +2029,8 @@ ossl_ssl_read_internal(int argc, VALUE *argv, VALUE self, int nonblock)
|
|
|
2006
2029
|
break;
|
|
2007
2030
|
case SSL_ERROR_SYSCALL:
|
|
2008
2031
|
if (!ERR_peek_error()) {
|
|
2009
|
-
if (
|
|
2010
|
-
|
|
2032
|
+
if (saved_errno)
|
|
2033
|
+
rb_exc_raise(rb_syserr_new(saved_errno, "SSL_read"));
|
|
2011
2034
|
else {
|
|
2012
2035
|
/*
|
|
2013
2036
|
* The underlying BIO returned 0. This is actually a
|
|
@@ -2092,6 +2115,7 @@ ossl_ssl_write_internal_safe(VALUE _args)
|
|
|
2092
2115
|
|
|
2093
2116
|
for (;;) {
|
|
2094
2117
|
int nwritten = SSL_write(ssl, RSTRING_PTR(str), num);
|
|
2118
|
+
int saved_errno = errno_mapped();
|
|
2095
2119
|
|
|
2096
2120
|
cb_state = rb_attr_get(self, ID_callback_state);
|
|
2097
2121
|
if (!NIL_P(cb_state)) {
|
|
@@ -2100,7 +2124,7 @@ ossl_ssl_write_internal_safe(VALUE _args)
|
|
|
2100
2124
|
rb_jump_tag(NUM2INT(cb_state));
|
|
2101
2125
|
}
|
|
2102
2126
|
|
|
2103
|
-
switch (
|
|
2127
|
+
switch (SSL_get_error(ssl, nwritten)) {
|
|
2104
2128
|
case SSL_ERROR_NONE:
|
|
2105
2129
|
return INT2NUM(nwritten);
|
|
2106
2130
|
case SSL_ERROR_WANT_WRITE:
|
|
@@ -2121,10 +2145,11 @@ ossl_ssl_write_internal_safe(VALUE _args)
|
|
|
2121
2145
|
* make the error handling in line with the socket library.
|
|
2122
2146
|
* [Bug #14713] https://bugs.ruby-lang.org/issues/14713
|
|
2123
2147
|
*/
|
|
2124
|
-
if (
|
|
2148
|
+
if (saved_errno == EPROTOTYPE)
|
|
2125
2149
|
continue;
|
|
2126
2150
|
#endif
|
|
2127
|
-
if (
|
|
2151
|
+
if (saved_errno)
|
|
2152
|
+
rb_exc_raise(rb_syserr_new(saved_errno, "SSL_write"));
|
|
2128
2153
|
/* fallthrough */
|
|
2129
2154
|
default:
|
|
2130
2155
|
ossl_raise(eSSLError, "SSL_write");
|
|
@@ -3300,5 +3325,6 @@ Init_ossl_ssl(void)
|
|
|
3300
3325
|
DefIVarID(io);
|
|
3301
3326
|
DefIVarID(context);
|
|
3302
3327
|
DefIVarID(hostname);
|
|
3328
|
+
DefIVarID(sync_close);
|
|
3303
3329
|
#endif /* !defined(OPENSSL_NO_SOCK) */
|
|
3304
3330
|
}
|
data/ext/openssl/ossl_ts.c
CHANGED
data/ext/openssl/ossl_x509.h
CHANGED
|
@@ -29,7 +29,7 @@ void Init_ossl_x509(void);
|
|
|
29
29
|
*/
|
|
30
30
|
extern VALUE cX509Attr;
|
|
31
31
|
|
|
32
|
-
VALUE ossl_x509attr_new(X509_ATTRIBUTE *);
|
|
32
|
+
VALUE ossl_x509attr_new(const X509_ATTRIBUTE *);
|
|
33
33
|
X509_ATTRIBUTE *GetX509AttrPtr(VALUE);
|
|
34
34
|
void Init_ossl_x509attr(void);
|
|
35
35
|
|
|
@@ -38,7 +38,7 @@ void Init_ossl_x509attr(void);
|
|
|
38
38
|
*/
|
|
39
39
|
extern VALUE cX509Cert;
|
|
40
40
|
|
|
41
|
-
VALUE ossl_x509_new(X509 *);
|
|
41
|
+
VALUE ossl_x509_new(const X509 *);
|
|
42
42
|
X509 *GetX509CertPtr(VALUE);
|
|
43
43
|
X509 *DupX509CertPtr(VALUE);
|
|
44
44
|
void Init_ossl_x509cert(void);
|
|
@@ -46,7 +46,7 @@ void Init_ossl_x509cert(void);
|
|
|
46
46
|
/*
|
|
47
47
|
* X509CRL
|
|
48
48
|
*/
|
|
49
|
-
VALUE ossl_x509crl_new(X509_CRL *);
|
|
49
|
+
VALUE ossl_x509crl_new(const X509_CRL *);
|
|
50
50
|
X509_CRL *GetX509CRLPtr(VALUE);
|
|
51
51
|
void Init_ossl_x509crl(void);
|
|
52
52
|
|
|
@@ -55,14 +55,14 @@ void Init_ossl_x509crl(void);
|
|
|
55
55
|
*/
|
|
56
56
|
extern VALUE cX509Ext;
|
|
57
57
|
|
|
58
|
-
VALUE ossl_x509ext_new(X509_EXTENSION *);
|
|
58
|
+
VALUE ossl_x509ext_new(const X509_EXTENSION *);
|
|
59
59
|
X509_EXTENSION *GetX509ExtPtr(VALUE);
|
|
60
60
|
void Init_ossl_x509ext(void);
|
|
61
61
|
|
|
62
62
|
/*
|
|
63
63
|
* X509Name
|
|
64
64
|
*/
|
|
65
|
-
VALUE ossl_x509name_new(X509_NAME *);
|
|
65
|
+
VALUE ossl_x509name_new(const X509_NAME *);
|
|
66
66
|
X509_NAME *GetX509NamePtr(VALUE);
|
|
67
67
|
void Init_ossl_x509name(void);
|
|
68
68
|
|
|
@@ -77,7 +77,7 @@ void Init_ossl_x509req(void);
|
|
|
77
77
|
*/
|
|
78
78
|
extern VALUE cX509Rev;
|
|
79
79
|
|
|
80
|
-
VALUE ossl_x509revoked_new(X509_REVOKED *);
|
|
80
|
+
VALUE ossl_x509revoked_new(const X509_REVOKED *);
|
|
81
81
|
X509_REVOKED *DupX509RevokedPtr(VALUE);
|
|
82
82
|
void Init_ossl_x509revoked(void);
|
|
83
83
|
|
data/ext/openssl/ossl_x509attr.c
CHANGED
|
@@ -48,13 +48,14 @@ static const rb_data_type_t ossl_x509attr_type = {
|
|
|
48
48
|
* Public
|
|
49
49
|
*/
|
|
50
50
|
VALUE
|
|
51
|
-
ossl_x509attr_new(X509_ATTRIBUTE *attr)
|
|
51
|
+
ossl_x509attr_new(const X509_ATTRIBUTE *attr)
|
|
52
52
|
{
|
|
53
53
|
X509_ATTRIBUTE *new;
|
|
54
54
|
VALUE obj;
|
|
55
55
|
|
|
56
56
|
obj = NewX509Attr(cX509Attr);
|
|
57
|
-
|
|
57
|
+
/* OpenSSL 1.1.1 takes a non-const pointer */
|
|
58
|
+
new = X509_ATTRIBUTE_dup((X509_ATTRIBUTE *)attr);
|
|
58
59
|
if (!new)
|
|
59
60
|
ossl_raise(eX509AttrError, "X509_ATTRIBUTE_dup");
|
|
60
61
|
SetX509Attr(obj, new);
|
|
@@ -196,7 +197,7 @@ ossl_x509attr_set_value(VALUE self, VALUE value)
|
|
|
196
197
|
ossl_raise(eX509AttrError, "attribute value must be ASN1::Set");
|
|
197
198
|
|
|
198
199
|
if (X509_ATTRIBUTE_count(attr)) { /* populated, reset first */
|
|
199
|
-
ASN1_OBJECT *obj = X509_ATTRIBUTE_get0_object(attr);
|
|
200
|
+
const ASN1_OBJECT *obj = X509_ATTRIBUTE_get0_object(attr);
|
|
200
201
|
X509_ATTRIBUTE *new_attr = X509_ATTRIBUTE_create_by_OBJ(NULL, obj, 0, NULL, -1);
|
|
201
202
|
if (!new_attr) {
|
|
202
203
|
sk_ASN1_TYPE_pop_free(sk, ASN1_TYPE_free);
|
|
@@ -240,7 +241,7 @@ ossl_x509attr_get_value(VALUE self)
|
|
|
240
241
|
|
|
241
242
|
count = X509_ATTRIBUTE_count(attr);
|
|
242
243
|
for (i = 0; i < count; i++)
|
|
243
|
-
sk_ASN1_TYPE_push(sk, X509_ATTRIBUTE_get0_type(attr, i));
|
|
244
|
+
sk_ASN1_TYPE_push(sk, (ASN1_TYPE *)X509_ATTRIBUTE_get0_type(attr, i));
|
|
244
245
|
|
|
245
246
|
if ((len = i2d_ASN1_SET_ANY(sk, NULL)) <= 0) {
|
|
246
247
|
sk_ASN1_TYPE_free(sk);
|
data/ext/openssl/ossl_x509cert.c
CHANGED
|
@@ -48,13 +48,14 @@ static const rb_data_type_t ossl_x509_type = {
|
|
|
48
48
|
* Public
|
|
49
49
|
*/
|
|
50
50
|
VALUE
|
|
51
|
-
ossl_x509_new(X509 *x509)
|
|
51
|
+
ossl_x509_new(const X509 *x509)
|
|
52
52
|
{
|
|
53
53
|
X509 *new;
|
|
54
54
|
VALUE obj;
|
|
55
55
|
|
|
56
56
|
obj = NewX509(cX509Cert);
|
|
57
|
-
|
|
57
|
+
/* OpenSSL 1.1.1 takes a non-const pointer */
|
|
58
|
+
new = X509_dup((X509 *)x509);
|
|
58
59
|
if (!new)
|
|
59
60
|
ossl_raise(eX509CertError, "X509_dup");
|
|
60
61
|
SetX509(obj, new);
|
|
@@ -345,7 +346,7 @@ static VALUE
|
|
|
345
346
|
ossl_x509_get_subject(VALUE self)
|
|
346
347
|
{
|
|
347
348
|
X509 *x509;
|
|
348
|
-
X509_NAME *name;
|
|
349
|
+
const X509_NAME *name;
|
|
349
350
|
|
|
350
351
|
GetX509(self, x509);
|
|
351
352
|
if (!(name = X509_get_subject_name(x509))) { /* NO DUP - don't free! */
|
|
@@ -380,7 +381,7 @@ static VALUE
|
|
|
380
381
|
ossl_x509_get_issuer(VALUE self)
|
|
381
382
|
{
|
|
382
383
|
X509 *x509;
|
|
383
|
-
X509_NAME *name;
|
|
384
|
+
const X509_NAME *name;
|
|
384
385
|
|
|
385
386
|
GetX509(self, x509);
|
|
386
387
|
if(!(name = X509_get_issuer_name(x509))) { /* NO DUP - don't free! */
|
|
@@ -603,14 +604,13 @@ ossl_x509_get_extensions(VALUE self)
|
|
|
603
604
|
{
|
|
604
605
|
X509 *x509;
|
|
605
606
|
int count, i;
|
|
606
|
-
X509_EXTENSION *ext;
|
|
607
607
|
VALUE ary;
|
|
608
608
|
|
|
609
609
|
GetX509(self, x509);
|
|
610
610
|
count = X509_get_ext_count(x509);
|
|
611
611
|
ary = rb_ary_new_capa(count);
|
|
612
612
|
for (i=0; i<count; i++) {
|
|
613
|
-
ext = X509_get_ext(x509, i);
|
|
613
|
+
const X509_EXTENSION *ext = X509_get_ext(x509, i);
|
|
614
614
|
rb_ary_push(ary, ossl_x509ext_new(ext));
|
|
615
615
|
}
|
|
616
616
|
|
data/ext/openssl/ossl_x509crl.c
CHANGED
|
@@ -58,13 +58,14 @@ GetX509CRLPtr(VALUE obj)
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
VALUE
|
|
61
|
-
ossl_x509crl_new(X509_CRL *crl)
|
|
61
|
+
ossl_x509crl_new(const X509_CRL *crl)
|
|
62
62
|
{
|
|
63
63
|
X509_CRL *tmp;
|
|
64
64
|
VALUE obj;
|
|
65
65
|
|
|
66
66
|
obj = NewX509CRL(cX509CRL);
|
|
67
|
-
|
|
67
|
+
/* OpenSSL 1.1.1 takes a non-const pointer */
|
|
68
|
+
tmp = X509_CRL_dup((X509_CRL *)crl);
|
|
68
69
|
if (!tmp)
|
|
69
70
|
ossl_raise(eX509CRLError, "X509_CRL_dup");
|
|
70
71
|
SetX509CRL(obj, tmp);
|
|
@@ -289,7 +290,7 @@ ossl_x509crl_get_revoked(VALUE self)
|
|
|
289
290
|
num = sk_X509_REVOKED_num(sk);
|
|
290
291
|
ary = rb_ary_new_capa(num);
|
|
291
292
|
for(i=0; i<num; i++) {
|
|
292
|
-
X509_REVOKED *rev = sk_X509_REVOKED_value(sk, i);
|
|
293
|
+
const X509_REVOKED *rev = sk_X509_REVOKED_value(sk, i);
|
|
293
294
|
rb_ary_push(ary, ossl_x509revoked_new(rev));
|
|
294
295
|
}
|
|
295
296
|
|
|
@@ -443,14 +444,13 @@ ossl_x509crl_get_extensions(VALUE self)
|
|
|
443
444
|
{
|
|
444
445
|
X509_CRL *crl;
|
|
445
446
|
int count, i;
|
|
446
|
-
X509_EXTENSION *ext;
|
|
447
447
|
VALUE ary;
|
|
448
448
|
|
|
449
449
|
GetX509CRL(self, crl);
|
|
450
450
|
count = X509_CRL_get_ext_count(crl);
|
|
451
451
|
ary = rb_ary_new_capa(count);
|
|
452
452
|
for (i=0; i<count; i++) {
|
|
453
|
-
ext = X509_CRL_get_ext(crl, i);
|
|
453
|
+
const X509_EXTENSION *ext = X509_CRL_get_ext(crl, i);
|
|
454
454
|
rb_ary_push(ary, ossl_x509ext_new(ext));
|
|
455
455
|
}
|
|
456
456
|
|
data/ext/openssl/ossl_x509ext.c
CHANGED
|
@@ -62,13 +62,14 @@ static const rb_data_type_t ossl_x509ext_type = {
|
|
|
62
62
|
* Public
|
|
63
63
|
*/
|
|
64
64
|
VALUE
|
|
65
|
-
ossl_x509ext_new(X509_EXTENSION *ext)
|
|
65
|
+
ossl_x509ext_new(const X509_EXTENSION *ext)
|
|
66
66
|
{
|
|
67
67
|
X509_EXTENSION *new;
|
|
68
68
|
VALUE obj;
|
|
69
69
|
|
|
70
70
|
obj = NewX509Ext(cX509Ext);
|
|
71
|
-
|
|
71
|
+
/* OpenSSL 1.1.1 takes a non-const pointer */
|
|
72
|
+
new = X509_EXTENSION_dup((X509_EXTENSION *)ext);
|
|
72
73
|
if (!new)
|
|
73
74
|
ossl_raise(eX509ExtError, "X509_EXTENSION_dup");
|
|
74
75
|
SetX509Ext(obj, new);
|
|
@@ -338,12 +339,20 @@ ossl_x509ext_set_value(VALUE self, VALUE data)
|
|
|
338
339
|
GetX509Ext(self, ext);
|
|
339
340
|
data = ossl_to_der_if_possible(data);
|
|
340
341
|
StringValue(data);
|
|
341
|
-
asn1s = X509_EXTENSION_get_data(ext);
|
|
342
342
|
|
|
343
|
+
asn1s = ASN1_OCTET_STRING_new();
|
|
344
|
+
if (!asn1s)
|
|
345
|
+
ossl_raise(eX509ExtError, "ASN1_OCTET_STRING_new");
|
|
343
346
|
if (!ASN1_OCTET_STRING_set(asn1s, (unsigned char *)RSTRING_PTR(data),
|
|
344
347
|
RSTRING_LENINT(data))) {
|
|
348
|
+
ASN1_OCTET_STRING_free(asn1s);
|
|
345
349
|
ossl_raise(eX509ExtError, "ASN1_OCTET_STRING_set");
|
|
346
350
|
}
|
|
351
|
+
if (!X509_EXTENSION_set_data(ext, asn1s)) {
|
|
352
|
+
ASN1_OCTET_STRING_free(asn1s);
|
|
353
|
+
ossl_raise(eX509ExtError, "X509_EXTENSION_set_data");
|
|
354
|
+
}
|
|
355
|
+
ASN1_OCTET_STRING_free(asn1s);
|
|
347
356
|
|
|
348
357
|
return data;
|
|
349
358
|
}
|
|
@@ -386,7 +395,7 @@ ossl_x509ext_get_value(VALUE obj)
|
|
|
386
395
|
if (!(out = BIO_new(BIO_s_mem())))
|
|
387
396
|
ossl_raise(eX509ExtError, NULL);
|
|
388
397
|
if (!X509V3_EXT_print(out, ext, 0, 0))
|
|
389
|
-
ASN1_STRING_print(out,
|
|
398
|
+
ASN1_STRING_print(out, X509_EXTENSION_get_data(ext));
|
|
390
399
|
ret = ossl_membio2str(out);
|
|
391
400
|
|
|
392
401
|
return ret;
|
|
@@ -396,7 +405,7 @@ static VALUE
|
|
|
396
405
|
ossl_x509ext_get_value_der(VALUE obj)
|
|
397
406
|
{
|
|
398
407
|
X509_EXTENSION *ext;
|
|
399
|
-
ASN1_OCTET_STRING *value;
|
|
408
|
+
const ASN1_OCTET_STRING *value;
|
|
400
409
|
|
|
401
410
|
GetX509Ext(obj, ext);
|
|
402
411
|
if ((value = X509_EXTENSION_get_data(ext)) == NULL)
|
data/ext/openssl/ossl_x509name.c
CHANGED
|
@@ -53,13 +53,14 @@ static const rb_data_type_t ossl_x509name_type = {
|
|
|
53
53
|
* Public
|
|
54
54
|
*/
|
|
55
55
|
VALUE
|
|
56
|
-
ossl_x509name_new(X509_NAME *name)
|
|
56
|
+
ossl_x509name_new(const X509_NAME *name)
|
|
57
57
|
{
|
|
58
58
|
X509_NAME *new;
|
|
59
59
|
VALUE obj;
|
|
60
60
|
|
|
61
61
|
obj = NewX509Name(cX509Name);
|
|
62
|
-
|
|
62
|
+
/* OpenSSL 1.1.1 takes a non-const pointer */
|
|
63
|
+
new = X509_NAME_dup((X509_NAME *)name);
|
|
63
64
|
if (!new)
|
|
64
65
|
ossl_raise(eX509NameError, "X509_NAME_dup");
|
|
65
66
|
SetX509Name(obj, new);
|
data/ext/openssl/ossl_x509req.c
CHANGED
|
@@ -231,7 +231,7 @@ static VALUE
|
|
|
231
231
|
ossl_x509req_get_subject(VALUE self)
|
|
232
232
|
{
|
|
233
233
|
X509_REQ *req;
|
|
234
|
-
X509_NAME *name;
|
|
234
|
+
const X509_NAME *name;
|
|
235
235
|
|
|
236
236
|
GetX509Req(self, req);
|
|
237
237
|
if (!(name = X509_REQ_get_subject_name(req))) { /* NO DUP - don't free */
|
|
@@ -351,7 +351,7 @@ ossl_x509req_get_attributes(VALUE self)
|
|
|
351
351
|
{
|
|
352
352
|
X509_REQ *req;
|
|
353
353
|
int count, i;
|
|
354
|
-
X509_ATTRIBUTE *attr;
|
|
354
|
+
const X509_ATTRIBUTE *attr;
|
|
355
355
|
VALUE ary;
|
|
356
356
|
|
|
357
357
|
GetX509Req(self, req);
|
|
@@ -48,13 +48,14 @@ static const rb_data_type_t ossl_x509rev_type = {
|
|
|
48
48
|
* PUBLIC
|
|
49
49
|
*/
|
|
50
50
|
VALUE
|
|
51
|
-
ossl_x509revoked_new(X509_REVOKED *rev)
|
|
51
|
+
ossl_x509revoked_new(const X509_REVOKED *rev)
|
|
52
52
|
{
|
|
53
53
|
X509_REVOKED *new;
|
|
54
54
|
VALUE obj;
|
|
55
55
|
|
|
56
56
|
obj = NewX509Rev(cX509Rev);
|
|
57
|
-
|
|
57
|
+
/* OpenSSL 1.1.1 takes a non-const pointer */
|
|
58
|
+
new = X509_REVOKED_dup((X509_REVOKED *)rev);
|
|
58
59
|
if (!new)
|
|
59
60
|
ossl_raise(eX509RevError, "X509_REVOKED_dup");
|
|
60
61
|
SetX509Rev(obj, new);
|
|
@@ -185,7 +186,7 @@ ossl_x509revoked_get_extensions(VALUE self)
|
|
|
185
186
|
{
|
|
186
187
|
X509_REVOKED *rev;
|
|
187
188
|
int count, i;
|
|
188
|
-
X509_EXTENSION *ext;
|
|
189
|
+
const X509_EXTENSION *ext;
|
|
189
190
|
VALUE ary;
|
|
190
191
|
|
|
191
192
|
GetX509Rev(self, rev);
|
|
@@ -512,10 +512,8 @@ static void
|
|
|
512
512
|
ossl_x509stctx_free(void *ptr)
|
|
513
513
|
{
|
|
514
514
|
X509_STORE_CTX *ctx = ptr;
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
if (X509_STORE_CTX_get0_cert(ctx))
|
|
518
|
-
X509_free(X509_STORE_CTX_get0_cert(ctx));
|
|
515
|
+
sk_X509_pop_free(X509_STORE_CTX_get0_untrusted(ctx), X509_free);
|
|
516
|
+
X509_free((X509 *)X509_STORE_CTX_get0_cert(ctx));
|
|
519
517
|
X509_STORE_CTX_free(ctx);
|
|
520
518
|
}
|
|
521
519
|
|
|
@@ -736,7 +734,7 @@ static VALUE
|
|
|
736
734
|
ossl_x509stctx_get_curr_cert(VALUE self)
|
|
737
735
|
{
|
|
738
736
|
X509_STORE_CTX *ctx;
|
|
739
|
-
X509 *x509;
|
|
737
|
+
const X509 *x509;
|
|
740
738
|
|
|
741
739
|
GetX509StCtx(self, ctx);
|
|
742
740
|
x509 = X509_STORE_CTX_get_current_cert(ctx);
|
|
@@ -758,7 +756,7 @@ static VALUE
|
|
|
758
756
|
ossl_x509stctx_get_curr_crl(VALUE self)
|
|
759
757
|
{
|
|
760
758
|
X509_STORE_CTX *ctx;
|
|
761
|
-
X509_CRL *crl;
|
|
759
|
+
const X509_CRL *crl;
|
|
762
760
|
|
|
763
761
|
GetX509StCtx(self, ctx);
|
|
764
762
|
crl = X509_STORE_CTX_get0_current_crl(ctx);
|
data/lib/openssl/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: openssl
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.0.
|
|
4
|
+
version: 4.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Martin Bosslet
|
|
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
118
118
|
- !ruby/object:Gem::Version
|
|
119
119
|
version: '0'
|
|
120
120
|
requirements: []
|
|
121
|
-
rubygems_version:
|
|
121
|
+
rubygems_version: 4.0.10
|
|
122
122
|
specification_version: 4
|
|
123
123
|
summary: SSL/TLS and general-purpose cryptography for Ruby
|
|
124
124
|
test_files: []
|