如何在Message Java中验证数字签名?

问题描述 投票:0回答:1

我尝试在Java上为Jira创建自定义邮件处理程序,如果该消息具有签名,则必须验证消息的数字签名。但是我不知道该怎么做。

  1. 我有javax.mail.Message message,如何检查它是否具有签名?

  2. 如果消息具有签名以验证这一点,据我所知,我必须像这样:

//create a Signature instance
 Signature signature = Signature.getInstance("SHA256withRSA");
//initialize the Signature object for verification which takes a public key
signature.initVerify(publicKey);
//add the received message bytes to the signature object
String body = MailUtils.getBody(message);
byte[] messageBytes = body.getBytes(); 
signature.update(messageBytes);
//And finally, check the signature
boolean isCorrect = signature.verify(receivedSignature);

但是如何从收到的javax.mail.Message消息中获取算法,publicKey和receiveSignature?

java jira javamail digital-signature jira-plugin
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.