openssl 4.0.0 → 4.0.1
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 +20 -0
- data/ext/openssl/ossl_cipher.c +6 -7
- data/ext/openssl/ossl_ocsp.c +2 -2
- data/ext/openssl/ossl_pkcs7.c +1 -1
- data/ext/openssl/ossl_pkey_ec.c +1 -1
- data/ext/openssl/ossl_ssl.c +57 -31
- 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: f92669ca419f000bd9b54ca88b086fcfe46979a501f8350fe5bcfc0df6ffd896
|
|
4
|
+
data.tar.gz: 8570f9571e41d153bca54aff559dd4c447b1f1512825f977e2f868cc2a1d0659
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 85eeffa423f89bd6a7a6030ccf5b75a96f71c7e22e135f8a31dd5d8850cf848579cbcc664305cc3cd531b7eb5971ffca77c05981f97ec8c816a2e987e89147f7
|
|
7
|
+
data.tar.gz: c5b9eb04bf69f29bd65731fe6e506e4b5951caca68ff5820dc67c45bd8a21bf56d54a0407d113b9a6a761a1d120833357ae462eacb30a6da828eb6cab5100b68
|
data/History.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
Version 4.0.1
|
|
2
|
+
=============
|
|
3
|
+
|
|
4
|
+
Notable changes
|
|
5
|
+
---------------
|
|
6
|
+
|
|
7
|
+
* Add `sync_close` keyword argument to `OpenSSL::SSL::SSLSocket.new` as a
|
|
8
|
+
short-hand for setting `sync_close` attribute on the created `SSLSocket`
|
|
9
|
+
instance.
|
|
10
|
+
[[GitHub #955]](https://github.com/ruby/openssl/issues/955)
|
|
11
|
+
[[GitHub #996]](https://github.com/ruby/openssl/pull/996)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
Bug fixes
|
|
15
|
+
---------
|
|
16
|
+
|
|
17
|
+
* Fix uninitialized variables in `OpenSSL::OCSP::BasicResponse#status`.
|
|
18
|
+
[[GitHub #1004]](https://github.com/ruby/openssl/pull/1004)
|
|
19
|
+
|
|
20
|
+
|
|
1
21
|
Version 4.0.0
|
|
2
22
|
=============
|
|
3
23
|
|
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)
|
data/ext/openssl/ossl_pkcs7.c
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/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.1
|
|
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.3
|
|
122
122
|
specification_version: 4
|
|
123
123
|
summary: SSL/TLS and general-purpose cryptography for Ruby
|
|
124
124
|
test_files: []
|