Exemplo n.º 1
0
        public static KIBSResponse GenerateTimeStamp(string mimMessage)
        {
            byte[]      bytData = Encoding.UTF8.GetBytes(mimMessage);
            SHA1Managed sha     = new SHA1Managed();

            byte[] hash = sha.ComputeHash(bytData);

            var oWS = new wsTSATest();

            oWS.Url = (string)Microsoft.Win32.Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\MIM", "KIBSUrl", "");
            var kibsCertificationPath     = (string)Microsoft.Win32.Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\MIM", "KIBSCertificationPath", "");     //WebConfigurationManager.AppSettings["KIBSCertificationPath"];
            var kibsCertificationPassword = (string)Microsoft.Win32.Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\MIM", "KIBSCertificationPassword", ""); //WebConfigurationManager.AppSettings["KIBSCertificationPassword"];
            var cer = new X509Certificate2(kibsCertificationPath, kibsCertificationPassword);

            oWS.ClientCertificates.Add(cer);
            var resp = oWS.funGenerateTS_Bytes(hash);

            oWS.Dispose();

            var    convert        = Convert.ToBase64String(resp.bytTSToken);
            var    token          = new Org.BouncyCastle.Tsp.TimeStampToken(new CmsSignedData(resp.bytTSToken));
            var    datetimeTS     = token.TimeStampInfo.GenTime;
            string strFailureInfo = resp.strFailureInfo;
            var    response       = new KIBSResponse();

            if (strFailureInfo != "")
            {
                response.IsSuccessful = false;
            }


            response.Hash      = convert;
            response.TimeStamp = datetimeTS;
            return(response);
        }
        public bool CheckAndGetMessageLogTimeStamp(string tokenTimestamp)
        {
            var oWS = new wsTSATest();

            oWS.Url = "https://wstsatest.kibs.mk/wsTSATest.asmx";
            var kibsCertificationPath     = WebConfigurationManager.AppSettings["KIBSCertificationPath"];
            var kibsCertificationPassword = WebConfigurationManager.AppSettings["KIBSCertificationPassword"];
            var cer = new X509Certificate2(kibsCertificationPath, kibsCertificationPassword);

            oWS.ClientCertificates.Add(cer);
            byte[] temp_backToBytes = Convert.FromBase64String(tokenTimestamp);
            var    response         = oWS.funCheckTS_Bytes(temp_backToBytes);

            oWS.Dispose();
            if (response.strFailureInfo == "")
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 3
0
        public string GetMessageLogCheckTimeStamp(TokenTimestampModel tokenTimestamp)
        {
            var oWS = new wsTSATest();

            oWS.Url = "https://wstsatest.kibs.mk/wsTSATest.asmx";
            var kibsCertificationPath     = WebConfigurationManager.AppSettings["KIBSCertificationPath"];
            var kibsCertificationPassword = WebConfigurationManager.AppSettings["KIBSCertificationPassword"];
            var cer = new X509Certificate2(kibsCertificationPath, kibsCertificationPassword);

            oWS.ClientCertificates.Add(cer);
            byte[] temp_backToBytes = Convert.FromBase64String(tokenTimestamp.TokenTimestamp);
            var    response         = oWS.funCheckTS_Bytes(temp_backToBytes);

            oWS.Dispose();
            if (response.strFailureInfo == "")
            {
                return("Проверката е успешна.");
            }
            else
            {
                return(response.strFailureInfo);
            }
        }