Esempio n. 1
0
        /// <summary>
        /// Signs and OCSP confirms the container.
        /// </summary>
        public void sign()
        {
            int err;

            /* Calculate the signature. */
            ComSignatureInfo si = new ComSignatureInfo();

            sd.createSignatureInfo(si);
            sd.addAllDocInfos(si);
            err = si.calculateSignatureWithCSPEstID(sd, 0, "");
            if (err != 0)
            {
                throw new Exception("Error signing the document: " + ei.getErrorStringByCode(err));
            }

            /* Get OCSP confirmation. */
            err = sd.getConfirmation(si, null, null, OCSP_URL, null, null);
            if (err != 0)
            {
                throw new Exception("Error getting confirmation: " + ei.getErrorStringByCode(err));
            }

            /* Verify signature and OCSP response. */
            err = sd.verifySigDoc("");
            if (err != 0)
            {
                throw new Exception("Error verifying the signature: " + ei.getErrorStringByCode(err));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Check that the signed response verifies.
        /// </summary>
        public void verify()
        {
            int err = sdoc.verifySigDoc("");

            if (err != 0)
            {
                throw new Exception("Error verifying the signed document: " + ei.getErrorStringByCode(err));
            }
        }