使用master.key进行数据海洋部署的Rails 5.2:ActiveSupport :: MessageEncryptor :: InvalidMessage:ActiveSupport :: MessageEncryptor :: InvalidMessage
我已将我的Ruby on Rails应用程序从Rails 5.1.2迁移到Rails 5.2.0以使用加密的秘密。 应用程序已成功部署到Digital Ocean Ubuntu Server。 但是当我进入浏览器访问时,它会显示以下日志。
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 `'
我使用rails credentials:edit
添加了加密的秘密rails credentials:edit
,它创建了config/credentials.yml.enc
和master.key
。
我还在我的ubuntu服务器上的/app_name/shared/config/
上添加了master.key文件,还放置了一个env变量RAILS_MASTER_KEY
。 但仍然得到这个错误,我不知道我在这里失踪了什么。
解决方案A和B是不同的解决方案。 只需选择哪种对您有好处。
一个。 从连续集成部署
1.编辑deploy.rb
set :default_env, { "RAILS_ENV" => "production", "RAILS_MASTER_KEY" => ENV["RAILS_MASTER_KEY"] }
2.将RAILS_MASTER_KEY
添加为变量
- 特拉维斯CI
- GitLab CI
湾 使用master.key
1.编辑deploy.rb
append :linked_files, "config/master.key"
2.使用:linked_files
上传:linked_files
假设我们的应用程序的根路径是/home/deploy/awesome-project
。 我们需要做的就是将密钥文件上传到/home/deploy/awesome-project/shared/config/master.key
。
- 如果你想使用它,如何解决“你需要为你的Gemfile添加gem’守护进程’”生产模式错误?
- 在能够使用Capistrano进行部署之前,是否需要在我的服务器上手动安装Bundler?
- 尝试将Rails 4应用程序部署到WebFaction,使用他们的文档并在本地获取错误
- 没有找到Rails rubber-cap命令
- Capistrano:my.server.ipadress上不存在链接文件database.yml
- Capistrano迁移部署
- shared_children在Capistrano 3工作
- EC2 – 无法部署为“bitnami”用户
- 为什么我收到此乘客错误无法在任何来源中找到rake-0.9.2.2?