gpt4 book ai didi

ruby-on-rails - Rails 5.2 与 master.key Digital Ocean 部署:ActiveSupport::MessageEncryptor::InvalidMessage:ActiveSupport::MessageEncryptor::InvalidMessage

转载 作者:行者123 更新时间:2023-12-02 20:22:39 24 4
gpt4 key购买 nike

我已将 Ruby on Rails 应用程序从 Rails 5.1.2 迁移到 Rails 5.2.0 以使用加密的 secret 。应用程序已成功部署到 Digital Ocean Ubuntu 服务器。但是当我进入浏览器访问时,它显示以下日志。

    ActiveSupport::MessageEncryptor::InvalidMessage: ActiveSupport::MessageEncryptor::InvalidMessage
/home/deploy/apps/GeekyCricket/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/message_encryptor.rb:206:in `rescue in _decrypt'
/home/deploy/apps/GeekyCricket/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/message_encryptor.rb:184:in `_decrypt'
/home/deploy/apps/GeekyCricket/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/message_encryptor.rb:157:in `decrypt_and_verify'
/home/deploy/apps/GeekyCricket/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/messages/rotator.rb:21:in `decrypt_and_verify'
/home/deploy/apps/GeekyCricket/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/encrypted_file.rb:79:in `decrypt'
/home/deploy/apps/GeekyCricket/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/encrypted_file.rb:42:in `read'
/home/deploy/apps/GeekyCricket/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/encrypted_configuration.rb:21:in `read'
/home/deploy/apps/GeekyCricket/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/encrypted_configuration.rb:33:in `config'
/home/deploy/apps/GeekyCricket/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/encrypted_configuration.rb:38:in `options'
/home/deploy/apps/GeekyCricket/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/core_ext/module/delegation.rb:271:in `method_missing'
(erb):12:in `<main>'

我使用 railscredentials:edit 添加了加密 key ,这会创建 config/credentials.yml.encmaster.key

我还在我的 ubuntu 服务器上的 /app_name/shared/config/ 上添加了 master.key 文件,还放置了一个环境变量 RAILS_MASTER_KEY。但仍然收到此错误,我不知道我在这里缺少什么。

最佳答案

解决方案 A 和 B 是不同的解决方案。只需选择对您有利的即可。

a.从持续集成部署

1.编辑deploy.rb

set :default_env, {
"RAILS_ENV" => "production",
"RAILS_MASTER_KEY" => ENV["RAILS_MASTER_KEY"]
}

2.添加RAILS_MASTER_KEY作为变量

b. master.key的使用

1.编辑deploy.rb

append :linked_files, "config/master.key"

2.上传master.key:linked_files

假设我们的应用程序的根路径是 /home/deploy/awesome-project 。我们需要做的就是将 key 文件上传到/home/deploy/awesome-project/shared/config/master.key .

关于ruby-on-rails - Rails 5.2 与 master.key Digital Ocean 部署:ActiveSupport::MessageEncryptor::InvalidMessage:ActiveSupport::MessageEncryptor::InvalidMessage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50963676/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com