欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

IllegalStateException: For MAC signing you do not need to specify the verifier key separately异常解决

程序员文章站 2022-07-14 18:40:10
...

IllegalStateException: For MAC signing you do not need to specify the verifier key separately...

一.异常现象

我在SpringCloud微服务项目中,利用SpringSecurity整合OAuth2,结合RSA非对称加密算法实现jwt token的时候,遇到了如下异常信息:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfiguration': Unsatisfied dependency expressed through field 'tokenStore'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tokenStore' defined in class path resource ....: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.provider.token.TokenStore]: Factory method 'tokenStore' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accessTokenConverter' defined in class path resource ... Invocation of init method failed; nested exception is java.lang.IllegalStateException: For MAC signing you do not need to specify the verifier key separately, and if you do it must match the signing key
.....
Caused by: java.lang.IllegalStateException: For MAC signing you do not need to specify the verifier key separately, and if you do it must match the signing key
	at org.springframework.util.Assert.state(Assert.java:73) ~[spring-core-5.0.11.RELEASE.jar:5.0.11.RELEASE]
	at ....

二.异常原因

出现这个问题的原因,一般都是因为自己的RSA公钥文件写错了!

比如我一开始利用keytool工具导出的公钥,然后把公钥复制粘贴到自己的public.txt文件中,结果少粘贴了3个“---”,就导致了该问题的产生!如下图标红区域所示:

IllegalStateException: For MAC signing you do not need to specify the verifier key separately异常解决

三.解决办法

一定要确保自己的public.txt公钥文件格式和内容正确!从keytool中导出的时候仔细点就好了!

IllegalStateException: For MAC signing you do not need to specify the verifier key separately异常解决

 

 

相关标签: 异常解决