Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSL connection failing due to optimisations in PR #134 #135

Closed
Andy-Bell opened this issue Mar 31, 2021 · 6 comments · Fixed by #139
Closed

SSL connection failing due to optimisations in PR #134 #135

Andy-Bell opened this issue Mar 31, 2021 · 6 comments · Fixed by #139

Comments

@Andy-Bell
Copy link

Hitting an issue with this library due to #134, I now cannot get the client to load an SSL connection.

Ruby version 2.7.2.p137
Clean build of ruby with openssl 1.1.1i on OSX
Here is a minimal reproduction of the issue:
https://github.com/Andy-Bell/mqtt-error-from-pr-134

Expected outcome:

  • MQTT client is created
  • I can then listen for new messages

Current outcome

  • Client hits an error and fails to create:
NoMethodError:
  undefined method `getbyte' for #<OpenSSL::SSL::SSLSocket:0x00007fc069f39298>
@njh
Copy link
Owner

njh commented Apr 15, 2021

Thanks for reporting this.

I am not sure if the best thing to do is:

  1. Just revert Improve Packet.read_byte performance #134
  2. Attempt to monkey-patch OpenSSL::SSL::SSLSocket, so that it support #getbyte

What do you think @tenderlove ?

@tenderlove
Copy link
Contributor

I think we should monkeypatch OpenSSL. If normal sockets support getbyte, and SSLSocket doesn't, then I think it's a bug in SSLSocket. I've sent a patch upstream. I'll try making a patch for ruby-mqtt, but I might need a day or two.

@njh
Copy link
Owner

njh commented Apr 16, 2021

@tenderlove fantastic! Thank you very much!

@Andy-Bell
Copy link
Author

Thanks both

@njh
Copy link
Owner

njh commented Sep 29, 2021

Hi @tenderlove. Do you think you might have time to create a patch for the lack of #getbyte in ruby-mqtt?

Would be good to make a new release of this gem.

tenderlove added a commit to tenderlove/ruby-mqtt that referenced this issue Sep 29, 2021
This backports the getbyte method which was added in this PR:

  ruby/openssl#438

We only add the method to SSLSocket if the method isn't already defined.
I was able to test this with the following program:

```ruby
require 'rubygems'
require 'mqtt'

client = MQTT::Client.connect(
  host: "test.mosquitto.org",
  port: 8883,
  ssl: true
)

client.get
```

Fixes njh#135
@tenderlove
Copy link
Contributor

@njh I'm so sorry. I totally forgot to do this. I've done it and sent a PR #139

🙇

tenderlove added a commit to tenderlove/ruby-mqtt that referenced this issue Sep 29, 2021
This backports the getbyte method which was added in this PR:

  ruby/openssl#438

We only add the method to SSLSocket if the method isn't already defined.
I was able to test this with the following program:

```ruby
require 'rubygems'
require 'mqtt'

client = MQTT::Client.connect(
  host: "test.mosquitto.org",
  port: 8883,
  ssl: true
)

client.get
```

Fixes njh#135
@njh njh mentioned this issue Jun 13, 2022
@njh njh closed this as completed in #139 Jun 15, 2022
njh pushed a commit that referenced this issue Jun 15, 2022
This backports the getbyte method which was added in this PR:

  ruby/openssl#438

We only add the method to SSLSocket if the method isn't already defined.
I was able to test this with the following program:

```ruby
require 'rubygems'
require 'mqtt'

client = MQTT::Client.connect(
  host: "test.mosquitto.org",
  port: 8883,
  ssl: true
)

client.get
```

Fixes #135
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants