• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Want to add metadata (XML) into the conent of CMSSignedData!!

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am new to Bouncycastle and trying to create a unsigned PKCS7 file (.p7c). After going through api available, I am able to create the .p7c file using below code.
Now I want to add a metadata in ContentType to this file. I am not getting any API to do so.
Can anyone please help me how can I change/create/re-write a content object and assign it to the CMSSignedData.

................


byte[] metaDataByte = loadFileData(metaData);

CMSProcessable msg = new CMSProcessableByteArray(metaDataByte);

Store certStores = new JcaCertStore(certList);

CMSSignedDataGenerator gen = new CMSSignedDataGenerator();
gen.addCertificates(certStores);
CMSSignedData sigData = gen.generate(msg, "BC");


pkcs7File = getPKCS7OutFile(createFile);
outStr = new FileOutputStream(pkcs7File);
outStr.write(sigData.getEncoded());

.....................................................

The above code is giving me output while viewing in openssl as

CMS_ContentInfo:
contentType: pkcs7-signedData (1.2.840.113549.1.7.2)
d.signedData:
version: 1
digestAlgorithms:
<EMPTY>
encapContentInfo:
eContentType: pkcs7-data (1.2.840.113549.1.7.1)
eContent: <ABSENT>
certificates:
d.certificate:
cert_info:

****
I want to add a xml file encoded in uTF-8 to the econent which is <Absent> In previous case. The desired output should be

CMS_ContentInfo:
contentType: pkcs7-signedData (1.2.840.113549.1.7.2)
d.signedData:
version: 1
digestAlgorithms:
<EMPTY>
encapContentInfo:
eContentType: pkcs7-data (1.2.840.113549.1.7.1)
eContent:
0000 - 3c 3f 78 6d 6c 20 76 65-72 73 69 6f 6e 3d 22 <?xml version="
000f - 31 2e 30 22 3f 3e 0d 0a-3c 74 65 73 74 53 74 1.0"?>..<testSt
001e - 72 75 63 74 75 72 65 3e-53 61 6d 70 6c 65 20 ructure>Sample
002d - 4d 65 74 61 64 61 74 61-3c 2f 74 65 73 74 53 Metadata</testS
003c - 74 72 75 63 74 75 72 65-3e tructure>
certificates:




Any help will be highly appreciated.... thanks in advance
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic