openssl 2.2.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +33 -45
  3. data/History.md +260 -0
  4. data/ext/openssl/extconf.rb +85 -72
  5. data/ext/openssl/openssl_missing.c +0 -66
  6. data/ext/openssl/openssl_missing.h +26 -45
  7. data/ext/openssl/ossl.c +67 -47
  8. data/ext/openssl/ossl.h +26 -6
  9. data/ext/openssl/ossl_asn1.c +26 -13
  10. data/ext/openssl/ossl_bn.c +278 -142
  11. data/ext/openssl/ossl_bn.h +2 -1
  12. data/ext/openssl/ossl_cipher.c +12 -13
  13. data/ext/openssl/ossl_config.c +412 -41
  14. data/ext/openssl/ossl_config.h +4 -7
  15. data/ext/openssl/ossl_digest.c +15 -11
  16. data/ext/openssl/ossl_engine.c +16 -15
  17. data/ext/openssl/ossl_hmac.c +56 -135
  18. data/ext/openssl/ossl_kdf.c +11 -3
  19. data/ext/openssl/ossl_ocsp.c +5 -53
  20. data/ext/openssl/ossl_pkcs12.c +21 -3
  21. data/ext/openssl/ossl_pkcs7.c +42 -59
  22. data/ext/openssl/ossl_pkey.c +1142 -191
  23. data/ext/openssl/ossl_pkey.h +36 -73
  24. data/ext/openssl/ossl_pkey_dh.c +130 -340
  25. data/ext/openssl/ossl_pkey_dsa.c +100 -405
  26. data/ext/openssl/ossl_pkey_ec.c +163 -335
  27. data/ext/openssl/ossl_pkey_rsa.c +106 -493
  28. data/ext/openssl/ossl_ssl.c +529 -421
  29. data/ext/openssl/ossl_ssl_session.c +28 -29
  30. data/ext/openssl/ossl_ts.c +64 -39
  31. data/ext/openssl/ossl_x509.c +0 -6
  32. data/ext/openssl/ossl_x509cert.c +167 -11
  33. data/ext/openssl/ossl_x509crl.c +13 -10
  34. data/ext/openssl/ossl_x509ext.c +1 -2
  35. data/ext/openssl/ossl_x509name.c +9 -2
  36. data/ext/openssl/ossl_x509req.c +13 -10
  37. data/ext/openssl/ossl_x509revoked.c +3 -3
  38. data/ext/openssl/ossl_x509store.c +193 -90
  39. data/lib/openssl/buffering.rb +10 -1
  40. data/lib/openssl/hmac.rb +65 -0
  41. data/lib/openssl/pkey.rb +429 -0
  42. data/lib/openssl/ssl.rb +13 -8
  43. data/lib/openssl/version.rb +1 -1
  44. data/lib/openssl/x509.rb +22 -0
  45. data/lib/openssl.rb +0 -1
  46. metadata +8 -66
  47. data/ext/openssl/ruby_missing.h +0 -24
  48. data/lib/openssl/config.rb +0 -501
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6f52e266d6038d1d7173a58d9ad72207e7d492da086ef0ecf9484a8b1cac5156
4
- data.tar.gz: ca3211e0c3887311a9d0ac997c864e0cdd54fc0c7510d04c2497c9c99b97fd0c
3
+ metadata.gz: 239c530562472710697b8da573b8aa64b477c02f5895907220e83e9f09c88fec
4
+ data.tar.gz: 62f2d04df3f693b995bf29be9d299c9f916f44a82b5bc5df60e9f46a748990d8
5
5
  SHA512:
6
- metadata.gz: b20ff54093b47c1d1da2f90a41ee1787bcd6a3e14c26f86f4c117d5ec6703364c73df226da5bf357ec6440770b639dd92575e468caeaf38fd8815ef52fb9864f
7
- data.tar.gz: 6f64e438c1cc74cea40674a4d3d5926ecc3ea4a0701dd02514f990fcbcb8c525a364789f832ac649fe65e557522a9df983e5beca5f3476b3ec29f7a82b15f071
6
+ metadata.gz: 05f891730a9dea150a2cecedb8decbf7f7dbb500cc825226a635fce8ca195a2dbf036de38dbdb7462cbb18e2e3c8aca337c1e1d9d021a94bbc444312dcf26568
7
+ data.tar.gz: 4cff09ce02fc107422829ca552c97cf912f2b5f129c87e37137b153fd2c09d9a231493af7ce32f391c32828b3ffc64bf905adf6a1e3fad943e78ca81048a4f96
data/CONTRIBUTING.md CHANGED
@@ -12,16 +12,17 @@ If you think you found a bug, file a ticket on GitHub. Please DO NOT report
12
12
  security issues here, there is a separate procedure which is described on
