Skip to content

Commit 995a46b

Browse files
committed
Merge branch 'maint' into ky/test-fixtures-update-2.1
* maint: (108 commits) Ruby/OpenSSL 2.1.1 Ruby/OpenSSL 2.1.0 Fix test-all tests to avoid creating report_on_exception warnings pkey/ec: add support for octet string encoding of EC point pkey/ec: rearrange PKey::EC::Point#initialize ssl: remove a misleading comment test/test_ssl: prevent changing default internal encoding Ruby/OpenSSL 2.1.0.beta2 test/test_x509crl: fix random failure test/test_x509cert: fix flaky test kdf: add HKDF support Drop support for LibreSSL 2.4 test/test_ssl: fix test_security_level ssl: add SSLContext#add_certificate test/utils: remove a pointless .public_key call in issue_cert test/envutil: port assert_warning from Ruby trunk Add RSA sign_pss() and verify_pss() methods Fix build failure against OpenSSL 1.1 built with no-deprecated Thanks rhenium for the code review and fixes. TLS Fallback Signaling Cipher Suite Value buffering: let #write accept multiple arguments ...
2 parents 5ba99ad + ce4022d commit 995a46b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+3915
-2607
lines changed

.travis.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,10 @@ matrix:
1919
include:
2020
- env: RUBY_VERSION=ruby-2.3 OPENSSL_VERSION=openssl-1.0.2
2121
- env: RUBY_VERSION=ruby-2.4 OPENSSL_VERSION=openssl-1.0.2
22-
- env: RUBY_VERSION=ruby-2.5 OPENSSL_VERSION=openssl-1.0.0
2322
- env: RUBY_VERSION=ruby-2.5 OPENSSL_VERSION=openssl-1.0.1
2423
- env: RUBY_VERSION=ruby-2.5 OPENSSL_VERSION=openssl-1.0.2
2524
- env: RUBY_VERSION=ruby-2.5 OPENSSL_VERSION=openssl-1.1.0
2625
- env: RUBY_VERSION=ruby-2.5 OPENSSL_VERSION=openssl-1.1.1
27-
- env: RUBY_VERSION=ruby-2.5 OPENSSL_VERSION=libressl-2.3
28-
- env: RUBY_VERSION=ruby-2.5 OPENSSL_VERSION=libressl-2.4
2926
- env: RUBY_VERSION=ruby-2.5 OPENSSL_VERSION=libressl-2.5
3027
- env: RUBY_VERSION=ruby-2.5 OPENSSL_VERSION=libressl-2.6
3128
- env: RUBY_VERSION=ruby-2.5 OPENSSL_VERSION=libressl-2.7

