示例#1
0
        /// <summary>
        /// Metodo para abrir el certificado de seguridad
        /// </summary>
        ///<remarks>
        /// Autor:          José Faustino Posas
        /// Company:        Ssoft Colombia
        /// Fecha:          2012-01-16
        /// -------------------
        /// Control de Cambios
        /// -------------------
        /// Autor:
        /// Fecha:
        /// Descripción:
        /// </remarks>
        public string setCertificateOpen(string sMensaje)
        {
            string sResponse = string.Empty;

            try
            {
                clsSerializer cSerializer = new clsSerializer();
                string        sDocumento  = "eServices_vasaca.crt";
                string        sFile       = clsValidaciones.XMLDatasetCreaGen() + sDocumento;

                string sFileDes        = clsValidaciones.XMLDatasetCreaGen() + sDocumento;
                string sDocumentoToken = cSerializer.RecuperaFileGen(sFileDes);

                X509Certificate2 objCertGen = new X509Certificate2(sFile);

                string sCerticicate      = setCertificateWriten(objCertGen);
                string sCertificateValid = setCertificateValidation(objCertGen);
                byte[] sCertificateFirma = setCertificateFirma(objCertGen, sMensaje);

                byte[] sCertificateFirmaValid = setCertificateFirma(objCertGen, sDocumentoToken);
                try
                {
                    string sConvertCert      = Convert.ToBase64String(sCertificateFirma);
                    string sConvertCertValid = Convert.ToBase64String(sCertificateFirmaValid);
                }
                catch { }
                byte[] sCertificateFirmaGen      = setCertificateFirmaCreate(objCertGen, sMensaje);
                byte[] sCertificateFirmaGenValid = setCertificateFirmaCreate(objCertGen, sDocumentoToken);
                try
                {
                    string sCert1      = setCertificateFirmaValidate(sCertificateFirmaGen, sMensaje);
                    string sCert1Valid = setCertificateFirmaValidate(sCertificateFirmaGenValid, sDocumentoToken);
                }
                catch { }
                byte[] sCertificateFirmaGenUltimo      = setCertificateFirmaEncrypted(objCertGen, sMensaje);
                byte[] sCertificateFirmaGenUltimoValid = setCertificateFirmaEncrypted(objCertGen, sDocumentoToken);
                try
                {
                    string sConvertCertGen = Convert.ToBase64String(sCertificateFirmaGenUltimo);
                    sResponse = sConvertCertGen;

                    byte[] sCertificateFirmaDes = setCertificateFirmaEncryptedDecode(sCertificateFirmaGenUltimo);
                    string sDecode = Encoding.ASCII.GetString(sCertificateFirmaDes);
                }
                catch { }
                try
                {
                    string sConvertCertGenValid = Convert.ToBase64String(sCertificateFirmaGenUltimoValid);

                    byte[] sCertificateFirmaDesValid = setCertificateFirmaEncryptedDecode(sCertificateFirmaGenUltimoValid);
                    string sDecodeValid = Encoding.ASCII.GetString(sCertificateFirmaDesValid);
                }
                catch { }
                //Token tkn = new Token();
                //sResponse = tkn.TokenGenerate(sMensaje, objCertGen);


                //X509Store objStore = new X509Store(StoreName.My, StoreLocation.LocalMachine);
                //objStore.Open(OpenFlags.ReadOnly);
                //foreach (X509Certificate2 objCert in objStore.Certificates)
                //    Debug.Print(objCert.SubjectName.Name + ": " + objCert.Thumbprint);
                //objStore.Close();
            }
            catch { }
            return(sResponse);
        }