服务在反序列化时报错:java.io.IOException: org.apache.dubbo.common.serialize.SerializationException: java.lang.IllegalArgumentException: [Serialization Security] Serialized class [类名] is not in allow list. Current mode is
STRICT, will disallow to deserialize it by default. Please add it into security/serialize.allowlist or follow FAQ to configure it.
参考官网关于类检查机制的说明
dubbo类检查机制
我使用的版本默认的检查模式为STRICT
,禁止反序列化所有不在允许序列化列表(白名单)中的类。
共有三个模式:STRICT 严格检查,WARN 告警,DISABLE 禁用
解决方法
有两种解决方法
- 将检查模式改为较为宽松的级别:可以通过配置
dubbo.application.serialize-check-status=WARN
或者dubbo.application.serialize-check-status=DISABLE
- 将要反序列化的类加入到白名单:在资源目录(resource)下定义security/serialize.allowlist文件,并将类的全名写入:
# security/serialize.allowlist
io.dubbo.test