No way to set `SSL_OP_IGNORE_UNEXPECTED_EOF` for ::HTTPClient, but Google services don't send `close_notify`
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
Direzione di ricerca
Inizia leggendo la configurazione SSL di HTTPClient in lib/httpclient.rb e lib/httpclient/ssl_config.rb, poi segui BaseService#new_client e Google::Apis::ClientOptions. Confronta il campo ssl_options proposto con l'hook alternativo di Faraday. Il lavoro è completato quando i chiamanti possono personalizzare le opzioni SSL dell'HTTPClient di BaseService, incluso SSL_OP_IGNORE_UNEXPECTED_EOF per le richieste Google API.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
- We want to set
SSL_OP_IGNORE_UNEXPECTED_EOFto deal with Google server TLS implementation ::HTTPClientprovides no way to do that, not even through global settings- Monkeypatching
BaseService#new_clientseems like the only path forward
Background
My company—using Openssl 3—is seeing frequent SSL errors while using this library to interact with Google services that look like SSL_read: unexpected eof while reading. Specific services we've seen this from in the last few days are Bigquery and Storage.
We noticed that the public HTTPS load balancer service (https://cloud.google.com/load-balancing/docs/https) is documented to not send a close_notify, so we feel like it's pretty likely that at least some Google APIs also don't do this, and that's why we're observing this behavior.
HTTP clients can protect against truncation attacks using Content-Length header, so we're comfortable using the SSL_OP_IGNORE_UNEXPECTED_EOF option to ignore these unexpected EOFs for Google services.
Problem
However, there is no way we can see to actually set this option on the SSL sockets created by this library. It uses ::HTTPClient, which sets some default SSL options (https://github.com/nahi/httpclient/blob/master/lib/httpclient.rb#L446 --> https://github.com/nahi/httpclient/blob/master/lib/httpclient/ssl_config.rb#L162).
Ideally we'd be able to set SSL_OP_IGNORE_UNEXPECTED_EOF specifically when making requests to Google APIs, but even if we were comfortable always having it set, we still can't: ::HTTPClient doesn't check OpenSSL::SSL::SSLContext::DEFAULT_PARAMS or provide some other way to set SSL options globally.
Proposed fix
Give users of the library a way to further customize the SSL options used by ::HTTPClient instance used by BaseService. Some potential ideas:
- most direct: add a nilable
ssl_optionsInteger toGoogle::Apis::ClientOptions, and inBaseServer#new_clientcheck if its set and use it if so - use faraday: https://github.com/googleapis/google-api-ruby-client/issues/2348 and add a hook to inject custom faraday middleware
Our workaround
In the meantime, we're probably going to monkeypatch BaseService#new_client to edit the SSL configuration. This will be brittle to library changes and hard to test (as we end up mocking out google services at higher level in most of our tests). We'd love any other ideas / or if there's some other way we're missing to set this option!
- Lingua principale
- Ruby
- Stelle
- 2.9k
- Fork
- 888
- Merge medio
- 8m
- PR unite (30g)
- 241
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di googleapis/google-api-ruby-client
-
Please Drop ruby 3.2 support Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
googleapis/google-api-ruby-client#28001 · 5 reazioni ·
-
googleapis/google-api-ruby-client#27757 · 1 assegnatario ·
-
googleapis/google-api-ruby-client#27758 · 1 assegnatario ·
-
googleapis/google-api-ruby-client#27759 · 1 assegnatario ·
-
api: storage type: feature request
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
googleapis/google-api-ruby-client#27339 ·
Tutte le issue di googleapis/google-api-ruby-client
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
hanami/hanami-cli#449 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
resque/resque-scheduler#826 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100