httpi 4.0.6 → 4.1.0
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/CHANGELOG.md +10 -0
- data/lib/httpi/adapter/em_http.rb +54 -2
- data/lib/httpi/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9903ec377c51dd8f43ebd602b1b155b06087a945ed4112ad04ae8ea3c7d04f0f
|
|
4
|
+
data.tar.gz: 14184705961d63a771ccb0f3af66cc1d55f6a5d5b534c087aaa5737c35837191
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 29154a3c7529c790f4ba5edc2bcec1c061725e1a9d519df479659bb989630ad8366e89974c49138520af9ac28c38a1c3ab3668fb5d7756ca96ae27e78ce443b1
|
|
7
|
+
data.tar.gz: cb6a0d3324c61d91ffb63ed32f5a5ddaec934dd28d02da19d6a32cf3d17c3855cfec8911f72122d720415d5da42968c794598d4b0271e979d43c093bbd659d89
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
* Add your changelog entry here
|
|
4
4
|
|
|
5
|
+
### 4.1.0 (2026-11-23)
|
|
6
|
+
|
|
7
|
+
#### Security
|
|
8
|
+
|
|
9
|
+
* The `:em_http` adapter no longer sends HTTPS requests without certificate verification ([GHSA-5f96-p49v-qh87](https://github.com/savonrb/httpi/security/advisories/GHSA-5f96-p49v-qh87)). It never applied the default `verify_mode` of `:peer`, so it accepted any server certificate and a network attacker could read and change the traffic, including Basic auth credentials. em-http-request cannot verify certificates reliably, so HTTPS requests through this adapter now raise `HTTPI::NotSupportedError` before anything is sent. **This breaks HTTPS through `:em_http`**, which is why it ships in a minor release. Switch to another adapter, such as `:net_http`, to keep verified HTTPS. Setting `verify_mode` to `:none` sends the request unverified, as an explicit choice. Thanks to @oss-security-shopify for securely disclosing this.
|
|
10
|
+
|
|
11
|
+
#### Deprecated
|
|
12
|
+
|
|
13
|
+
* The `:em_http` adapter is deprecated. Use another adapter, such as `:net_http`. em-http-request and eventmachine are no longer maintained, and eventmachine does not build on Ruby 4.1. Using the adapter prints a warning once per process.
|
|
14
|
+
|
|
5
15
|
### 4.0.6 (2026-10-29)
|
|
6
16
|
|
|
7
17
|
* Republish the 4.0.5 changes as 4.0.6. The 4.0.5 gem never reached RubyGems, as its push workflow failed before the push step. The 4.0.5 tag is protected, so a new version carries the same gem code.
|
|
@@ -6,8 +6,8 @@ module HTTPI
|
|
|
6
6
|
# An HTTPI adapter for `EventMachine::HttpRequest`. Due to limitations of
|
|
7
7
|
# the em-httprequest library, not all features are supported. In particular,
|
|
8
8
|
#
|
|
9
|
+
# * TLS certificate verification (HTTPS requires verify_mode :none),
|
|
9
10
|
# * CA files,
|
|
10
|
-
# * certificate verification modes other than "none" and "peer,"
|
|
11
11
|
# * NTLM authentication,
|
|
12
12
|
# * digest authentication, and
|
|
13
13
|
# * password-protected certificate keys
|
|
@@ -26,10 +26,33 @@ module HTTPI
|
|
|
26
26
|
# * multi-request
|
|
27
27
|
#
|
|
28
28
|
# are supported by em-httprequest but not HTTPI.
|
|
29
|
+
#
|
|
30
|
+
# @deprecated em-http-request and eventmachine are no longer maintained.
|
|
31
|
+
# Use another adapter, such as +:net_http+.
|
|
29
32
|
class EmHttpRequest < Base
|
|
30
33
|
register :em_http, deps: %w[em-synchrony em-synchrony/em-http em-http]
|
|
31
34
|
|
|
35
|
+
DEPRECATION_WARNING = "The em_http adapter is deprecated. " \
|
|
36
|
+
"em-http-request and eventmachine are no longer maintained, and eventmachine " \
|
|
37
|
+
"does not build on Ruby 4.1. Use another adapter, such as :net_http."
|
|
38
|
+
|
|
39
|
+
TLS_VERIFICATION_ERROR = "EM-HTTP-Request cannot verify TLS certificates. " \
|
|
40
|
+
"Use another adapter, or set verify_mode to :none to skip verification"
|
|
41
|
+
|
|
42
|
+
# Prints the deprecation warning once per process, so an application that
|
|
43
|
+
# sends many requests is told without its logs being flooded.
|
|
44
|
+
#
|
|
45
|
+
# @return [void]
|
|
46
|
+
# @api private
|
|
47
|
+
def self.warn_deprecation
|
|
48
|
+
return if @deprecation_warned
|
|
49
|
+
|
|
50
|
+
@deprecation_warned = true
|
|
51
|
+
warn DEPRECATION_WARNING
|
|
52
|
+
end
|
|
53
|
+
|
|
32
54
|
def initialize(request)
|
|
55
|
+
self.class.warn_deprecation
|
|
33
56
|
@request = request
|
|
34
57
|
@client = EventMachine::HttpRequest.new build_request_url(request.url), connection_options
|
|
35
58
|
end
|
|
@@ -54,10 +77,12 @@ module HTTPI
|
|
|
54
77
|
options = client_options
|
|
55
78
|
setup_http_auth(options) if @request.auth.http?
|
|
56
79
|
|
|
57
|
-
if
|
|
80
|
+
if unsupported_ssl_options?
|
|
58
81
|
raise NotSupportedError, "EM-HTTP-Request does not support SSL client auth"
|
|
59
82
|
end
|
|
60
83
|
|
|
84
|
+
raise NotSupportedError, TLS_VERIFICATION_ERROR if unverifiable_https?
|
|
85
|
+
|
|
61
86
|
if @request.on_body
|
|
62
87
|
raise NotSupportedError, "EM-HTTP-Request does not support response streaming"
|
|
63
88
|
end
|
|
@@ -74,10 +99,37 @@ module HTTPI
|
|
|
74
99
|
options[:connect_timeout] = @request.open_timeout if @request.open_timeout
|
|
75
100
|
|
|
76
101
|
options[:proxy] = proxy_options if @request.proxy
|
|
102
|
+
options[:tls] = {verify_peer: false} if @request.ssl?
|
|
77
103
|
|
|
78
104
|
options
|
|
79
105
|
end
|
|
80
106
|
|
|
107
|
+
# Checks for ssl settings this adapter cannot apply. A +verify_mode+ of
|
|
108
|
+
# +:none+ is the only one it honors, so anything else must raise instead
|
|
109
|
+
# of being ignored. A client certificate that cannot be read still counts
|
|
110
|
+
# as configured.
|
|
111
|
+
#
|
|
112
|
+
# @return [Boolean] true when the request sets an unsupported ssl option
|
|
113
|
+
def unsupported_ssl_options?
|
|
114
|
+
return false unless @request.auth.ssl?
|
|
115
|
+
|
|
116
|
+
ssl = @request.auth.ssl
|
|
117
|
+
!!(ssl.verify_mode != :none || ssl.ca_cert_file || ssl.ciphers || (ssl.cert && ssl.cert_key))
|
|
118
|
+
rescue TypeError, Errno::ENOENT
|
|
119
|
+
true
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# Checks whether an HTTPS request expects certificate verification.
|
|
123
|
+
# em-http-request cannot verify certificates reliably: it raises from
|
|
124
|
+
# inside reactor callbacks and checks the hostname against a proxy
|
|
125
|
+
# instead of the target. The adapter refuses these requests rather than
|
|
126
|
+
# send them unverified.
|
|
127
|
+
#
|
|
128
|
+
# @return [Boolean] true for HTTPS unless verify_mode is +:none+
|
|
129
|
+
def unverifiable_https?
|
|
130
|
+
@request.ssl? && @request.auth.ssl.verify_mode != :none
|
|
131
|
+
end
|
|
132
|
+
|
|
81
133
|
def client_options
|
|
82
134
|
{
|
|
83
135
|
query: @request.url.query,
|
data/lib/httpi/version.rb
CHANGED