History.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,60 @@
1+
Version 2.1.0
2+
=============
3+
4+
Notable changes
5+
---------------
6+
7+
* Support for OpenSSL versions before 1.0.1 and LibreSSL versions before 2.5
8+
is removed.
9+
[[GitHub #86]](https://github.com/ruby/openssl/pull/86)
10+
* OpenSSL::BN#negative?, #+@, and #-@ are added.
11+
* OpenSSL::SSL::SSLSocket#connect raises a more informative exception when
12+
certificate verification fails.
13+
[[GitHub #99]](https://github.com/ruby/openssl/pull/99)
14+
* OpenSSL::KDF module is newly added. In addition to PBKDF2-HMAC that has moved
15+
from OpenSSL::PKCS5, scrypt and HKDF are supported.
16+
[[GitHub #109]](https://github.com/ruby/openssl/pull/109)
17+
[[GitHub #173]](https://github.com/ruby/openssl/pull/173)
18+
* OpenSSL.fips_mode is added. We had the setter, but not the getter.
19+
[[GitHub #125]](https://github.com/ruby/openssl/pull/125)
20+
* OpenSSL::OCSP::Request#signed? is added.
21+
* OpenSSL::ASN1 handles the indefinite length form better. OpenSSL::ASN1.decode
22+
no longer wrongly treats the end-of-contents octets as part of the content.
23+
OpenSSL::ASN1::ASN1Data#infinite_length is renamed to #indefinite_length.
24+
[[GitHub #98]](https://github.com/ruby/openssl/pull/98)
25+
* OpenSSL::X509::Name#add_entry now accepts two additional keyword arguments
26+
'loc' and 'set'.
27+
[[GitHub #94]](https://github.com/ruby/openssl/issues/94)
28+
* OpenSSL::SSL::SSLContext#min_version= and #max_version= are added to replace
29+
#ssl_version= that was built on top of the deprecated OpenSSL C API. Use of
30+
that method and the constant OpenSSL::SSL::SSLContext::METHODS is now
31+
deprecated.
32+
[[GitHub #142]](https://github.com/ruby/openssl/pull/142)
33+
* OpenSSL::X509::Name#to_utf8 is added.
34+
[[GitHub #26]](https://github.com/ruby/openssl/issues/26)
35+
[[GitHub #143]](https://github.com/ruby/openssl/pull/143)
36+
* OpenSSL::X509::{Extension,Attribute,Certificate,CRL,Revoked,Request} can be
37+
compared with == operator.
38+
[[GitHub #161]](https://github.com/ruby/openssl/pull/161)
39+
* TLS Fallback Signaling Cipher Suite Value (SCSV) support is added.
40+
[[GitHub #165]](https://github.com/ruby/openssl/pull/165)
41+
* Build failure with OpenSSL 1.1 built with no-deprecated is fixed.
42+
[[GitHub #160]](https://github.com/ruby/openssl/pull/160)
43+
* OpenSSL::Buffering#write accepts an arbitrary number of arguments.
44+
[[Feature #9323]](https://bugs.ruby-lang.org/issues/9323)
45+
[[GitHub #162]](https://github.com/ruby/openssl/pull/162)
46+
* OpenSSL::PKey::RSA#sign_pss and #verify_pss are added. They perform RSA-PSS
47+
signature and verification.
48+
[[GitHub #75]](https://github.com/ruby/openssl/issues/75)
49+
[[GitHub #76]](https://github.com/ruby/openssl/pull/76)
50+
[[GitHub #169]](https://github.com/ruby/openssl/pull/169)
51+
* OpenSSL::SSL::SSLContext#add_certificate is added.
52+
[[GitHub #167]](https://github.com/ruby/openssl/pull/167)
53+
* OpenSSL::PKey::EC::Point#to_octet_string is added.
54+
OpenSSL::PKey::EC::Point.new can now take String as the second argument.
55+
[[GitHub #177]](https://github.com/ruby/openssl/pull/177)
56+
57+
158
Version 2.0.8
259
=============
360

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Alternatively, you can install the gem with `bundler`:
2727
# Gemfile
2828
gem 'openssl'
2929
# or specify git master
30-
gem 'openssl', github: 'ruby/openssl'
30+
gem 'openssl', git: 'https://github.com/ruby/openssl'
3131
```
3232

3333
After doing `bundle install`, you should have the gem installed in your bundle.

Rakefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ RDoc::Task.new do |rdoc|
2020
rdoc.rdoc_files.include("*.md", "lib/**/*.rb", "ext/**/*.c")
2121
end
2222

23-
task :test => :debug
23+
task :test => [:compile, :debug]
2424
task :debug do
2525
ruby "-I./lib -ropenssl -ve'puts OpenSSL::OPENSSL_VERSION, OpenSSL::OPENSSL_LIBRARY_VERSION'"
2626
end
@@ -77,3 +77,5 @@ namespace :sync do
7777
puts "Don't forget to update ext/openssl/depend"
7878
end
7979
end
80+
81+
task :default => :test

ext/openssl/deprecation.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ module OpenSSL
33
def self.deprecated_warning_flag
44
unless flag = (@deprecated_warning_flag ||= nil)
55
if try_compile("", flag = "-Werror=deprecated-declarations")
6-
if /darwin/ =~ RUBY_PLATFORM and with_config("broken-apple-openssl")
7-
flag = "-Wno-deprecated-declarations"
8-
end
96
$warnflags << " #{flag}"
107
else
118
flag = ""

ext/openssl/extconf.rb

Lines changed: 7 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -94,30 +94,19 @@ def find_openssl_library
9494
unless find_openssl_library
9595
Logging::message "=== Checking for required stuff failed. ===\n"
9696
Logging::message "Makefile wasn't created. Fix the errors above.\n"
97-
exit 1
97+
raise "OpenSSL library could not be found. You might want to use " \
98+
"--with-openssl-dir=<dir> option to specify the prefix where OpenSSL " \
99+
"is installed."
98100
end
99101
end
100102

101-
result = checking_for("OpenSSL version is 0.9.8 or later") {
102-
try_static_assert("OPENSSL_VERSION_NUMBER >= 0x00908000L", "openssl/opensslv.h")
103-
}
104-
unless result
105-
raise "OpenSSL 0.9.8 or later required."
106-
end
107-
108-
if /darwin/ =~ RUBY_PLATFORM and !OpenSSL.check_func("SSL_library_init()", "openssl/ssl.h")
109-
raise "Ignore OpenSSL broken by Apple.\nPlease use another openssl. (e.g. using `configure --with-openssl-dir=/path/to/openssl')"
103+
unless checking_for("OpenSSL version is 1.0.1 or later") {
104+
try_static_assert("OPENSSL_VERSION_NUMBER >= 0x10001000L", "openssl/opensslv.h") }
105+
raise "OpenSSL >= 1.0.1 or LibreSSL is required"
110106
end
111107

112108
Logging::message "=== Checking for OpenSSL features... ===\n"
113109
# compile options
114-
115-
# SSLv2 and SSLv3 may be removed in future versions of OpenSSL, and even macros
116-
# like OPENSSL_NO_SSL2 may not be defined.
117-
have_func("SSLv2_method")
118-
have_func("SSLv3_method")
119-
have_func("TLSv1_1_method")
120-
have_func("TLSv1_2_method")
121110
have_func("RAND_egd")
122111
engines = %w{builtin_engines openbsd_dev_crypto dynamic 4758cca aep atalla chil
123112
cswift nuron sureware ubsec padlock capi gmp gost cryptodev aesni}
@@ -129,30 +118,6 @@ def find_openssl_library
129118
$defs.push("-DNOCRYPT")
130119
end
131120

132-
# added in 0.9.8X
133-
have_func("EVP_CIPHER_CTX_new")
134-
have_func("EVP_CIPHER_CTX_free")
135-
OpenSSL.check_func_or_macro("SSL_CTX_clear_options", "openssl/ssl.h")
136-
137-
# added in 1.0.0
138-
have_func("ASN1_TIME_adj")
139-
have_func("EVP_CIPHER_CTX_copy")
140-
have_func("EVP_PKEY_base_id")
141-
have_func("HMAC_CTX_copy")
142-
have_func("PKCS5_PBKDF2_HMAC")
143-
have_func("X509_NAME_hash_old")
144-
have_func("X509_STORE_CTX_get0_current_crl")
145-
have_func("X509_STORE_set_verify_cb")
146-
have_func("i2d_ASN1_SET_ANY")
147-
have_func("SSL_SESSION_cmp") # removed
148-
OpenSSL.check_func_or_macro("SSL_set_tlsext_host_name", "openssl/ssl.h")
149-
have_struct_member("CRYPTO_THREADID", "ptr", "openssl/crypto.h")
150-
have_func("EVP_PKEY_get0")
151-
152-
# added in 1.0.1
153-
have_func("SSL_CTX_set_next_proto_select_cb")
154-
have_macro("EVP_CTRL_GCM_GET_TAG", ['openssl/evp.h']) && $defs.push("-DHAVE_AUTHENTICATED_ENCRYPTION")
155-
156121
# added in 1.0.2
157122
have_func("EC_curve_nist2nid")
158123
have_func("X509_REVOKED_dup")
@@ -199,6 +164,7 @@ def find_openssl_library
199164
have_func("SSL_CTX_get_security_level")
200165
have_func("X509_get0_notBefore")
201166
have_func("SSL_SESSION_get_protocol_version")
167+
have_func("EVP_PBE_scrypt")
202168

203169
Logging::message "=== Checking done. ===\n"
204170

ext/openssl/openssl_missing.c

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -20,73 +20,6 @@
2020

2121
#include "openssl_missing.h"
2222

23-
/* added in 0.9.8X */
24-
#if !defined(HAVE_EVP_CIPHER_CTX_NEW)
25-
EVP_CIPHER_CTX *
26-
ossl_EVP_CIPHER_CTX_new(void)
27-
{
28-
EVP_CIPHER_CTX *ctx = OPENSSL_malloc(sizeof(EVP_CIPHER_CTX));
29-
if (!ctx)
30-
return NULL;
31-
EVP_CIPHER_CTX_init(ctx);
32-
return ctx;
33-
}
34-
#endif
35-
36-
#if !defined(HAVE_EVP_CIPHER_CTX_FREE)
37-
void
38-
ossl_EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *ctx)
39-
{
40-
if (ctx) {
41-
EVP_CIPHER_CTX_cleanup(ctx);
42-
OPENSSL_free(ctx);
43-
}
44-
}
45-
#endif
46-
47-
/* added in 1.0.0 */
48-
#if !defined(HAVE_EVP_CIPHER_CTX_COPY)
49-
/*
50-
* this function does not exist in OpenSSL yet... or ever?.
51-
* a future version may break this function.
52-
* tested on 0.9.7d.
53-
*/
54-
int
55-
ossl_EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in)
56-
{
57-
memcpy(out, in, sizeof(EVP_CIPHER_CTX));
58-
59-
#if !defined(OPENSSL_NO_ENGINE)
60-
if (in->engine) ENGINE_add(out->engine);
61-
if (in->cipher_data) {
62-
out->cipher_data = OPENSSL_malloc(in->cipher->ctx_size);
63-
memcpy(out->cipher_data, in->cipher_data, in->cipher->ctx_size);
64-
}
65-
#endif
66-
67-
return 1;
68-
}
69-
#endif
70-
71-
#if !defined(OPENSSL_NO_HMAC)
72-
#if !defined(HAVE_HMAC_CTX_COPY)
73-
int
74-
ossl_HMAC_CTX_copy(HMAC_CTX *out, HMAC_CTX *in)
75-
{
76-
if (!out || !in)
77-
return 0;
78-
79-
memcpy(out, in, sizeof(HMAC_CTX));
80-
81-
EVP_MD_CTX_copy(&out->md_ctx, &in->md_ctx);
82-
EVP_MD_CTX_copy(&out->i_ctx, &in->i_ctx);
83-
EVP_MD_CTX_copy(&out->o_ctx, &in->o_ctx);
84-
85-
return 1;
86-
}
87-
#endif /* HAVE_HMAC_CTX_COPY */
88-
#endif /* NO_HMAC */
89-
9023
/* added in 1.0.2 */
9124
#if !defined(OPENSSL_NO_EC)
9225
#if !defined(HAVE_EC_CURVE_NIST2NID)

ext/openssl/openssl_missing.h

Lines changed: 5 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -12,53 +12,6 @@
1212

1313
#include "ruby/config.h"
1414

15-
/* added in 0.9.8X */
16-
#if !defined(HAVE_EVP_CIPHER_CTX_NEW)
17-
EVP_CIPHER_CTX *ossl_EVP_CIPHER_CTX_new(void);
18-
# define EVP_CIPHER_CTX_new ossl_EVP_CIPHER_CTX_new
19-
#endif
20-
21-
#if !defined(HAVE_EVP_CIPHER_CTX_FREE)
22-
void ossl_EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *);
23-
# define EVP_CIPHER_CTX_free ossl_EVP_CIPHER_CTX_free
24-
#endif
25-
26-
#if !defined(HAVE_SSL_CTX_CLEAR_OPTIONS)
27-
# define SSL_CTX_clear_options(ctx, op) ((ctx)->options &= ~(op))
28-
#endif
29-
30-
/* added in 1.0.0 */
31-
#if !defined(HAVE_EVP_PKEY_BASE_ID)
32-
# define EVP_PKEY_base_id(pkey) EVP_PKEY_type((pkey)->type)
33-
#endif
34-
35-
#if !defined(HAVE_EVP_CIPHER_CTX_COPY)
36-
int ossl_EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *, const EVP_CIPHER_CTX *);
37-
# define EVP_CIPHER_CTX_copy ossl_EVP_CIPHER_CTX_copy
38-
#endif
39-
40-
#if !defined(HAVE_HMAC_CTX_COPY)
41-
int ossl_HMAC_CTX_copy(HMAC_CTX *out, HMAC_CTX *in);
42-
# define HMAC_CTX_copy ossl_HMAC_CTX_copy
43-
#endif
44-
45-
#if !defined(HAVE_X509_STORE_CTX_GET0_CURRENT_CRL)
46-
# define X509_STORE_CTX_get0_current_crl(x) ((x)->current_crl)
47-
#endif
48-
49-
#if !defined(HAVE_X509_STORE_SET_VERIFY_CB)
50-
# define X509_STORE_set_verify_cb X509_STORE_set_verify_cb_func
51-
#endif
52-
53-
#if !defined(HAVE_I2D_ASN1_SET_ANY)
54-
# define i2d_ASN1_SET_ANY(sk, x) i2d_ASN1_SET_OF_ASN1_TYPE((sk), (x), \
55-
i2d_ASN1_TYPE, V_ASN1_SET, V_ASN1_UNIVERSAL, 0)
56-
#endif
57-
58-
#if !defined(HAVE_EVP_PKEY_GET0)
59-
# define EVP_PKEY_get0(pk) (pk->pkey.ptr)
60-
#endif
61-
6215
/* added in 1.0.2 */
6316
#if !defined(OPENSSL_NO_EC)
6417
#if !defined(HAVE_EC_CURVE_NIST2NID)
@@ -245,7 +198,7 @@ IMPL_PKEY_GETTER(EC_KEY, ec)
245198
#undef IMPL_KEY_ACCESSOR3
246199
#endif /* HAVE_OPAQUE_OPENSSL */
247200

248-
#if defined(HAVE_AUTHENTICATED_ENCRYPTION) && !defined(EVP_CTRL_AEAD_GET_TAG)
201+
#if !defined(EVP_CTRL_AEAD_GET_TAG)
249202
# define EVP_CTRL_AEAD_GET_TAG EVP_CTRL_GCM_GET_TAG
250203
# define EVP_CTRL_AEAD_SET_TAG EVP_CTRL_GCM_SET_TAG
251204
# define EVP_CTRL_AEAD_SET_IVLEN EVP_CTRL_GCM_SET_IVLEN
@@ -256,6 +209,10 @@ IMPL_PKEY_GETTER(EC_KEY, ec)
256209
# define X509_get0_notAfter(x) X509_get_notAfter(x)
257210
# define X509_CRL_get0_lastUpdate(x) X509_CRL_get_lastUpdate(x)
258211
# define X509_CRL_get0_nextUpdate(x) X509_CRL_get_nextUpdate(x)
212+
# define X509_set1_notBefore(x, t) X509_set_notBefore(x, t)
213+
# define X509_set1_notAfter(x, t) X509_set_notAfter(x, t)
214+
# define X509_CRL_set1_lastUpdate(x, t) X509_CRL_set_lastUpdate(x, t)
215+
# define X509_CRL_set1_nextUpdate(x, t) X509_CRL_set_nextUpdate(x, t)
259216
#endif
260217

261218
#if !defined(HAVE_SSL_SESSION_GET_PROTOCOL_VERSION)

0 commit comments

Comments
 (0)