简体   繁体   English

SSL 无法建立安全连接 - 在 Heroku 中使用 Devise 的 Rails 6 应用程序

[英]SSL cannot establish secure connection - with Rails 6 app using Devise in Heroku

As the title says, I have a Rails 6 app running in Heroku, with the automatic SSL certificate that Heroku provides.正如标题所说,我有一个在 Heroku 中运行的 Rails 6 应用程序,具有 Heroku 提供的自动 SSL 证书。 Everything works great, and I can visit any page and it gets the https working fine.一切正常,我可以访问任何页面,它使https工作正常。 However, there is one exception: When users sign up and they get the confirmation email, clicking the link does not work for some reason (see attached screenshots below), and the same happens even if you copy+paste the link in a new tab, of course.但是,有一个例外:当用户注册并收到 email 确认时,由于某种原因无法单击链接(请参阅下面的截图),即使您将链接复制并粘贴到新标签中也会发生同样的情况, 当然。

  • Ruby version: 2.7.1p83 Ruby版本:2.7.1p83
  • Rails version: 6.0.3.1导轨版本:6.0.3.1

Safari 截图 Firefox: Firefox: 在此处输入图像描述

This is what I get when trying to access that url https://my_domain.com/users/confirmation?confirmation_token=foobar .这是我在尝试访问 url https://my_domain.com/users/confirmation?confirmation_token=foobar时得到的。

My environments/production.rb has these settings:我的environments/production.rb有这些设置:

Rails.application.configure do
  # a few more non important things, and then:
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.perform_deliveries = true
  config.action_mailer.smtp_settings = {
    :user_name => ENV['SENDGRID_USERNAME'],
    :password => ENV['SENDGRID_PASSWORD'],
    :domain => 'my_domain.com',
    :address => 'smtp.sendgrid.net',
    :port => 587,
    :authentication => :plain,
    :enable_starttls_auto => true
  }


  config.force_ssl = true
  config.action_mailer.default_url_options = { :host => 'my_domain.com' }
end

And this is what it looks like in Heroku:这就是它在 Heroku 中的样子:

在此处输入图像描述

I have these routes for Devise:我有 Devise 的这些路线:

Rails.application.routes.draw do
  devise_for :users, controllers: { registrations: 'users/registrations',
                                    confirmations: 'users/confirmations' }
  authenticated :user do
    root to: "depots#index", as: :authenticated_root
  end

  root to: "public/welcome#index"
end

And the controller looks like this: controller 看起来像这样:

class Users::ConfirmationsController < Devise::ConfirmationsController
  def after_confirmation_path_for(resource_name, resource)
    sign_in(resource)
    authenticated_root_path
  end
end

Do you guys have any idea on what could be wrong?你们有什么想法可能是错的吗? And if not, any advice on how to troubleshoot this?如果没有,关于如何解决这个问题的任何建议?

UPDATE Aug, 04, 2020: 2020 年 8 月 4 日更新:

I had added this redirect to my domain but even though it works redirecting from grownis.com to www.grownis.com it doesn't for https://grownis.com I had added this redirect to my domain but even though it works redirecting from grownis.com to www.grownis.com it doesn't for https://grownis.com

在此处输入图像描述

Your certificate is not wildcard certificate.您的证书不是通配符证书。 Please check this link.请检查此链接。

https://grownis.com/ https://grownis.com/

The confirmation link is https://grownis.com/users/confirmation?confirmation_token=CONRIMATION_TOKEN确认链接为https://grownis.com/users/confirmation?confirmation_token=CONRIMATION_TOKEN

You will need to make a redirection from non-www to www or purchase wildcard certificate.您需要从非 www 重定向到 www 或购买通配符证书。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM