日韩性视频-久久久蜜桃-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ò),歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 亚洲视频不卡 | 国产99久| 色婷婷免费视频 | 久操视频在线观看免费 | 亚洲老女人av | 中文字幕在线视频网 | 国产色在线视频 | 老鸭窝一区二区 | 老牛嫩草二区三区观影体验 | 亚洲一区免费在线观看 | 四虎在线观看 | 一级免费黄色大片 | 国产一级二级三级在线 | 久久婷婷丁香 | 女性生殖扒开酷刑vk | 午夜影院免费观看 | 爱情岛亚洲首页论坛 | 91视频麻豆 | 日本性爱动漫 | 骚虎av | 韩国一级一片高清免费观看 | 国产亚洲毛片 | 国产97色在线 | 日韩 | 伊人日日夜夜 | 国产黄色网络 | 国产aa毛片 | 亚洲青春草 | 黄色a在线 | 丰满人妻一区二区三区大胸 | 精品国产伦一区二区三区 | 免费看一级视频 | aaa黄色 | 91精品国产一区二区三区香蕉 | 中国性老太hd大全69 | 午夜av免费在线观看 | 99在线视频观看 | 91极品蜜桃臀 | 国产女人18毛片水真多 | 日本xxxx裸体xxxx| 亚洲欧美另类中文字幕 | 午夜怡红院| 色多多污污 | 免费人成在线观看 | 精品一区二区三区视频在线观看 | 日本在线免费播放 | 国产片91| 欧美日韩精品久久久免费观看 | 欧美 日韩 中文字幕 | 黄色无遮挡网站 | 女人高潮潮呻吟喷水 | 高h喷汁呻吟3p | 国产成人av在线 | 黄色一级一片免费播放 | 亚洲电影一区二区三区 | 黄色一级免费大片 | 色婷婷狠狠爱 | 伊人视频 | 欧美在线观看免费高清 | 玖玖国产| 最新国产在线视频 | 操你啦在线视频 | 国产肥白大熟妇bbbb视频 | 天天拍夜夜拍 | 亚洲第一天堂影院 | 成年人视频在线观看免费 | 国产视频www | 中文字幕超清在线免费观看 | 亚洲精品无码专区 | 久久久三级视频 | 国产一区二区激情视频 | 综合精品在线 | 日本在线色 | 高清无码视频直接看 | 精品人妻少妇AV无码专区 | 好吊妞视频这里只有精品 | 久久99精品国产麻豆婷婷洗澡 | 亚洲一区二区三区av无码 | 噜噜噜久久 | 性欧美极品另类 | 色99在线| 国产激情视频一区二区三区 | 在线观看中文字幕亚洲 | 国产精品一区二区三区在线看 | 午夜激情男女 | 牛牛精品一区 | 天天免费看av | 综合亚洲网 | 精品1区2区 | 国产欧美精品久久 | 成人精品在线观看视频 | 修仙淫交(高h)h文 | 电影91久久久 | 好屌妞视频这里只有精品 | av在线电影观看 | 久伊人 | 国产精品午夜在线 | 亚洲v日韩v综合v精品v | 国产综合在线观看 | 日韩一区二区三区在线播放 |