postal icon indicating copy to clipboard operation
postal copied to clipboard

Webhook Payload "sent_with_ssl" is false

Open mohan-nishit opened this issue 9 years ago • 6 comments

Hi there!

Thanks for sharing Postal with us. It is an amazing piece of work! I have an issue to report, which is, my webhooks are reporting to an API endpoint with all events payloads, but all payloads have the field "sent_with_ssl" as false.

Postal itself is working fine, and if I telnet to the postal server, with an ehlo postal.mydomain.com I can see 250-STARTTLS. Are the emails not being sent over SSL?

mohan-nishit avatar Sep 10 '17 19:09 mohan-nishit

#272 Also mentions this issue.

mohan-nishit avatar Sep 10 '17 19:09 mohan-nishit

I am trying to resolve this issue at the real moment but still have no success. I will keep trying in the near days.

igerzog avatar Sep 11 '17 20:09 igerzog

#330 related

---------- Forwarded message ---------- From: "alexroosenstein" [email protected] Date: Sep 12, 2017 6:05 AM Subject: Re: [atech/postal] MessageSent events not being sent via webhook (#330) To: "atech/postal" [email protected] Cc: "Subscribed" [email protected]

I've actually 'fixed' this by changing this line: https://github.com/atech/postal/blob/2f0155747c5c058afb83856ce5c3c8 d5f8cad341/app/models/webhook_request.rb#L46

To: where("retry_after < ? OR (retry_after IS NULL AND created_at<SUBTIME(NOW(), '0:30:0.000000'))", Time.now).limit(100).each(&: queue)

I added the limit(100) as we've ran into a backlog of roughly 900.000 webhook requests and I didn't want to overload anything. I added the created_atcheck so it would only requeue webhook requests that are older than 30 minutes (and thus were never actually queued). This is not a permanent/ideal fix, but it did temporarily solve our problem with the webhook requests.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/atech/postal/issues/330#issuecomment-328806387, or mute the thread https://github.com/notifications/unsubscribe-auth/AMMA50KIp7kIA2OdjMpLvM2ZJOYewsiEks5shldygaJpZM4O-9gG .

On Sep 11, 2017 4:31 PM, "igerzog" [email protected] wrote:

I am trying to resolve this issue at the real moment but still have no success. I will keep trying in the near days.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/atech/postal/issues/348#issuecomment-328649641, or mute the thread https://github.com/notifications/unsubscribe-auth/AMMA5zj-8zPsiz3PDOt16qnGliwyz_orks5shZiOgaJpZM4PSa5t .

shopglobal avatar Sep 12 '17 11:09 shopglobal

Interesting solution. I will check it tomorrow. Thanks!

igerzog avatar Sep 12 '17 19:09 igerzog

Still not resolved. Any suggestions?

igerzog avatar Dec 21 '17 02:12 igerzog

Well, I have resolved the problem with the permanent false value of "sent_with_ssl" field. The reason is that the class of socket object being checked here to determine if the connection secured is not OpenSSL::SSL::SSLSocket but Net::InternetMessageIO.

In order to fix this I suggest to modify tlsconnect(s) from Net::SMTP by adding new variable @secure_socket that becomes true after successful SSL connection:

  def tlsconnect(s)
    verified = false
    s = ssl_socket(s, @ssl_context)
    logging "TLS connection started"
    s.sync_close = true
    s.connect
    if @ssl_context.verify_mode != OpenSSL::SSL::VERIFY_NONE
      s.post_connection_check(@address)
    end
    verified = true
    @secure_socket = true
    s
  ensure
    s.close unless verified
  end

and then place it to the end of smtp_extensions.rb. The definition for secure_socket? simply transforms to:

  def secure_socket?
    !!(@secure_socket)
  end

If it's ok with my suggestion I will prepare a commit for this fix 🙂

igerzog avatar Sep 17 '19 18:09 igerzog