在客户端页面里面, 提交之前使用电子钥匙的api直接调用电子钥匙里的私钥对数据进行加密和签名, 然后将加密数据和签名生成的摘要发送到服务端.
然后在服务端使用如下代码进行验证:
X509Certificate certificate = CertUtils.getCertificate(ServletActionContext.getRequest());
PublicKey pub = certificate.getPublicKey();
Signature rsa = Signature.getInstance("MD5withRSA");
rsa.initVerify(pub);
rsa.update(encryptMessage.getBytes());
boolean verifies = rsa.verify(signedMessage.getBytes());CertUtils是自己写的一个类, 功能是从request里获取证书. 客户端签名确实用的是MD5 RSA的算法. 但是验证的结果总是false. 请问下这样到底是哪个地方出错了``? 是不是因为加密用的私钥和服务端从request里取到的pubkey不是一对?
然后在服务端使用如下代码进行验证:
X509Certificate certificate = CertUtils.getCertificate(ServletActionContext.getRequest());
PublicKey pub = certificate.getPublicKey();
Signature rsa = Signature.getInstance("MD5withRSA");
rsa.initVerify(pub);
rsa.update(encryptMessage.getBytes());
boolean verifies = rsa.verify(signedMessage.getBytes());CertUtils是自己写的一个类, 功能是从request里获取证书. 客户端签名确实用的是MD5 RSA的算法. 但是验证的结果总是false. 请问下这样到底是哪个地方出错了``? 是不是因为加密用的私钥和服务端从request里取到的pubkey不是一对?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货