title: Adding Signing certificate as signed attributes in CMS
body: <p>Is this the way to add the signing certificate as signed attribute?</p>
  
  <pre><code>JcaSignerInfoGeneratorBuilder builder = new JcaSignerInfoGeneratorBuilder(new JcaDigestCalculatorProviderBuilder().setProvider("BC").build());
  Attribute attr = new Attribute(CMSAttributes.messageDigest, new DERSet(new DEROctetString( this.digest(myCert.getEncoded()) )));// using SHA-512 for this.digest()
  ASN1EncodableVector v = new ASN1EncodableVector();
  v.add(attr);
  builder.setSignedAttributeGenerator(new DefaultSignedAttributeTableGenerator(new AttributeTable(v)));
  </code></pre>
  
  <p>On verification</p>
  
  <pre><code>signerInformation.verify(new JcaSimpleSignerInfoVerifierBuilder().setProvider("BC").build(cert))
  </code></pre>
  
  <p>I got exception:</p>
  
  <pre><code>org.bouncycastle.cms.CMSSignerDigestMismatchException: message-digest attribute value does not match calculated value
  </code></pre>
  
  <p>For digest calculation of the attribute I use SHA-512, for signing SHA512withRSA.</p>