# 플러그인에서 ActiveSupport::MessageEncryptor::InvalidMessage 오류 발생

**URL:** <https://meta.discourse.org/t/trouble-with-activesupport-invalidmessage-in-plugin/229957>\
**Category:** Development\
**Created:** [6월 14, 2022, 5:55오후 UTC](https://meta.discourse.org/t/trouble-with-activesupport-invalidmessage-in-plugin/229957 "2022-06-14T17:55:42Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [6월 20, 2022, 6:09오후 UTC](https://meta.discourse.org/t/trouble-with-activesupport-invalidmessage-in-plugin/229957/4 "2022-06-20T18:09:35Z")

</div>

감사합니다, @gerhard!

> **[Upgrading Ruby on Rails — Ruby on Rails Guides](https://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#new-activesupport-messageencryptor-default-serializer)**
>
> This guide provides steps to be followed when you upgrade your applications to a newer version of Ruby on Rails. These steps are also available in individual release guides.

에서 다음 내용을 찾았습니다.

> [@](#):
>
> Rails 7.1부터 `MessageEncryptor`에서 사용하는 기본 직렬화기(serializer)는 `JSON`입니다. 이는 현재 기본 직렬화기보다 더 안전한 대안을 제공합니다.
> 
> `MessageEncryptor`는 기본 직렬화기를 `Marshal`에서 `JSON`으로 마이그레이션할 수 있는 기능을 제공합니다.  
> 기존 애플리케이션에서 이 변경 사항을 무시하려면 다음을 설정하세요: `config.active_support.default_message_encryptor_serializer = :marshal` .

(하지만 여기에는 Rails 7.1이라고 되어 있네요?)

기존 플러그인에서 이 변경 사항을 무시할 수 있는, 알고 보면 자명한 `plugin.rb` 한 줄 코드가 있는지 혹시 바로 아시는 게 있을까요?

아니면 이 변경 사항이 무엇을 의미하는지 직접 파악해야 할 수도 있겠네요.

수정: `dev` 환경에서 해당 줄을 `config/application.rb`에 추가해도 마법처럼 해결되지 않습니다.

죄송합니다. 조금 더 아래를 읽어보니:

> [@](#):
>
> #### [3.10 Key generator digest class changing to use SHA256](https://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#key-generator-digest-class-changing-to-use-sha256)
> 
> 키 생성기(key generator)의 기본 다이제스트 클래스가 SHA1에서 SHA256으로 변경됩니다. 이는 Rails가 생성하는 모든 암호화된 메시지(암호화된 쿠키 포함)에 영향을 미칩니다.
> 
> 이전 다이제스트 클래스를 사용한 메시지를 읽을 수 있도록 하려면 로테이터(rotator)를 등록해야 합니다.

그래서 이것이 제 즉각적인 문제를 해결해 줄 수도 있겠네요. 다시 한번 도움을 주셔서 감사합니다! 이번에는 성공할 수 있을지도 모르겠네요.

* * *

음, Rails 6과 Rails 7 모두에서 생성한 키는 다음과 같이 보입니다:

```plaintext
#<ActiveSupport::KeyGenerator:0x000055870212d4f8 @hash_digest_class=OpenSSL::Digest::SHA1, @iterations=65536, @secret="my-big-secret">

```

하지만 암호화 방식은 다릅니다. `hash_digest_class`가 문제인 줄 알았는데, 적어도 양쪽에서 동일해 보이는데도 암호화된 문자열은 다릅니다. 😿

---

_[View the full topic](https://meta.discourse.org/t/trouble-with-activesupport-invalidmessage-in-plugin/229957)._
