日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

The specified key byte array is 136 bits which is not secure enough for any JWT HMAC-SHA algorithm.

發(fā)布時(shí)間:2024/3/26 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 The specified key byte array is 136 bits which is not secure enough for any JWT HMAC-SHA algorithm. 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

場景

集合了<jjwt.version>0.11.5</jjwt.version>版本的 jwt

<dependency><groupId>io.jsonwebtoken</groupId><artifactId>jjwt-api</artifactId><version>${jjwt.version}</version></dependency><dependency><groupId>io.jsonwebtoken</groupId><artifactId>jjwt-impl</artifactId><version>${jjwt.version}</version><scope>runtime</scope></dependency><dependency><groupId>io.jsonwebtoken</groupId><artifactId>jjwt-jackson</artifactId> <!-- or jjwt-gson if Gson is preferred --><version>${jjwt.version}</version><scope>runtime</scope></dependency>

原 signWith 方法過時(shí),更改后報(bào)錯(cuò)如下

主要錯(cuò)誤信息如下

The specified key byte array is 136 bits which is not secure enough for any JWT HMAC-SHA algorithm.

2022-05-11 16:44:38.748 ERROR 83332 --- [io-13921-exec-1] o.a.c.c.C.[.[.[.[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [/admin] threw exception [Request processing failed; nested exception is io.jsonwebtoken.security.WeakKeyException: The specified key byte array is 136 bits which is not secure enough for any JWT HMAC-SHA algorithm. The JWT JWA Specification (RFC 7518, Section 3.2) states that keys used with HMAC-SHA algorithms MUST have a size >= 256 bits (the key size must be greater than or equal to the hash output size). Consider using the io.jsonwebtoken.security.Keys#secretKeyFor(SignatureAlgorithm) method to create a key guaranteed to be secure enough for your preferred HMAC-SHA algorithm. See https://tools.ietf.org/html/rfc7518#section-3.2 for more information.] with root causeio.jsonwebtoken.security.WeakKeyException: The specified key byte array is 136 bits which is not secure enough for any JWT HMAC-SHA algorithm. The JWT JWA Specification (RFC 7518, Section 3.2) states that keys used with HMAC-SHA algorithms MUST have a size >= 256 bits (the key size must be greater than or equal to the hash output size). Consider using the io.jsonwebtoken.security.Keys#secretKeyFor(SignatureAlgorithm) method to create a key guaranteed to be secure enough for your preferred HMAC-SHA algorithm. See https://tools.ietf.org/html/rfc7518#section-3.2 for more information.at io.jsonwebtoken.security.Keys.hmacShaKeyFor(Keys.java:96) ~[jjwt-api-0.11.5.jar:0.11.5]at com.admin.utils.JwtTokenUtils.generateToken(JwtTokenUtils.java:42) ~[classes/:na]at com.admin.service.AdminUserService.adminLogin(AdminUserService.java:59) ~[classes/:na]at com.admin.service.AdminUserService$$FastClassBySpringCGLIB$$1.invoke(<generated>) ~[classes/:na]at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.3.19.jar:5.3.19]at org.springframework.aop.framework.CglibAopProxy.invokeMethod(CglibAopProxy.java:386) ~[spring-aop-5.3.19.jar:5.3.19]at org.springframework.aop.framework.CglibAopProxy.access$000(CglibAopProxy.java:85) ~[spring-aop-5.3.19.jar:5.3.19]at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:704) ~[spring-aop-5.3.19.jar:5.3.19]at com.admin.service.AdminUserService$$EnhancerBySpringCGLIB$$1.adminLogin(<generated>) ~[classes/:na]at com.admin.controller.UserController.adminLogin(UserController.java:26) ~[classes/:na]at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_332]at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_332]at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_332]at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_332]

解決

給下述代碼中的JWT_SECRET字段弄長點(diǎn),大概 256 來個(gè)字符的時(shí)候就可以了

/*** 根據(jù)用戶信息生成token*/public String generateToken(String username) {Claims claims = Jwts.claims().setSubject(username);SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256;SecretKey key = Keys.hmacShaKeyFor(JWT_SECRET.getBytes(StandardCharsets.UTF_8));return Jwts.builder().setClaims(claims).setExpiration(generateExpirationDate()).signWith(key, signatureAlgorithm).compact();}

總結(jié)

以上是生活随笔為你收集整理的The specified key byte array is 136 bits which is not secure enough for any JWT HMAC-SHA algorithm.的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 在线不卡的av | 日韩电影在线观看一区二区 | 冲田杏梨在线 | 日本欧美色图 | 又黄又色 | 黑人玩弄人妻一区二 | 19禁大尺度做爰无遮挡电影 | 一区精品二区国产 | 国产精品系列在线播放 | 日韩精品一区在线 | 国产一区福利 | 精品久久久免费 | 最新国产网站 | 亚洲啪啪 | 亚洲成人日韩 | 超碰1000 | 秋霞午夜视频 | 国产精品一卡 | 免费中文字幕日韩欧美 | 四虎免费av | 女女爱爱视频 | 免费在线观看a视频 | 精品欧美一区二区三区 | 美女扒开粉嫩的尿囗给男生桶 | 婷婷影音 | 好姑娘在线观看高清完整版电影 | 亚洲天堂爱爱 | 玉女心经是什么意思 | 欧美精品一二三四 | 拍摄av现场失控高潮数次 | 日韩不卡视频一区二区 | 免费看91 | 羞羞动漫在线观看 | 日日日日日日 | japanesehdxxxx| 中文字幕免费在线看线人动作大片 | 高h大肚孕期孕妇play | 午夜宅男影院 | 99国产精品一区二区 | 毛片毛片毛片毛片毛片 | 奇米网久久| 91爱看| 奇米777第四色 | 91网国产| 波多野结衣视频网址 | 日韩精品一区二区三区中文在线 | 国产成人精品久久二区二区91 | 性xxx欧美| 成人a毛片 | 黄色精品免费 | 91蝌蚪视频在线观看 | 亚洲精品在线看 | jizz国产精品 | 热久久在线 | 亚洲第一黄色网 | 黄频在线免费观看 | 国产人成视频在线观看 | 国产小视频在线 | av大全免费观看 | 向着小小的花蕾绽放 | 久久精品屋 | 欧美日韩精品一区二区三区四区 | 97超碰碰 | 日韩精品在线看 | 国产电影一区二区三区爱妃记 | 久久精品2019中文字幕 | 久久午夜片| 四虎新网站 | 东凛在线观看 | 干日本少妇 | 天堂网2018 | 日本一区二区三区在线播放 | 国产山村乱淫老妇女视频 | 亚洲国产精品久久久久爰性色 | 国产欧美日韩精品一区二区三区 | 国内精品国产三级国产aⅴ久 | 欧美激情第1页 | 欧美激情在线播放 | 天天天av | 老司机性视频 | 人妻丝袜一区二区三区 | 丰满少妇麻豆av苏语棠 | 俄罗斯丰满熟妇hd | 欧美久久久久久久久中文字幕 | 男人视频网站 | 天天躁日日躁aaaxxⅹ | 欧美激情精品久久 | 欧美激情黄色 | 亚洲一区二区日韩 | 噜噜噜视频 | 免费成人美女女 | 亚洲女人初尝黑人巨大 | 91精品人妻一区二区三区蜜桃欧美 | 9999av| 超碰超碰超碰超碰超碰 | 国偷自产视频一区二区久 | 91片看| 日本肉体xxxⅹ裸体交 | 爱情岛亚洲首页论坛小巨 |