Beispiel #1
0
        public EsitoVerifica externalCertCheckWs(string CLRWsUrl, DocsPaVO.documento.CertificateInfo certificateToVerify)
        {
            logger.Debug("START");
            if (esito == null)
            {
                esito = new EsitoVerifica();
            }

            if (string.IsNullOrEmpty(CLRWsUrl))
            {
                logger.Error(String.Format("l'Url del componente di verifica firma {0} non è stato specificato"));
                throw new   Exception(String.Format("l'Url del componente di verifica firma {0} non è stato specificato"));
            }

            try
            {
                externalService.ClrVerification ver = new externalService.ClrVerification();
                ver.Url     = CLRWsUrl;
                ver.Timeout = 100000;
                String retval = null;

                retval = ver.DettaglioCertificato(certificateToVerify.X509Certificate, null);
                logger.Debug("VERIFY_SIGNATURE: RETVAL " + retval);
                esito = DeserializeObject <EsitoVerifica>(retval);
                return(esito);
            }
            catch (Exception e)
            {
                string msgerr = String.Format("eccezione in externalCertCheckWs: {0} \r\n {1}", e.Message, e.StackTrace);
                logger.Error(msgerr);
                esito.message = msgerr;
                return(esito);

                throw e;
            }
        }
Beispiel #2
0
        public bool externalClrCheckWS(string CLRWsUrl, string fileToverify, DateTime?dateVerifica, bool isPadesAndCades = false)
        {
            logger.Debug("START");
            if (esito == null)
            {
                esito = new EsitoVerifica();
            }

            if (string.IsNullOrEmpty(CLRWsUrl))
            {
                logger.Error(String.Format("l'Url del componente di verifica firma {0} non è stato specificato"));
                throw new   Exception(String.Format("l'Url del componente di verifica firma {0} non è stato specificato"));
            }

            try
            {
                externalService.ClrVerification ver = new externalService.ClrVerification();
                ver.Url     = CLRWsUrl;
                ver.Timeout = 100000;
                String retval = null;

                if (dateVerifica == DateTime.MinValue)
                {
                    dateVerifica = null;
                }

                if (ver.FileLocale(fileToverify))  //Controllo l'sistenza del file locale al server
                {
                    retval = ver.VerificaCertificatoFileLocale(fileToverify, dateVerifica, false, isPadesAndCades);
                }
                else //nel caso non ci fosse lo mando...
                {
                    retval = ver.VerificaCertificato(System.IO.File.ReadAllBytes(fileToverify), dateVerifica, false, isPadesAndCades);
                }


                esito = DeserializeObject <EsitoVerifica>(retval);
                if (esito.status == EsitoVerificaStatus.Valid)
                {
                    logger.Info("externalClrCheck Certificato OK");
                    return(true);
                }
                if (esito.status == EsitoVerificaStatus.NotTimeValid)
                {
                    logger.Debug("externalClrCheck Certificato SCADUTO o REVOCATO ");
                    return(false);
                }
                if (esito.status == EsitoVerificaStatus.SHA1NonSupportato)
                {
                    logger.Debug("externalClrCheck Certificato IN SHA1 non supportato");
                    return(false);
                }
                if (esito.status == EsitoVerificaStatus.Revoked)
                {
                    logger.Debug(String.Format("Certificato Revocato in data:{0} per {1} : {2} ", esito.dataRevocaCertificato, esito.SubjectCN, esito.SubjectDN));
                    return(false);
                }
                if (esito.status == EsitoVerificaStatus.ErroreGenerico)
                {
                    logger.Debug(String.Format("ErroreGenerico {0}", retval));
                    //esito.message = retval;
                    return(false);
                }
            }
            catch (Exception e)
            {
                string msgerr = String.Format("eccezione in externalClrCheck: {0} \r\n {1}", e.Message, e.StackTrace);
                logger.Error(msgerr);
                esito.message = msgerr;
                throw e;
            }
            return(false);
        }