Esempio n. 1
0
        internal bool InitCa(out string strmsg)
        {
            //是否插入启动设备
            strmsg = "";
            try
            {
                medicalTK = new JITUsbKeyComLib.MedicalTKClass();
            }
            catch (Exception err)
            {
                strmsg = "clientkey Error:" + err.Message;
                return(false);
            }
            string strcer = medicalTK.SOF_GetUserList();

            if (strcer == "")
            {
                strmsg = "请确认你的Ukey是否插入!";
                return(false);
            }
            else
            {
                string[] certarray = strcer.Split(new string[] { "&&&" }, StringSplitOptions.None);//strcer.Split(new char[3] { '&', '|', '=' });
                if (certarray.Length > 0)
                {
                    foreach (string i in certarray)
                    {
                        cerlst.Add(i);//获得用户列表
                    }
                    //不能同时插入两个KEY
                    if (cerlst.Count > 1)
                    {
                        strmsg = "终端不能同时使用多个key,请拔出一个";
                        cerlst.Clear();
                        return(false);
                    }

                    //获取Base64编码的证书字符串
                    certBase64 = medicalTK.SOF_ExportUserCert(cerlst[0]);
                    if ("".Equals(certBase64))
                    {
                        strmsg = "获取Base64编码的证书字错误码:" + medicalTK.GetLastError();
                        return(false);
                    }
                }
                else
                {
                    strmsg = "无法找到证书!";
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// 获取证书列表
        /// 卫生测试001||Haitai HaiKey HID 0#JIT#HBCAAPPLICATION_RSA#JIT#3BB9CDF1-4A07-4E72-AAFA-C5D22409B2A7
        /// </summary>
        /// <returns>证书用户信息List</returns>
        public List <string> GetUserList()
        {
            List <string> list = new List <string>();
            //获取USBKey用户
            string userArray = medicalTK.SOF_GetUserList();

            foreach (string user in userArray.Split(new char[] { '&', '&', '&' }))
            {
                if ("".Equals(user))
                {
                    continue;
                }
                list.Add(user);
            }
            if (list.Count == 0)
            {
                return(null);
            }

            return(list);
        }