13
13
  ["Security at ruby-lang.org"](https://www.ruby-lang.org/en/security/).
14
14
 
15
- When reporting a bug, please make sure you include:
16
- * Ruby version
17
- * OpenSSL gem version
18
- * OpenSSL library version
19
- * A sample file that illustrates the problem or link to the repository or
15
+ When reporting a bug, please make sure you include:
16
+
17
+ * Ruby version (`ruby -v`)
18
+ * `openssl` gem version (`gem list openssl` and `OpenSSL::VERSION`)
19
+ * OpenSSL library version (`OpenSSL::OPENSSL_VERSION`)
20
+ * A sample file that illustrates the problem or link to the repository or
20
21
  gem that is associated with the bug.
21
22
 
22
23
  There are a number of unresolved issues and feature requests for openssl that
23
24
  need review. Before submitting a new ticket, it is recommended to check
24
- [known issues] and [bugs.ruby-lang.org], the previous issue tracker.
25
+ [known issues].
25
26
 
26
27
  ## Submitting patches
27
28
 
@@ -34,62 +35,50 @@ Make sure that your branch does:
34
35
  * Have good commit messages
35
36
  * Follow Ruby's coding style ([DeveloperHowTo])
36
37
  * Pass the test suite successfully (see "Testing")
37
- * Add an entry to [History.md] if necessary
38
38
 
39
39
  ## Testing
40
40
 
41
41
  We have a test suite!
42
42
 
43
43
  Test cases are located under the
44
- [`test/`](https://github.com/ruby/openssl/tree/master/test) directory.
44
+ [`test/openssl`](https://github.com/ruby/openssl/tree/master/test/openssl)
45
+ directory.
45
46
 
46
47
  You can run it with the following three commands:
47
48
 
48
49
  ```
49
- $ rake install_dependencies # installs rake-compiler, test-unit, ...
50
- $ rake compile
51
- $ rake test
50
+ $ bundle install # installs rake-compiler, test-unit, ...
51
+ $ bundle exec rake compile
52
+ $ bundle exec rake test
52
53
  ```
53
54
 
54
- ### Docker
55
-
56
- You can also use Docker Compose to run tests. It can be used to check that your
57
- changes work correctly with various supported versions of Ruby and OpenSSL.
58
-
59
- First, you need to install [Docker](https://www.docker.com/products/docker) and
60
- [Docker Compose](https://www.docker.com/products/docker-compose) on your
61
- computer.
55
+ ### With different versions of OpenSSL
62
56
 
63
- If you're on MacOS or Windows, we recommended to use the official [Docker
64
- Toolbox](https://www.docker.com/products/docker-toolbox). On Linux, follow the
65
- instructions for your package manager. For further information, please check
66
- the [official documentation](https://docs.docker.com/).
57
+ Ruby OpenSSL supports various versions of OpenSSL library. The test suite needs
58
+ to pass on all supported combinations.
67
59
 
68
- Once you have Docker and Docker Compose, running the following commands will
69
- build the container and execute the openssl tests. In this example, we will use
70
- Ruby version 2.3 with OpenSSL version 1.0.2.
60
+ Similarly to when installing `openssl` gem via the `gem` command,
61
+ you can pass a `--with-openssl-dir` argument to `rake compile`
62
+ to specify the OpenSSL library to build against.
71
63
 
72
64
  ```
73
- $ docker-compose build
74
- $ export RUBY_VERSION=ruby-2.3
75
- $ export OPENSSL_VERSION=openssl-1.0.2
76
- $ docker-compose run test
77
-
78
- # You may want an interactive shell for dubugging
79
- $ docker-compose run debug
65
+ $ ( curl -OL https://ftp.openssl.org/source/openssl-3.0.1.tar.gz &&
66
+ tar xf openssl-3.0.1.tar.gz &&
67
+ cd openssl-3.0.1 &&
68
+ ./config --prefix=$HOME/.openssl/openssl-3.0.1 --libdir=lib &&
69
+ make -j4 &&
70
+ make install )
71
+
72
+ $ # in Ruby/OpenSSL's source directory
73
+ $ bundle exec rake clean
74
+ $ bundle exec rake compile -- --with-openssl-dir=$HOME/.openssl/openssl-3.0.1
75
+ $ bundle exec rake test
80
76
  ```
81
77
 
82
- All possible values for `RUBY_VERSION` and `OPENSSL_VERSION` can be found in
83
- [`test.yml`](https://github.com/ruby/openssl/tree/master/.github/workflows/test.yml).
84
-
85
- **NOTE**: these commands must be run from the openssl repository root, in order
86
- to use the
87
- [`docker-compose.yml`](https://github.com/ruby/openssl/blob/master/docker-compose.yml)
88
- file we have provided.
89
-
90
- This Docker image is built using the
91
- [Dockerfile](https://github.com/ruby/openssl/tree/master/tool/ruby-openssl-docker)
92
- provided in the repository.
78
+ The GitHub Actions workflow file
79
+ [`test.yml`](https://github.com/ruby/openssl/tree/master/.github/workflows/test.yml)
80
+ contains useful information for building OpenSSL/LibreSSL and testing against
81
+ them.
93
82
 
94
83
 
95
84
  ## Relation with Ruby source tree
@@ -124,7 +113,6 @@ _Thanks for your contributions!_
124
113
 
125
114
  [GitHub]: https://github.com/ruby/openssl
126
115
  [known issues]: https://github.com/ruby/openssl/issues
127
- [bugs.ruby-lang.org]: https://bugs.ruby-lang.org/issues?utf8=%E2%9C%93&set_filter=1&f%5B%5D=status_id&op%5Bstatus_id%5D=o&f%5B%5D=assigned_to_id&op%5Bassigned_to_id%5D=%3D&v%5Bassigned_to_id%5D%5B%5D=7150&f%5B%5D=&c%5B%5D=project&c%5B%5D=tracker&c%5B%5D=status&c%5B%5D=subject&c%5B%5D=assigned_to&c%5B%5D=updated_on&group_by=&t%5B%5D=
128
116
  [DeveloperHowTo]: https://bugs.ruby-lang.org/projects/ruby/wiki/DeveloperHowto
129
117
  [HackerOne]: https://hackerone.com/ruby
130
118
  [Security]: https://www.ruby-lang.org/en/security/
data/History.md CHANGED
@@ -1,3 +1,217 @@
1
+ Version 3.1.0
2
+ =============
3
+
4
+ Ruby/OpenSSL 3.1 will be maintained for the lifetime of Ruby 3.2.
5
+
6
+ Merged bug fixes in 2.2.3 and 3.0.2. Among the new features and changes are:
7
+
8
+ Notable changes
9
+ ---------------
10
+
11
+ * Add `OpenSSL::SSL::SSLContext#ciphersuites=` to allow setting TLS 1.3 cipher
12
+ suites.
13
+ [[GitHub #493]](https://github.com/ruby/openssl/pull/493)
14
+ * Add `OpenSSL::SSL::SSLSocket#export_keying_material` for exporting keying
15
+ material of the session, as defined in RFC 5705.
16
+ [[GitHub #530]](https://github.com/ruby/openssl/pull/530)
17
+ * Add `OpenSSL::SSL::SSLContext#keylog_cb=` for setting the TLS key logging
18
+ callback, which is useful for supporting NSS's SSLKEYLOGFILE debugging output.
19
+ [[GitHub #536]](https://github.com/ruby/openssl/pull/536)
20
+ * Remove the default digest algorithm from `OpenSSL::OCSP::BasicResponse#sign`
21
+ and `OpenSSL::OCSP::Request#sign`. Omitting the 5th parameter of these
22
+ methods used to be equivalent of specifying SHA-1. This default value is now
23
+ removed and we will let the underlying OpenSSL library decide instead.
24
+ [[GitHub #507]](https://github.com/ruby/openssl/pull/507)
25
+ * Add `OpenSSL::BN#mod_sqrt`.
26
+ [[GitHub #553]](https://github.com/ruby/openssl/pull/553)
27
+ * Allow calling `OpenSSL::Cipher#update` with an empty string. This was
28
+ prohibited to workaround an ancient bug in OpenSSL.
29
+ [[GitHub #568]](https://github.com/ruby/openssl/pull/568)
30
+ * Fix build on platforms without socket support, such as WASI. `OpenSSL::SSL`
31
+ will not be defined if OpenSSL is compiled with `OPENSSL_NO_SOCK`.
32
+ [[GitHub #558]](https://github.com/ruby/openssl/pull/558)
33
+ * Improve support for recent LibreSSL versions. This includes HKDF support in
34
+ LibreSSL 3.6 and Ed25519 support in LibreSSL 3.7.
35
+
36
+
37
+ Version 3.0.2
38
+ =============
39
+
40
+ Merged changes in 2.2.3. Additionally, the following issues are fixed by this
41
+ release.
42
+
43
+ Bug fixes
44
+ ---------
45
+
46
+ * Fix OpenSSL::PKey::EC#check_key not working correctly on OpenSSL 3.0.
47
+ [[GitHub #563]](https://github.com/ruby/openssl/issues/563)
48
+ [[GitHub #580]](https://github.com/ruby/openssl/pull/580)
49
+
50
+
51
+ Version 3.0.1
52
+ =============
53
+
54
+ Merged changes in 2.1.4 and 2.2.2. Additionally, the following issues are fixed
55
+ by this release.
56
+
57
+ Bug fixes
58
+ ---------
59
+
60
+ * Add missing type check in OpenSSL::PKey::PKey#sign's optional parameters.
61
+ [[GitHub #531]](https://github.com/ruby/openssl/pull/531)
62
+ * Work around OpenSSL 3.0's HMAC issues with a zero-length key.
63
+ [[GitHub #538]](https://github.com/ruby/openssl/pull/538)
64
+ * Fix a regression in OpenSSL::PKey::DSA.generate's default of 'q' size.
65
+ [[GitHub #483]](https://github.com/ruby/openssl/issues/483)
66
+ [[GitHub #539]](https://github.com/ruby/openssl/pull/539)
67
+ * Restore OpenSSL::PKey.read's ability to decode "openssl ecparam -genkey"
68
+ output when linked against OpenSSL 3.0.
69
+ [[GitHub #535]](https://github.com/ruby/openssl/pull/535)
70
+ [[GitHub #540]](https://github.com/ruby/openssl/pull/540)
71
+ * Restore error checks in OpenSSL::PKey::EC#{to_der,to_pem}.
72
+ [[GitHub #541]](https://github.com/ruby/openssl/pull/541)
73
+
74
+
75
+ Version 3.0.0
76
+ =============
77
+
78
+ Compatibility notes
79
+ -------------------
80
+
81
+ * OpenSSL 1.0.1 and Ruby 2.3-2.5 are no longer supported.
82
+ [[GitHub #396]](https://github.com/ruby/openssl/pull/396)
83
+ [[GitHub #466]](https://github.com/ruby/openssl/pull/466)
84
+
85
+ * OpenSSL 3.0 support is added. It is the first major version bump from OpenSSL
86
+ 1.1 and contains incompatible changes that affect Ruby/OpenSSL.
87
+ Note that OpenSSL 3.0 support is preliminary and not all features are
88
+ currently available:
89
+ [[GitHub #369]](https://github.com/ruby/openssl/issues/369)
90
+
91
+ - Deprecate the ability to modify `OpenSSL::PKey::PKey` instances. OpenSSL 3.0
92
+ made EVP_PKEY structure immutable, and hence the following methods are not
93
+ available when Ruby/OpenSSL is linked against OpenSSL 3.0.
94
+ [[GitHub #480]](https://github.com/ruby/openssl/pull/480)
95
+
96
+ - `OpenSSL::PKey::RSA#set_key`, `#set_factors`, `#set_crt_params`
97
+ - `OpenSSL::PKey::DSA#set_pqg`, `#set_key`
98
+ - `OpenSSL::PKey::DH#set_pqg`, `#set_key`, `#generate_key!`
99
+ - `OpenSSL::PKey::EC#private_key=`, `#public_key=`, `#group=`, `#generate_key!`
100
+
101
+ - Deprecate `OpenSSL::Engine`. The ENGINE API has been deprecated in OpenSSL 3.0
102
+ in favor of the new "provider" concept and will be removed in a future
103
+ version.
104
+ [[GitHub #481]](https://github.com/ruby/openssl/pull/481)
105
+
106
+ * `OpenSSL::SSL::SSLContext#tmp_ecdh_callback` has been removed. It has been
107
+ deprecated since v2.0.0 because it is incompatible with modern OpenSSL
108
+ versions.
109
+ [[GitHub #394]](https://github.com/ruby/openssl/pull/394)
110
+
111
+ * `OpenSSL::SSL::SSLSocket#read` and `#write` now raise `OpenSSL::SSL::SSLError`
112
+ if called before a TLS connection is established. Historically, they
113
+ read/wrote unencrypted data to the underlying socket directly in that case.
114
+ [[GitHub #9]](https://github.com/ruby/openssl/issues/9)
115
+ [[GitHub #469]](https://github.com/ruby/openssl/pull/469)
116
+
117
+
118
+ Notable changes
119
+ ---------------
120
+
121
+ * Enhance OpenSSL::PKey's common interface.
122
+ [[GitHub #370]](https://github.com/ruby/openssl/issues/370)
123
+
124
+ - Key deserialization: Enhance `OpenSSL::PKey.read` to handle PEM encoding of
125
+ DH parameters, which used to be only deserialized by `OpenSSL::PKey::DH.new`.
126
+ [[GitHub #328]](https://github.com/ruby/openssl/issues/328)
127
+ - Key generation: Add `OpenSSL::PKey.generate_parameters` and
128
+ `OpenSSL::PKey.generate_key`.
129
+ [[GitHub #329]](https://github.com/ruby/openssl/issues/329)
130
+ - Public key signing: Enhance `OpenSSL::PKey::PKey#sign` and `#verify` to use
131
+ the new EVP_DigestSign() family to enable PureEdDSA support on OpenSSL 1.1.1
132
+ or later. They also now take optional algorithm-specific parameters for more
133
+ control.
134
+ [[GitHub #329]](https://github.com/ruby/openssl/issues/329)
135
+ - Low-level public key signing and verification: Add
136
+ `OpenSSL::PKey::PKey#sign_raw`, `#verify_raw`, and `#verify_recover`.
137
+ [[GitHub #382]](https://github.com/ruby/openssl/issues/382)
138
+ - Public key encryption: Add `OpenSSL::PKey::PKey#encrypt` and `#decrypt`.
139
+ [[GitHub #382]](https://github.com/ruby/openssl/issues/382)
140
+ - Key agreement: Add `OpenSSL::PKey::PKey#derive`.
141
+ [[GitHub #329]](https://github.com/ruby/openssl/issues/329)
142
+ - Key comparison: Add `OpenSSL::PKey::PKey#compare?` to conveniently check
143
+ that two keys have common parameters and a public key.
144
+ [[GitHub #383]](https://github.com/ruby/openssl/issues/383)
145
+
146
+ * Add `OpenSSL::BN#set_flags` and `#get_flags`. This can be used in combination
147
+ with `OpenSSL::BN::CONSTTIME` to force constant-time computation.
148
+ [[GitHub #417]](https://github.com/ruby/openssl/issues/417)
149
+
150
+ * Add `OpenSSL::BN#abs` to get the absolute value of the BIGNUM.
151
+ [[GitHub #430]](https://github.com/ruby/openssl/issues/430)
152
+
153
+ * Add `OpenSSL::SSL::SSLSocket#getbyte`.
154
+ [[GitHub #438]](https://github.com/ruby/openssl/issues/438)
155
+
156
+ * Add `OpenSSL::SSL::SSLContext#tmp_dh=`.
157
+ [[GitHub #459]](https://github.com/ruby/openssl/pull/459)
158
+
159
+ * Add `OpenSSL::X509::Certificate.load` to load a PEM-encoded and concatenated
160
+ list of X.509 certificates at once.
161
+ [[GitHub #441]](https://github.com/ruby/openssl/pull/441)
162
+
163
+ * Change `OpenSSL::X509::Certificate.new` to attempt to deserialize the given
164
+ string first as DER encoding first and then as PEM encoding to ensure the
165
+ round-trip consistency.
166
+ [[GitHub #442]](https://github.com/ruby/openssl/pull/442)
167
+
168
+ * Update various part of the code base to use the modern API. No breaking
169
+ changes are intended with this. This includes:
170
+
171
+ - `OpenSSL::HMAC` uses the EVP API.
172
+ [[GitHub #371]](https://github.com/ruby/openssl/issues/371)
173
+ - `OpenSSL::Config` uses native OpenSSL API to parse config files.
174
+ [[GitHub #342]](https://github.com/ruby/openssl/issues/342)
175
+
176
+
177
+ Version 2.2.3
178
+ =============
179
+
180
+ Bug fixes
181
+ ---------
182
+
183
+ * Fix serveral methods in OpenSSL::PKey::EC::Point attempting to raise an error
184
+ with an incorrect class, which would end up with a TypeError.
185
+ [[GitHub #570]](https://github.com/ruby/openssl/pull/570)
186
+ * Fix OpenSSL::PKey::EC::Point#eql? and OpenSSL::PKey::EC::Group#eql?
187
+ incorrectly treated OpenSSL's internal errors as "not equal".
188
+ [[GitHub #564]](https://github.com/ruby/openssl/pull/564)
189
+ * Fix build with LibreSSL 3.5 or later.
190
+
191
+
192
+ Version 2.2.2
193
+ =============
194
+
195
+ Merged changes in 2.1.4.
196
+
197
+
198
+ Version 2.2.1
199
+ =============
200
+
201
+ Merged changes in 2.1.3. Additionally, the following issues are fixed by this
202
+ release.
203
+
204
+ Bug fixes
205
+ ---------
206
+
207
+ * Fix crash in `OpenSSL::Timestamp::{Request,Response,TokenInfo}.new` when
208
+ invalid arguments are given.
209
+ [[GitHub #407]](https://github.com/ruby/openssl/pull/407)
210
+ * Fix `OpenSSL::Timestamp::Factory#create_timestamp` with LibreSSL on platforms
211
+ where `time_t` has a different size from `long`.
212
+ [[GitHub #454]](https://github.com/ruby/openssl/pull/454)
213
+
214
+
1
215
  Version 2.2.0
2
216
  =============
3
217
 
@@ -75,6 +289,52 @@ Notable changes
75
289
  [[GitHub #297]](https://github.com/ruby/openssl/pull/297)
76
290
 
77
291
 
292
+ Version 2.1.4
293
+ =============
294
+
295
+ Bug fixes
296
+ ---------
297
+
298
+ * Do not use pkg-config if --with-openssl-dir option is specified.
299
+ [[GitHub #486]](https://github.com/ruby/openssl/pull/486)
300
+
301
+
302
+ Version 2.1.3
303
+ =============
304
+
305
+ Bug fixes
306
+ ---------
307
+
308
+ * Fix deprecation warnings on Ruby 3.0.
309
+ * Add ".include" directive support in `OpenSSL::Config`.
310
+ [[GitHub #216]](https://github.com/ruby/openssl/pull/216)
311
+ * Fix handling of IPv6 address SANs.
312
+ [[GitHub #185]](https://github.com/ruby/openssl/pull/185)
313
+ * Hostname verification failure with `OpenSSL::SSL::SSLContext#verify_hostname=`
314
+ sets a proper error code.
315
+ [[GitHub #350]](https://github.com/ruby/openssl/pull/350)
316
+ * Fix crash with `OpenSSL::BN.new(nil, 2)`.
317
+ [[Bug #15760]](https://bugs.ruby-lang.org/issues/15760)
318
+ * `OpenSSL::SSL::SSLSocket#sys{read,write}` prevent internal string buffers from
319
+ being modified by another thread.
320
+ [[GitHub #453]](https://github.com/ruby/openssl/pull/453)
321
+ * Fix misuse of input record separator in `OpenSSL::Buffering` where it was
322
+ for output.
323
+ * Fix wrong integer casting in `OpenSSL::PKey::EC#dsa_verify_asn1`.
324
+ [[GitHub #460]](https://github.com/ruby/openssl/pull/460)
325
+ * `extconf.rb` explicitly checks that OpenSSL's version number is 1.0.1 or
326
+ newer but also less than 3.0. Ruby/OpenSSL v2.1.x and v2.2.x will not support
327
+ OpenSSL 3.0 API.
328
+ [[GitHub #458]](https://github.com/ruby/openssl/pull/458)
329
+ * Activate `digest` gem correctly. `digest` library could go into an
330
+ inconsistent state if there are multiple versions of `digest` is installed
331
+ and `openssl` is `require`d before `digest`.
332
+ [[GitHub #463]](https://github.com/ruby/openssl/pull/463)
333
+ * Fix GC.compact compatibility.
334
+ [[GitHub #464]](https://github.com/ruby/openssl/issues/464)
335
+ [[GitHub #465]](https://github.com/ruby/openssl/pull/465)
336
+
337
+
78
338
  Version 2.1.2
79
339
  =============
80
340
 
@@ -13,7 +13,7 @@
13
13
 
14
14
  require "mkmf"
15
15
 
16
- dir_config("openssl")
16
+ dir_config_given = dir_config("openssl").any?
17
17
  dir_config("kerberos")
18
18
 
19
19
  Logging::message "=== OpenSSL for Ruby configurator ===\n"
@@ -25,6 +25,9 @@ Logging::message "=== OpenSSL for Ruby configurator ===\n"
25
25
  if with_config("debug") or enable_config("debug")
26
26
  $defs.push("-DOSSL_DEBUG")
27
27
  end
28
+ $defs.push("-D""OPENSSL_SUPPRESS_DEPRECATED")
29
+
30
+ have_func("rb_io_maybe_wait(0, Qnil, Qnil, Qnil)", "ruby/io.h") # Ruby 3.1
28
31
 
29
32
  Logging::message "=== Checking for system dependent stuff... ===\n"
30
33
  have_library("nsl", "t_open")
@@ -33,9 +36,6 @@ if $mswin || $mingw
33
36
  have_library("ws2_32")
34
37
  end
35
38
 
36
- Logging::message "=== Checking for required stuff... ===\n"
37
- result = pkg_config("openssl") && have_header("openssl/ssl.h")
38
-
39
39
  if $mingw
40
40
  append_cflags '-D_FORTIFY_SOURCE=2'
41
41
  append_ldflags '-fstack-protector'
@@ -92,89 +92,102 @@ def find_openssl_library
92
92
  return false
93
93
  end
94
94
 
95
- unless result
96
- unless find_openssl_library
97
- Logging::message "=== Checking for required stuff failed. ===\n"
98
- Logging::message "Makefile wasn't created. Fix the errors above.\n"
99
- raise "OpenSSL library could not be found. You might want to use " \
100
- "--with-openssl-dir=<dir> option to specify the prefix where OpenSSL " \
101
- "is installed."
102
- end
95
+ Logging::message "=== Checking for required stuff... ===\n"
96
+ pkg_config_found = !dir_config_given && pkg_config("openssl") && have_header("openssl/ssl.h")
97
+
98
+ if !pkg_config_found && !find_openssl_library
99
+ Logging::message "=== Checking for required stuff failed. ===\n"
100
+ Logging::message "Makefile wasn't created. Fix the errors above.\n"
101
+ raise "OpenSSL library could not be found. You might want to use " \
102
+ "--with-openssl-dir=<dir> option to specify the prefix where OpenSSL " \
103
+ "is installed."
104
+ end
105
+
106
+ version_ok = if have_macro("LIBRESSL_VERSION_NUMBER", "openssl/opensslv.h")
107
+ is_libressl = true
108
+ checking_for("LibreSSL version >= 3.1.0") {
109
+ try_static_assert("LIBRESSL_VERSION_NUMBER >= 0x30100000L", "openssl/opensslv.h") }
110
+ else
111
+ checking_for("OpenSSL version >= 1.0.2") {
112
+ try_static_assert("OPENSSL_VERSION_NUMBER >= 0x10002000L", "openssl/opensslv.h") }
113
+ end
114
+ unless version_ok
115
+ raise "OpenSSL >= 1.0.2 or LibreSSL >= 3.1.0 is required"
103
116
  end
104
117
 
105
- unless checking_for("OpenSSL version is 1.0.1 or later") {
106
- try_static_assert("OPENSSL_VERSION_NUMBER >= 0x10001000L", "openssl/opensslv.h") }
107
- raise "OpenSSL >= 1.0.1 or LibreSSL is required"
118
+ # Prevent wincrypt.h from being included, which defines conflicting macro with openssl/x509.h
119
+ if is_libressl && ($mswin || $mingw)
120
+ $defs.push("-DNOCRYPT")
108
121
  end
109
122
 
110
123
  Logging::message "=== Checking for OpenSSL features... ===\n"
124
+ evp_h = "openssl/evp.h".freeze
125
+ x509_h = "openssl/x509.h".freeze
126
+ ts_h = "openssl/ts.h".freeze
127
+ ssl_h = "openssl/ssl.h".freeze
128
+
111
129
  # compile options
112
- have_func("RAND_egd")
130
+ have_func("RAND_egd()", "openssl/rand.h")
113
131
  engines = %w{dynamic 4758cca aep atalla chil
114
132
  cswift nuron sureware ubsec padlock capi gmp gost cryptodev}
115
133
  engines.each { |name|
116
134
  have_func("ENGINE_load_#{name}()", "openssl/engine.h")
117
135
  }
118
136
 
119
- if ($mswin || $mingw) && have_macro("LIBRESSL_VERSION_NUMBER", "openssl/opensslv.h")
120
- $defs.push("-DNOCRYPT")
121
- end
122
-
123
- # added in 1.0.2
124
- have_func("EC_curve_nist2nid")
125
- have_func("X509_REVOKED_dup")
126
- have_func("X509_STORE_CTX_get0_store")
127
- have_func("SSL_CTX_set_alpn_select_cb")
128
- have_func("SSL_CTX_set1_curves_list(NULL, NULL)", "openssl/ssl.h")
129
- have_func("SSL_CTX_set_ecdh_auto(NULL, 0)", "openssl/ssl.h")
130
- have_func("SSL_get_server_tmp_key(NULL, NULL)", "openssl/ssl.h")
131
- have_func("SSL_is_server")
132
-
133
137
  # added in 1.1.0
134
- if !have_struct_member("SSL", "ctx", "openssl/ssl.h") ||
135
- try_static_assert("LIBRESSL_VERSION_NUMBER >= 0x2070000fL", "openssl/opensslv.h")
138
+ if !have_struct_member("SSL", "ctx", "openssl/ssl.h") || is_libressl
136
139
  $defs.push("-DHAVE_OPAQUE_OPENSSL")
137
140
  end
138
- have_func("CRYPTO_lock") || $defs.push("-DHAVE_OPENSSL_110_THREADING_API")
139
- have_func("BN_GENCB_new")
140
- have_func("BN_GENCB_free")
141
- have_func("BN_GENCB_get_arg")
142
- have_func("EVP_MD_CTX_new")
143
- have_func("EVP_MD_CTX_free")
144
- have_func("HMAC_CTX_new")
145
- have_func("HMAC_CTX_free")
146
- have_func("X509_STORE_get_ex_data")
147
- have_func("X509_STORE_set_ex_data")
148
- have_func("X509_STORE_get_ex_new_index")
149
- have_func("X509_CRL_get0_signature")
150
- have_func("X509_REQ_get0_signature")
151
- have_func("X509_REVOKED_get0_serialNumber")
152
- have_func("X509_REVOKED_get0_revocationDate")
153
- have_func("X509_get0_tbs_sigalg")
154
- have_func("X509_STORE_CTX_get0_untrusted")
155
- have_func("X509_STORE_CTX_get0_cert")
156
- have_func("X509_STORE_CTX_get0_chain")
157
- have_func("OCSP_SINGLERESP_get0_id")
158
- have_func("SSL_CTX_get_ciphers")
159
- have_func("X509_up_ref")
160
- have_func("X509_CRL_up_ref")
161
- have_func("X509_STORE_up_ref")
162
- have_func("SSL_SESSION_up_ref")
163
- have_func("EVP_PKEY_up_ref")
164
- have_func("SSL_CTX_set_tmp_ecdh_callback(NULL, NULL)", "openssl/ssl.h") # removed
165
- have_func("SSL_CTX_set_min_proto_version(NULL, 0)", "openssl/ssl.h")
166
- have_func("SSL_CTX_get_security_level")
167
- have_func("X509_get0_notBefore")
168
- have_func("SSL_SESSION_get_protocol_version")
169
- have_func("TS_STATUS_INFO_get0_status")
170
- have_func("TS_STATUS_INFO_get0_text")
171
- have_func("TS_STATUS_INFO_get0_failure_info")
172
- have_func("TS_VERIFY_CTS_set_certs")
173
- have_func("TS_VERIFY_CTX_set_store")
174
- have_func("TS_VERIFY_CTX_add_flags")
175
- have_func("TS_RESP_CTX_set_time_cb")
176
- have_func("EVP_PBE_scrypt")
177
- have_func("SSL_CTX_set_post_handshake_auth")
141
+ have_func("EVP_MD_CTX_new()", evp_h)
142
+ have_func("EVP_MD_CTX_free(NULL)", evp_h)
143
+ have_func("EVP_MD_CTX_pkey_ctx(NULL)", evp_h)
144
+ have_func("X509_STORE_get_ex_data(NULL, 0)", x509_h)
145
+ have_func("X509_STORE_set_ex_data(NULL, 0, NULL)", x509_h)
146
+ have_func("X509_STORE_get_ex_new_index(0, NULL, NULL, NULL, NULL)", x509_h)
147
+ have_func("X509_CRL_get0_signature(NULL, NULL, NULL)", x509_h)
148
+ have_func("X509_REQ_get0_signature(NULL, NULL, NULL)", x509_h)
149
+ have_func("X509_REVOKED_get0_serialNumber(NULL)", x509_h)
150
+ have_func("X509_REVOKED_get0_revocationDate(NULL)", x509_h)
151
+ have_func("X509_get0_tbs_sigalg(NULL)", x509_h)
152
+ have_func("X509_STORE_CTX_get0_untrusted(NULL)", x509_h)
153
+ have_func("X509_STORE_CTX_get0_cert(NULL)", x509_h)
154
+ have_func("X509_STORE_CTX_get0_chain(NULL)", x509_h)
155
+ have_func("OCSP_SINGLERESP_get0_id(NULL)", "openssl/ocsp.h")
156
+ have_func("SSL_CTX_get_ciphers(NULL)", ssl_h)
157
+ have_func("X509_up_ref(NULL)", x509_h)
158
+ have_func("X509_CRL_up_ref(NULL)", x509_h)
159
+ have_func("X509_STORE_up_ref(NULL)", x509_h)
160
+ have_func("SSL_SESSION_up_ref(NULL)", ssl_h)
161
+ have_func("EVP_PKEY_up_ref(NULL)", evp_h)
162
+ have_func("SSL_CTX_set_min_proto_version(NULL, 0)", ssl_h)
163
+ have_func("SSL_CTX_get_security_level(NULL)", ssl_h)
164
+ have_func("X509_get0_notBefore(NULL)", x509_h)
165
+ have_func("SSL_SESSION_get_protocol_version(NULL)", ssl_h)
166
+ have_func("TS_STATUS_INFO_get0_status(NULL)", ts_h)
167
+ have_func("TS_STATUS_INFO_get0_text(NULL)", ts_h)
168
+ have_func("TS_STATUS_INFO_get0_failure_info(NULL)", ts_h)
169
+ have_func("TS_VERIFY_CTS_set_certs(NULL, NULL)", ts_h)
170
+ have_func("TS_VERIFY_CTX_set_store(NULL, NULL)", ts_h)
171
+ have_func("TS_VERIFY_CTX_add_flags(NULL, 0)", ts_h)
172
+ have_func("TS_RESP_CTX_set_time_cb(NULL, NULL, NULL)", ts_h)
173
+ have_func("EVP_PBE_scrypt(\"\", 0, (unsigned char *)\"\", 0, 0, 0, 0, 0, NULL, 0)", evp_h)
174
+ have_func("SSL_CTX_set_post_handshake_auth(NULL, 0)", ssl_h)
175
+
176
+ # added in 1.1.1
177
+ have_func("EVP_PKEY_check(NULL)", evp_h)
178
+ have_func("EVP_PKEY_new_raw_private_key(0, NULL, (unsigned char *)\"\", 0)", evp_h)
179
+ have_func("SSL_CTX_set_ciphersuites(NULL, \"\")", ssl_h)
180
+
181
+ # added in 3.0.0
182
+ have_func("SSL_set0_tmp_dh_pkey(NULL, NULL)", ssl_h)
183
+ have_func("ERR_get_error_all(NULL, NULL, NULL, NULL, NULL)", "openssl/err.h")
184
+ have_func("TS_VERIFY_CTX_set_certs(NULL, NULL)", ts_h)
185
+ have_func("SSL_CTX_load_verify_file(NULL, \"\")", ssl_h)
186
+ have_func("BN_check_prime(NULL, NULL, NULL)", "openssl/bn.h")
187
+ have_func("EVP_MD_CTX_get0_md(NULL)", evp_h)
188
+ have_func("EVP_MD_CTX_get_pkey_ctx(NULL)", evp_h)
189
+ have_func("EVP_PKEY_eq(NULL, NULL)", evp_h)
190
+ have_func("EVP_PKEY_dup(NULL)", evp_h)
178
191
 
179
192
  Logging::message "=== Checking done. ===\n"
180
193