简体   繁体   中英

How to get signed content from pkcs7 attached signature using Bouncy Castle

using following code; when i tries to get access the signed from the PKCS7 attached signature.

  cms = new CMSSignedData(envelopedData); //PKCS7 envelope
  String signedData = new String((byte[])cms.getSignedContent().getContent());

I got the output like this.

nº™(5š?¶ÁNšc«n‘¶˜Êõûøˆ‚<ùæB0¸ð¿ø"˜ZÊ×`—õWøž8¹¨c¼‘Ç{¥é×Æx¢ôãÕ›|?€çžÆ3ÔÜç&¦¤X„õ·3c'Gž\³Ö/€Á<ž²¬ÿµƒÉâw…«b›¤?¤­1®kB•ô?³Á­2€¦?r`!¦÷nt¯*Ÿ

Same thing works fine for detached signature. For attached signature, i used the following code.

CMSSignedData sigData = gen.generate(msg, true); 

Even. I tried all the charsets for the signedData String.

I found the problem and resolved it. It was due to the double signing process.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM