attrs.push({attr: "signingTime"});
  if (f1.attr_sigcertv1.checked)
    sattrs.push({attr: "signingCertificate", array:[certPEM]});
  if (f1.attr_sigcertv2.checked)
    sattrs.push({attr: "signingCertificateV2", array:[certPEM]});
  if (f1.attr_sigpol_flag.checked) {
    sattrs.push({
      attr: "signaturePolicyIdentifier",
      oid: f1.attr_sigpol_oid.value,
      alg: f1.attr_sigpol_hashalg.value,
      hash: f1.attr_sigpol_hash.value
    });
  }

  var hCmsSignedData;
  try {
    //aler