Watch Star Fork

GVPHutool / hutoolJavaApache-2.0

SecureUtil签名失败 #IH61M

任务
已完成
Hanley  创建于

错误信息 输入图片说明

另外发现 SignAlgorithm 中 SHA1withRSA有个空格不清楚是否有关系。 输入图片说明

public static void main(String[] args) {
			
		String privateKey = "MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAJ4fG8vJ0tzu7tjXMSJhyNjlE5B7GkTKMKEQlR6LY3IhIhMFVjuA6W+DqH1VMxl9h3GIM4yCKG2VRZEYEPazgVxa5/ifO8W0pfmrzWCPrddUq4t0Slz5u2lLKymLpPjCzboHoDb8VlF+1HOxjKQckAXq9q7U7dV5VxOzJDuZXlz3AgMBAAECgYABo2LfVqT3owYYewpIR+kTzjPIsG3SPqIIWSqiWWFbYlp/BfQhw7EndZ6+Ra602ecYVwfpscOHdx90ZGJwm+WAMkKT4HiWYwyb0ZqQzRBGYDHFjPpfCBxrzSIJ3QL+B8c8YHq4HaLKRKmq7VUF1gtyWaek87rETWAmQoGjt8DyAQJBAOG4OxsT901zjfxrgKwCv6fV8wGXrNfDSViP1t9r3u6tRPsE6Gli0dfMyzxwENDTI75sOEAfyu6xBlemQGmNsfcCQQCzVWQkl9YUoVDWEitvI5MpkvVKYsFLRXKvLfyxLcY3LxpLKBcEeJ/n5wLxjH0GorhJMmM2Rw3hkjUTJCoqqe0BAkATt8FKC0N2O5ryqv1xiUfuxGzW/cX2jzOwDdiqacTuuqok93fKBPzpyhUS8YM2iss7jj6Xs29JzKMOMxK7ZcpfAkAf21lwzrAu9gEgJhYlJhKsXfjJAAYKUwnuaKLs7o65mtp242ZDWxI85eK1+hjzptBJ4HOTXsfufESFY/VBovIBAkAltO886qQRoNSc0OsVlCi4X1DGo6x2RqQ9EsWPrxWEZGYuyEdODrc54b8L+zaUJLfMJdsCIHEUbM7WXxvFVXNv";
		String publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCeHxvLydLc7u7Y1zEiYcjY5ROQexpEyjChEJUei2NyISITBVY7gOlvg6h9VTMZfYdxiDOMgihtlUWRGBD2s4FcWuf4nzvFtKX5q81gj63XVKuLdEpc+btpSyspi6T4ws26B6A2/FZRftRzsYykHJAF6vau1O3VeVcTsyQ7mV5c9wIDAQAB";
		
		final String content = "我是Hanley.";	
		Sign sign = SecureUtil.sign(SignAlgorithm.SHA1withRSA,privateKey,null);
		byte[] signed = sign.sign(content.getBytes());
	}
1463_loolly 1506828_thanlin 共2人参与

评论 (4)

1463_loolly
Looly 2018-01-03 20:25 拥有者

确认bug,请使用以下方式替代:

Sign sign = new Sign("SHA1withRSA", privateKey,null);

3.3.1会修复此问题。

1506828_thanlin
Hanley 2018-01-03 21:00

刚试了下,还是不行,一样的错误。

运行环境

  • Mac OS 10.13.2 (17C88)
  • Eclipse Version: Oxygen.2 Release (4.7.2)
1463_loolly
Looly 2018-01-03 21:22 拥有者
final String content = "我是Hanley.";
Sign sign = new Sign("SHA1withRSA", SecureUtil.generatePrivateKey("RSA", Base64.decode(privateKey)), null);
// 签名
byte[] signed = sign.sign(content.getBytes());

试下这个。我忽略Key生成策略问题了。我会一并修复在下个版本。

1506828_thanlin
Hanley 2018-01-04 11:14

Thanks

登录 后才可以发表评论

负责人
标签
bug
里程碑
关联分支
开始时间
未设置
结束时间
未设置
置顶选项
优先级

搜索帮助