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

Upcoming Postmark TLS Changes #102

Closed
mgomes opened this issue Feb 23, 2021 · 6 comments
Closed

Upcoming Postmark TLS Changes #102

mgomes opened this issue Feb 23, 2021 · 6 comments

Comments

@mgomes
Copy link

mgomes commented Feb 23, 2021

Hello,

Does this gem already support (or will support) the upcoming changes to the Postmark API? This email just went out, but it's not clear if official clients such as this one are ready to go.

Thanks for your help!

@tomazy
Copy link
Contributor

tomazy commented Feb 23, 2021

You need to make sure that your ruby/openssl version supports TLS version greater than 1.0 which should be the case unless you're using a very old version of ruby or openssl - support for TLS 1.1 & 1.2 was added back in 2012: ruby/ruby@060184c .

The best way to check if you're safe is to connect to the new temporary endpoint and send an email:

require 'postmark'

client = Postmark::ApiClient.new(SERVER_TOKEN, host: 'api-ssl-temp.postmarkapp.com')
client.deliver(from: ..., to: ...., text_body: 'test')

In case of any issues with ruby and SSL I recommend this troubleshooting guide from the bundler project: https://bundler.io/guides/rubygems_tls_ssl_troubleshooting_guide.html#tls-10-and-11-are-deprecated .

EDIT:
⚠️ Also, make sure you're using the latest version of this gem: 1.21.3. ⚠️

@ibalosh ibalosh closed this as completed Feb 24, 2021
@mgomes
Copy link
Author

mgomes commented Feb 24, 2021

Thanks @tomazy 👍

@elbrunof
Copy link

You may need to add http_ssl_version: :TLSv1_2 to ApiClient:

client = Postmark::ApiClient.new(POSTMARK_API_TOKEN, host: 'api-ssl-temp.postmarkapp.com', http_ssl_version: :TLSv1_2)

In case you use postmark-rails, add http_ssl_version: :TLSv1_2 to your application config file:

config.action_mailer.postmark_settings = {
  api_token: ENV['POSTMARK_API_TOKEN'],
  http_ssl_version: :TLSv1_2,
}

@beder
Copy link

beder commented Feb 25, 2021

You may need to add http_ssl_version: :TLSv1_2 to ApiClient:

client = Postmark::ApiClient.new(POSTMARK_API_TOKEN, host: 'api-ssl-temp.postmarkapp.com', http_ssl_version: :TLSv1_2)

In case you use postmark-rails, add http_ssl_version: :TLSv1_2 to your application config file:

config.action_mailer.postmark_settings = {
  api_token: ENV['POSTMARK_API_TOKEN'],
  http_ssl_version: :TLSv1_2,
}

Please note that http_ssl_version is needed only in postmark gem versions prior to v1.21.3. Version 1.21.3 removes TLSV1 as the default SSL version and lets the HTTP client negotiate the SSL version.

Method: HTTPClient::SSLConfig#ssl_version

See: 529e9db

@DylanFM
Copy link

DylanFM commented Feb 25, 2021

I may be mistaken here, but I ran into an exception when following the testing steps above. Despite the bundler curl test passing 👌. After updating our postmark(-rails) gem test email sent fine.

Just in case someone runs into this exception and thinks they need to fix other things - check that your postmark gem is up to date.

Before gem update:

client = Postmark::ApiClient.new k, host: 'api-ssl-temp.postmarkapp.com'
=> #<Postmark::ApiClient:0x000055daf3263260 ...>>>
client.deliver(from: '...', to: '...', text_body: 'testing api-ssl-temp.postmarkapp.com')
Traceback (most recent call last):
        1: from (irb):14
OpenSSL::SSL::SSLError (SSL_connect SYSCALL returned=5 errno=0 state=SSLv3/TLS write client hello) 

After update:

client.deliver(from: '...', to: '...', text_body: 'testing api-ssl-temp.postmarkapp.com')
=> {:to=>"...", :submitted_at=>"2021-02-25T13:50:46.4864111Z", :message_id=>"...", :error_code=>0, :message=>"OK"}

@jshow
Copy link

jshow commented Feb 25, 2021

after upgrading to the latest postmark gems, I had to install openssl gem, install libssl-dev package and recompile the ruby binary - all good now

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

No branches or pull requests

7 participants